Skip to content

Commit e691b02

Browse files
rscharfegitster
authored andcommitted
refs: pass NULL to refs_resolve_ref_unsafe() if hash is not needed
This allows us to get rid of two write-only variables, one of them being a SHA1 buffer. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 54fad66 commit e691b02

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

refs/files-backend.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,13 +1676,12 @@ static int commit_ref_update(struct files_ref_store *refs,
16761676
* check with HEAD only which should cover 99% of all usage
16771677
* scenarios (even 100% of the default ones).
16781678
*/
1679-
struct object_id head_oid;
16801679
int head_flag;
16811680
const char *head_ref;
16821681

16831682
head_ref = refs_resolve_ref_unsafe(&refs->base, "HEAD",
16841683
RESOLVE_REF_READING,
1685-
head_oid.hash, &head_flag);
1684+
NULL, &head_flag);
16861685
if (head_ref && (head_flag & REF_ISSYMREF) &&
16871686
!strcmp(head_ref, lock->ref_name)) {
16881687
struct strbuf log_err = STRBUF_INIT;

worktree.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ const struct worktree *find_shared_symref(const char *symref,
307307
for (i = 0; worktrees[i]; i++) {
308308
struct worktree *wt = worktrees[i];
309309
const char *symref_target;
310-
unsigned char sha1[20];
311310
struct ref_store *refs;
312311
int flags;
313312

@@ -327,7 +326,7 @@ const struct worktree *find_shared_symref(const char *symref,
327326

328327
refs = get_worktree_ref_store(wt);
329328
symref_target = refs_resolve_ref_unsafe(refs, symref, 0,
330-
sha1, &flags);
329+
NULL, &flags);
331330
if ((flags & REF_ISSYMREF) && !strcmp(symref_target, target)) {
332331
existing = wt;
333332
break;

0 commit comments

Comments
 (0)