reflog: handle $name => remotes/%s/HEAD mapping consistently for logs
When refs/remotes/gfi/master and refs/remotes/gfi/HEAD exist, and the latter is a symref that points at the former, dwim_ref() resolves string "gfi" to "refs/remotes/gfi/master" as expected, but dwim_log() does not understand "gfi@{1.day}" and needs to be told "gfi/master@{1.day}". This is confusing. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
eb3a48221f
commit
40facde06e
29
sha1_name.c
29
sha1_name.c
@ -275,16 +275,29 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
|
|||||||
*log = NULL;
|
*log = NULL;
|
||||||
for (p = ref_fmt; *p; p++) {
|
for (p = ref_fmt; *p; p++) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *path = mkpath(*p, len, str);
|
unsigned char hash[20];
|
||||||
|
char path[PATH_MAX];
|
||||||
|
const char *ref, *it;
|
||||||
|
|
||||||
|
strcpy(path, mkpath(*p, len, str));
|
||||||
|
ref = resolve_ref(path, hash, 0, NULL);
|
||||||
|
if (!ref)
|
||||||
|
continue;
|
||||||
if (!stat(git_path("logs/%s", path), &st) &&
|
if (!stat(git_path("logs/%s", path), &st) &&
|
||||||
S_ISREG(st.st_mode)) {
|
S_ISREG(st.st_mode))
|
||||||
if (!logs_found++) {
|
it = path;
|
||||||
*log = xstrdup(path);
|
else if (strcmp(ref, path) &&
|
||||||
resolve_ref(path, sha1, 0, NULL);
|
!stat(git_path("logs/%s", ref), &st) &&
|
||||||
}
|
S_ISREG(st.st_mode))
|
||||||
if (!warn_ambiguous_refs)
|
it = ref;
|
||||||
break;
|
else
|
||||||
|
continue;
|
||||||
|
if (!logs_found++) {
|
||||||
|
*log = xstrdup(it);
|
||||||
|
hashcpy(sha1, hash);
|
||||||
}
|
}
|
||||||
|
if (!warn_ambiguous_refs)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return logs_found;
|
return logs_found;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user