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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Sep 23, 2017 at 11:44 UTC
e691b027b60034ed3362fc4d6065b6be85bf234b
2 files changed
+2
-4
refs/files-backend.c
+1
-2
@@ -1676,13 +1676,12 @@ static int commit_ref_update(struct files_ref_store *refs,
1676
* check with HEAD only which should cover 99% of all usage
1677
* scenarios (even 100% of the default ones).
1678
*/
1679
- struct object_id head_oid;
1679
int head_flag;
1680
const char *head_ref;
1681
1682
head_ref = refs_resolve_ref_unsafe(&refs->base, "HEAD",
1683
RESOLVE_REF_READING,
1685
- head_oid.hash, &head_flag);
1684
+ NULL, &head_flag);
1685
if (head_ref && (head_flag & REF_ISSYMREF) &&
1686
!strcmp(head_ref, lock->ref_name)) {
1687
struct strbuf log_err = STRBUF_INIT;
worktree.c
+1
-2
@@ -307,7 +307,6 @@ const struct worktree *find_shared_symref(const char *symref,
307
for (i = 0; worktrees[i]; i++) {
308
struct worktree *wt = worktrees[i];
309
const char *symref_target;
310
- unsigned char sha1[20];
310
struct ref_store *refs;
311
int flags;
312
@@ -327,7 +326,7 @@ const struct worktree *find_shared_symref(const char *symref,
326
327
refs = get_worktree_ref_store(wt);
328
symref_target = refs_resolve_ref_unsafe(refs, symref, 0,
330
- sha1, &flags);
329
+ NULL, &flags);
330
if ((flags & REF_ISSYMREF) && !strcmp(symref_target, target)) {
331
existing = wt;
332
break;