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>
---
Junio C Hamano <junkio@cox.net> writes:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
>> Since "git log origin/master" uses dwim_log() to match
>> "refs/remotes/origin/master", it makes sense to do that for
>> "git log --reflog", too.
>
> This is a bit sad.
>
> When there is remotes/origin/HEAD symref that points at
> remotes/origin/master (and usually there is, in a repository
> initialized with the current git-clone), you can say "git log
> origin". Even with this patch, I do not think dwim_log would
> allow you to say "git log -g origin" to mean "git log -g
> origin/master".
I think there should be a cleaner way to fix this, but at least
this seems to work.
sha1_name.c | 29 +++++++++++++++++++++--------
1 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/sha1_name.c b/sha1_name.c
index f79a7c9..09c63ed 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -275,16 +275,29 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
*log = NULL;
for (p = ref_fmt; *p; p++) {
struct stat st;
- char *path = mkpath(*p, len, str);
+ unsigned char hash[20];
+ char path[PATH_MAX];
+ 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) &&
- S_ISREG(st.st_mode)) {
- if (!logs_found++) {
- *log = xstrdup(path);
- resolve_ref(path, sha1, 0, NULL);
- }
- if (!warn_ambiguous_refs)
- break;
+ S_ISREG(st.st_mode))
+ it = path;
+ else if (strcmp(ref, path) &&
+ !stat(git_path("logs/%s", ref), &st) &&
+ S_ISREG(st.st_mode))
+ it = ref;
+ else
+ continue;
+ if (!logs_found++) {
+ *log = xstrdup(it);
+ hashcpy(sha1, hash);
}
+ if (!warn_ambiguous_refs)
+ break;
}
return logs_found;
}
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
| Oren Laadan | [RFC v2][PATCH 1/9] kernel based checkpoint-restart |
| Luiz Fernando N. Capitulino | 2.6.{26.2,27-rc} oops on virtualbox |
| Tomasz Kłoczko | Is it time for remove (crap) ALSA from kernel tree ? |
| Linus Torvalds | Linux 2.6.27-rc8 |
git: | |
| Linus Torvalds | Re: cleaner/better zlib sources? |
| Jon Smirl | Re: [PATCH] RFC: git lazy clone proof-of-concept |
| Jan-Benedict Glaw | Re: parsecvs tool now creates git repositories |
| Matthieu Moy | git push to a non-bare repository |
| James Hartley | scp batch mode? |
| Alexey Suslikov | OT: OpenBSD on Asus eeePC |
| Karel Kulhavy | lookup option in /etc/resolv.conf ignored |
| Kevin Neff | Patching a SSH 'Weakness' |
| Volker Armin Hemmann | build error with 2.6.27.6+reiser4+ehci-hub patch. ERROR: "mii_ethtool_gset" [drive... |
| Denys Fedoryshchenko | RESEND, HTB(?) softlockup, vanilla 2.6.24 |
| Corey Hickey | [PATCH 05/10] Add divisor. |
| Scott Wood | [PATCH 1/9] fs_enet: Whitespace cleanup. |
| Why does uClinux 2.6.18 bootup block SuperIO UART IRQs that BIOS configured | 18 minutes ago | Linux kernel |
| USB statistics | 1 hour ago | Linux kernel |
| Block Sub System query | 5 hours ago | Linux kernel |
| kernel module to intercept socket creation | 7 hours ago | Linux kernel |
| Image size changing during each build | 7 hours ago | Linux kernel |
| Soft lock bug | 12 hours ago | Linux kernel |
| sysctl - dynamic registration problem | 18 hours ago | Linux kernel |
| Question on swap as ramdisk partition | 20 hours ago | Linux kernel |
| serial driver xmit problem | 1 day ago | Linux kernel |
| Generic Netlink subsytem | 1 day ago | Linux kernel |
