refs: convert dwim_log to struct object_id

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Oct 15, 2017 at 22:06 UTC 334dc52f49ee3e56a32142d3500fe93ef79aac67
5 files changed +9 -9
builtin/reflog.c
+2 -2
@@ -602,7 +602,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
602 for (; i < argc; i++) {
603 char *ref;
604 struct object_id oid;
605 - if (!dwim_log(argv[i], strlen(argv[i]), oid.hash, &ref)) {
605 + if (!dwim_log(argv[i], strlen(argv[i]), &oid, &ref)) {
606 status |= error("%s points nowhere!", argv[i]);
607 continue;
608 }
@@ -668,7 +668,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
668 continue;
669 }
670
671 - if (!dwim_log(argv[i], spec - argv[i], oid.hash, &ref)) {
671 + if (!dwim_log(argv[i], spec - argv[i], &oid, &ref)) {
672 status |= error("no reflog for '%s'", argv[i]);
673 continue;
674 }
reflog-walk.c
+1 -1
@@ -161,7 +161,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
161 struct object_id oid;
162 char *b;
163 int ret = dwim_log(branch, strlen(branch),
164 - oid.hash, &b);
164 + &oid, &b);
165 if (ret > 1)
166 free(b);
167 else if (ret == 1) {
refs.c
+4 -4
@@ -497,7 +497,7 @@ int expand_ref(const char *str, int len, struct object_id *oid, char **ref)
497 return refs_found;
498 }
499
500 -int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
500 +int dwim_log(const char *str, int len, struct object_id *oid, char **log)
501 {
502 char *last_branch = substitute_branch_name(&str, &len);
503 const char **p;
@@ -506,13 +506,13 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
506
507 *log = NULL;
508 for (p = ref_rev_parse_rules; *p; p++) {
509 - unsigned char hash[20];
509 + struct object_id hash;
510 const char *ref, *it;
511
512 strbuf_reset(&path);
513 strbuf_addf(&path, *p, len, str);
514 ref = resolve_ref_unsafe(path.buf, RESOLVE_REF_READING,
515 - hash, NULL);
515 + hash.hash, NULL);
516 if (!ref)
517 continue;
518 if (reflog_exists(path.buf))
@@ -523,7 +523,7 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
523 continue;
524 if (!logs_found++) {
525 *log = xstrdup(it);
526 - hashcpy(sha1, hash);
526 + oidcpy(oid, &hash);
527 }
528 if (!warn_ambiguous_refs)
529 break;
refs.h
+1 -1
@@ -141,7 +141,7 @@ int refname_match(const char *abbrev_name, const char *full_name);
141
142 int expand_ref(const char *str, int len, struct object_id *oid, char **ref);
143 int dwim_ref(const char *str, int len, struct object_id *oid, char **ref);
144 -int dwim_log(const char *str, int len, unsigned char *sha1, char **ref);
144 +int dwim_log(const char *str, int len, struct object_id *oid, char **ref);
145
146 /*
147 * A ref_transaction represents a collection of reference updates that
sha1_name.c
+1 -1
@@ -656,7 +656,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
656 /* allow "@{...}" to mean the current branch reflog */
657 refs_found = dwim_ref("HEAD", 4, oid, &real_ref);
658 else if (reflog_len)
659 - refs_found = dwim_log(str, len, oid->hash, &real_ref);
659 + refs_found = dwim_log(str, len, oid, &real_ref);
660 else
661 refs_found = dwim_ref(str, len, oid, &real_ref);
662