Skip to content

Commit 334dc52

Browse files
bk2204gitster
authored andcommitted
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>
1 parent b8acac5 commit 334dc52

5 files changed

Lines changed: 9 additions & 9 deletions

File tree

builtin/reflog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
602602
for (; i < argc; i++) {
603603
char *ref;
604604
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)) {
606606
status |= error("%s points nowhere!", argv[i]);
607607
continue;
608608
}
@@ -668,7 +668,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
668668
continue;
669669
}
670670

671-
if (!dwim_log(argv[i], spec - argv[i], oid.hash, &ref)) {
671+
if (!dwim_log(argv[i], spec - argv[i], &oid, &ref)) {
672672
status |= error("no reflog for '%s'", argv[i]);
673673
continue;
674674
}

reflog-walk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
161161
struct object_id oid;
162162
char *b;
163163
int ret = dwim_log(branch, strlen(branch),
164-
oid.hash, &b);
164+
&oid, &b);
165165
if (ret > 1)
166166
free(b);
167167
else if (ret == 1) {

refs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ int expand_ref(const char *str, int len, struct object_id *oid, char **ref)
497497
return refs_found;
498498
}
499499

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)
501501
{
502502
char *last_branch = substitute_branch_name(&str, &len);
503503
const char **p;
@@ -506,13 +506,13 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
506506

507507
*log = NULL;
508508
for (p = ref_rev_parse_rules; *p; p++) {
509-
unsigned char hash[20];
509+
struct object_id hash;
510510
const char *ref, *it;
511511

512512
strbuf_reset(&path);
513513
strbuf_addf(&path, *p, len, str);
514514
ref = resolve_ref_unsafe(path.buf, RESOLVE_REF_READING,
515-
hash, NULL);
515+
hash.hash, NULL);
516516
if (!ref)
517517
continue;
518518
if (reflog_exists(path.buf))
@@ -523,7 +523,7 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
523523
continue;
524524
if (!logs_found++) {
525525
*log = xstrdup(it);
526-
hashcpy(sha1, hash);
526+
oidcpy(oid, &hash);
527527
}
528528
if (!warn_ambiguous_refs)
529529
break;

refs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ int refname_match(const char *abbrev_name, const char *full_name);
141141

142142
int expand_ref(const char *str, int len, struct object_id *oid, char **ref);
143143
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);
145145

146146
/*
147147
* A ref_transaction represents a collection of reference updates that

sha1_name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
656656
/* allow "@{...}" to mean the current branch reflog */
657657
refs_found = dwim_ref("HEAD", 4, oid, &real_ref);
658658
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);
660660
else
661661
refs_found = dwim_ref(str, len, oid, &real_ref);
662662

0 commit comments

Comments
 (0)