Skip to content

Commit

Permalink
refs: convert dwim_log to struct object_id
Browse files Browse the repository at this point in the history
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
bk2204 authored and gitster committed Oct 16, 2017
1 parent b8acac5 commit 334dc52
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions builtin/reflog.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
for (; i < argc; i++) {
char *ref;
struct object_id oid;
if (!dwim_log(argv[i], strlen(argv[i]), oid.hash, &ref)) {
if (!dwim_log(argv[i], strlen(argv[i]), &oid, &ref)) {
status |= error("%s points nowhere!", argv[i]);
continue;
}
Expand Down Expand Up @@ -668,7 +668,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
continue;
}

if (!dwim_log(argv[i], spec - argv[i], oid.hash, &ref)) {
if (!dwim_log(argv[i], spec - argv[i], &oid, &ref)) {
status |= error("no reflog for '%s'", argv[i]);
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion reflog-walk.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
struct object_id oid;
char *b;
int ret = dwim_log(branch, strlen(branch),
oid.hash, &b);
&oid, &b);
if (ret > 1)
free(b);
else if (ret == 1) {
Expand Down
8 changes: 4 additions & 4 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ int expand_ref(const char *str, int len, struct object_id *oid, char **ref)
return refs_found;
}

int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
int dwim_log(const char *str, int len, struct object_id *oid, char **log)
{
char *last_branch = substitute_branch_name(&str, &len);
const char **p;
Expand All @@ -506,13 +506,13 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)

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

strbuf_reset(&path);
strbuf_addf(&path, *p, len, str);
ref = resolve_ref_unsafe(path.buf, RESOLVE_REF_READING,
hash, NULL);
hash.hash, NULL);
if (!ref)
continue;
if (reflog_exists(path.buf))
Expand All @@ -523,7 +523,7 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
continue;
if (!logs_found++) {
*log = xstrdup(it);
hashcpy(sha1, hash);
oidcpy(oid, &hash);
}
if (!warn_ambiguous_refs)
break;
Expand Down
2 changes: 1 addition & 1 deletion refs.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ int refname_match(const char *abbrev_name, const char *full_name);

int expand_ref(const char *str, int len, struct object_id *oid, char **ref);
int dwim_ref(const char *str, int len, struct object_id *oid, char **ref);
int dwim_log(const char *str, int len, unsigned char *sha1, char **ref);
int dwim_log(const char *str, int len, struct object_id *oid, char **ref);

/*
* A ref_transaction represents a collection of reference updates that
Expand Down
2 changes: 1 addition & 1 deletion sha1_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
/* allow "@{...}" to mean the current branch reflog */
refs_found = dwim_ref("HEAD", 4, oid, &real_ref);
else if (reflog_len)
refs_found = dwim_log(str, len, oid->hash, &real_ref);
refs_found = dwim_log(str, len, oid, &real_ref);
else
refs_found = dwim_ref(str, len, oid, &real_ref);

Expand Down

0 comments on commit 334dc52

Please sign in to comment.