{"thread":{"id":"6732","subject":"[BUG] Empty reflogs and \"git log -g\"","startedAt":"2007-02-08T01:21:33Z","lastAt":"2007-02-09T07:19:59Z","messageCount":13,"participants":["Santi Béjar","Johannes Schindelin","Jakub Narebski","Nicolas Pitre","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"33907","messageId":"8aa486160702071721s401ea38fxa8eb71bb694a6915@mail.gmail.com","threadId":"6732","inReplyTo":null,"subject":"[BUG] Empty reflogs and \"git log -g\"","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2007-02-08T01:21:33Z","receivedAt":"2007-02-08T01:21:33Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"Hi *,\n\n  when a reflog entry do not have a reflog message the refs@{num}\nsyntax gives a different result than with 'git log -g'. Actually 'git\nlog -g' just skips this ref.\n\nRegards,\n\nSanti\n"},{"id":"33917","messageId":"8aa486160702072325q1d63c5d2mc1c6a492392802c6@mail.gmail.com","threadId":"6732","inReplyTo":"8aa486160702071721s401ea38fxa8eb71bb694a6915@mail.gmail.com","subject":"Re: [BUG] Empty reflogs and \"git log -g\"","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2007-02-08T07:25:20Z","receivedAt":"2007-02-08T07:25:20Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On 2/8/07, Santi Béjar <sbejar@gmail.com> wrote:\n> Hi *,\n>\n>   when a reflog entry do not have a reflog message the refs@{num}\n> syntax gives a different result than with 'git log -g'. Actually 'git\n> log -g' just skips this ref.\n>\n\nAlso:\n\n$ git log origin/master\n\nworks, but\n\n$ git log -g origin/master\n\ndoes not. You have to put the remotes prefix.\n\nSanti\n"},{"id":"33956","messageId":"Pine.LNX.4.63.0702082021210.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6732","inReplyTo":"8aa486160702071721s401ea38fxa8eb71bb694a6915@mail.gmail.com","subject":"Re: [BUG] Empty reflogs and \"git log -g\"","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-08T19:22:17Z","receivedAt":"2007-02-08T19:22:17Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 8 Feb 2007, Santi Béjar wrote:\n\n>  when a reflog entry do not have a reflog message the refs@{num} syntax \n> gives a different result than with 'git log -g'. Actually 'git log -g' \n> just skips this ref.\n\nI could be that some older git version produces empty messages. But I'd \nregard the empty messages to be the problem. Or is the current Git version \nstill producing such entries?\n\nCiao,\nDscho\n"},{"id":"33958","messageId":"Pine.LNX.4.63.0702082022200.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6732","inReplyTo":"8aa486160702072325q1d63c5d2mc1c6a492392802c6@mail.gmail.com","subject":"Re: [BUG] Empty reflogs and \"git log -g\"","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-08T19:36:03Z","receivedAt":"2007-02-08T19:36:03Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 8 Feb 2007, Santi Béjar wrote:\n\n> On 2/8/07, Santi Béjar <sbejar@gmail.com> wrote:\n> > Hi *,\n> > \n> >   when a reflog entry do not have a reflog message the refs@{num}\n> > syntax gives a different result than with 'git log -g'. Actually 'git\n> > log -g' just skips this ref.\n> > \n> \n> Also:\n> \n> $ git log origin/master\n> \n> works, but\n> \n> $ git log -g origin/master\n> \n> does not. You have to put the remotes prefix.\n\nI hesitate \"fixing\" that. I mean, if you want to know about the remote \nbranch \"master\" why not be precise? Yes, \"git log\" _is_ nice if you want \nto be sloppy.\n\nBut if you _have_ to have it, see attached patch. I will not push for it \nin time for 1.5.0, though, since I have a track record of not getting \npatches right on the first try.\n\nCiao,\nDscho\n\n---\n\n reflog-walk.c |   13 +++++++++++++\n 1 files changed, 13 insertions(+), 0 deletions(-)\n\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex 653ec95..430faef 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -174,6 +174,19 @@ void add_reflog_for_walk(struct reflog_walk_info *info,\n \t\t\tbranch = xstrdup(head);\n \t\t}\n \t\treflogs = read_complete_reflog(branch);\n+\t\tif (!reflogs || reflogs->nr == 0) {\n+\t\t\tunsigned char sha1[20];\n+\t\t\tchar *b;\n+\t\t\tif (dwim_ref(branch, strlen(branch), sha1, &b) == 1) {\n+\t\t\t\tif (reflogs) {\n+\t\t\t\t\tfree(reflogs->ref);\n+\t\t\t\t\tfree(reflogs);\n+\t\t\t\t}\n+\t\t\t\tfree(branch);\n+\t\t\t\tbranch = b;\n+\t\t\t\treflogs = read_complete_reflog(branch);\n+\t\t\t}\n+\t\t}\n \t\tif (!reflogs || reflogs->nr == 0)\n \t\t\tdie(\"No reflogs found for '%s'\", branch);\n \t\tpath_list_insert(branch, &info->complete_reflogs)->util"},{"id":"33959","messageId":"eqfu36$lb3$1@sea.gmane.org","threadId":"6732","inReplyTo":"Pine.LNX.4.63.0702082021210.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [BUG] Empty reflogs and \"git log -g\"","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-02-08T19:37:44Z","receivedAt":"2007-02-08T19:37:44Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Johannes Schindelin wrote:\n\n> On Thu, 8 Feb 2007, Santi Béjar wrote:\n> \n>>  when a reflog entry do not have a reflog message the refs@{num} syntax \n>> gives a different result than with 'git log -g'. Actually 'git log -g' \n>> just skips this ref.\n> \n> I could be that some older git version produces empty messages. But I'd \n> regard the empty messages to be the problem. Or is the current Git version \n> still producing such entries?\n\nStGIT used to produce no reflog messages; I don't know if this has improved.\nBut you can have old reflog entries with empty messages; git log -g should\ndeal with them IMHO.\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"33960","messageId":"Pine.LNX.4.63.0702082040390.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6732","inReplyTo":"eqfu36$lb3$1@sea.gmane.org","subject":"Re: [BUG] Empty reflogs and \"git log -g\"","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-08T19:46:43Z","receivedAt":"2007-02-08T19:46:43Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\n[Cc'ing the mailing list, not the newsgroup]\n\nOn Thu, 8 Feb 2007, Jakub Narebski wrote:\n\n> Johannes Schindelin wrote:\n> \n> > On Thu, 8 Feb 2007, Santi Béjar wrote:\n> > \n> >>  when a reflog entry do not have a reflog message the refs@{num} syntax \n> >> gives a different result than with 'git log -g'. Actually 'git log -g' \n> >> just skips this ref.\n> > \n> > I could be that some older git version produces empty messages. But I'd \n> > regard the empty messages to be the problem. Or is the current Git version \n> > still producing such entries?\n> \n> StGIT used to produce no reflog messages; I don't know if this has \n> improved. But you can have old reflog entries with empty messages; git \n> log -g should deal with them IMHO.\n\nI just tried. An empty string is not enough. The tab before the message \nhas to be lacking, too.\n\nHere's a small patch, if you have to have it.\n\n---\n\n refs.c |    8 +++++---\n 1 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 7e07fc4..ba5bd2d 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1189,12 +1189,14 @@ int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)\n \t\t    !message || message[0] != ' ' ||\n \t\t    (message[1] != '+' && message[1] != '-') ||\n \t\t    !isdigit(message[2]) || !isdigit(message[3]) ||\n-\t\t    !isdigit(message[4]) || !isdigit(message[5]) ||\n-\t\t    message[6] != '\\t')\n+\t\t    !isdigit(message[4]) || !isdigit(message[5]))\n \t\t\tcontinue; /* corrupt? */\n \t\temail_end[1] = '\\0';\n \t\ttz = strtol(message + 1, NULL, 10);\n-\t\tmessage += 7;\n+\t\tif (message[6] != '\\t')\n+\t\t\tmessage += 6;\n+\t\telse\n+\t\t\tmessage += 7;\n \t\tret = fn(osha1, nsha1, buf+82, timestamp, tz, message, cb_data);\n \t\tif (ret)\n \t\t\tbreak;"},{"id":"33961","messageId":"Pine.LNX.4.64.0702081447050.13009@xanadu.home","threadId":"6732","inReplyTo":"Pine.LNX.4.63.0702082022200.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [BUG] Empty reflogs and \"git log -g\"","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-02-08T19:49:23Z","receivedAt":"2007-02-08T19:49:23Z","isPatch":false,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Thu, 8 Feb 2007, Johannes Schindelin wrote:\n\n> But if you _have_ to have it, see attached patch. I will not push for it \n> in time for 1.5.0, though, since I have a track record of not getting \n> patches right on the first try.\n\nWell.... to that effect I'd suggest you use dwim_log() instead.\nOtherwise it'll break the HEAD reflog.\n\n\nNicolas\n"},{"id":"33963","messageId":"Pine.LNX.4.63.0702082102140.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6732","inReplyTo":"Pine.LNX.4.64.0702081447050.13009@xanadu.home","subject":"Re: [BUG] Empty reflogs and \"git log -g\"","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-08T20:02:41Z","receivedAt":"2007-02-08T20:02:41Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 8 Feb 2007, Nicolas Pitre wrote:\n\n> On Thu, 8 Feb 2007, Johannes Schindelin wrote:\n> \n> > But if you _have_ to have it, see attached patch. I will not push for it \n> > in time for 1.5.0, though, since I have a track record of not getting \n> > patches right on the first try.\n> \n> Well.... to that effect I'd suggest you use dwim_log() instead.\n> Otherwise it'll break the HEAD reflog.\n\nThanks! I did not see that... See, I told you about my first tries with \npatches...\n\nCiao,\nDscho\n"},{"id":"34000","messageId":"7vveicw850.fsf@assigned-by-dhcp.cox.net","threadId":"6732","inReplyTo":"Pine.LNX.4.63.0702082040390.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [BUG] Empty reflogs and \"git log -g\"","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-08T23:18:35Z","receivedAt":"2007-02-08T23:18:35Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Thu, 8 Feb 2007, Jakub Narebski wrote:\n>\n>> StGIT used to produce no reflog messages; I don't know if this has \n>> improved. But you can have old reflog entries with empty messages; git \n>> log -g should deal with them IMHO.\n>\n> I just tried. An empty string is not enough. The tab before the message \n> has to be lacking, too.\n>\n> Here's a small patch, if you have to have it.\n\nI think this is necessary for v1.5.0.  I'd appreciate a properly\nsigned-off log message.\n\n>\n> ---\n>\n>  refs.c |    8 +++++---\n>  1 files changed, 5 insertions(+), 3 deletions(-)\n>\n> diff --git a/refs.c b/refs.c\n> index 7e07fc4..ba5bd2d 100644\n> --- a/refs.c\n> +++ b/refs.c\n> @@ -1189,12 +1189,14 @@ int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)\n>  \t\t    !message || message[0] != ' ' ||\n>  \t\t    (message[1] != '+' && message[1] != '-') ||\n>  \t\t    !isdigit(message[2]) || !isdigit(message[3]) ||\n> -\t\t    !isdigit(message[4]) || !isdigit(message[5]) ||\n> -\t\t    message[6] != '\\t')\n> +\t\t    !isdigit(message[4]) || !isdigit(message[5]))\n>  \t\t\tcontinue; /* corrupt? */\n>  \t\temail_end[1] = '\\0';\n>  \t\ttz = strtol(message + 1, NULL, 10);\n> -\t\tmessage += 7;\n> +\t\tif (message[6] != '\\t')\n> +\t\t\tmessage += 6;\n> +\t\telse\n> +\t\t\tmessage += 7;\n>  \t\tret = fn(osha1, nsha1, buf+82, timestamp, tz, message, cb_data);\n>  \t\tif (ret)\n>  \t\t\tbreak;\n"},{"id":"34014","messageId":"Pine.LNX.4.63.0702090057210.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6732","inReplyTo":"7vveicw850.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] for_each_reflog_ent: be forgiving about missing message","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-08T23:59:47Z","receivedAt":"2007-02-08T23:59:47Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nSome reflogs are/were generated without a message; do not plainly\nignore those entries.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tOn Thu, 8 Feb 2007, Junio C Hamano wrote:\n\n\t> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\t> \n\t> > On Thu, 8 Feb 2007, Jakub Narebski wrote:\n\t> >\n\t> >> StGIT used to produce no reflog messages; I don't know if \n\t> >> this has improved. But you can have old reflog entries with \n\t> >> empty messages; git log -g should deal with them IMHO.\n\t> >\n\t> > I just tried. An empty string is not enough. The tab before \n\t> > the message has to be lacking, too.\n\t> >\n\t> > Here's a small patch, if you have to have it.\n\t> \n\t> I think this is necessary for v1.5.0.  I'd appreciate a properly\n\t> signed-off log message.\n\n\tVoila!\n\n refs.c |    8 +++++---\n 1 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 7e07fc4..ba5bd2d 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1189,12 +1189,14 @@ int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)\n \t\t    !message || message[0] != ' ' ||\n \t\t    (message[1] != '+' && message[1] != '-') ||\n \t\t    !isdigit(message[2]) || !isdigit(message[3]) ||\n-\t\t    !isdigit(message[4]) || !isdigit(message[5]) ||\n-\t\t    message[6] != '\\t')\n+\t\t    !isdigit(message[4]) || !isdigit(message[5]))\n \t\t\tcontinue; /* corrupt? */\n \t\temail_end[1] = '\\0';\n \t\ttz = strtol(message + 1, NULL, 10);\n-\t\tmessage += 7;\n+\t\tif (message[6] != '\\t')\n+\t\t\tmessage += 6;\n+\t\telse\n+\t\t\tmessage += 7;\n \t\tret = fn(osha1, nsha1, buf+82, timestamp, tz, message, cb_data);\n \t\tif (ret)\n \t\t\tbreak;\n"},{"id":"34021","messageId":"Pine.LNX.4.63.0702090127510.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6732","inReplyTo":"7vveicw850.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] log --reflog: use dwim_log","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-09T00:28:23Z","receivedAt":"2007-02-09T00:28:23Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nSince \"git log origin/master\" uses dwim_log() to match\n\"refs/remotes/origin/master\", it makes sense to do that for\n\"git log --reflog\", too.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n\n\tI changed dwim_ref() to dwim_log() as per Nico's request.\n\n cache.h       |    1 +\n reflog-walk.c |   13 +++++++++++++\n sha1_name.c   |    2 +-\n 3 files changed, 15 insertions(+), 1 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 6f55fdc..44941c0 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -304,6 +304,7 @@ extern char *sha1_to_hex(const unsigned char *sha1);\t/* static buffer result! */\n extern int read_ref(const char *filename, unsigned char *sha1);\n extern const char *resolve_ref(const char *path, unsigned char *sha1, int, int *);\n extern int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref);\n+extern int dwim_log(const char *str, int len, unsigned char *sha1, char **ref);\n \n extern int create_symref(const char *ref, const char *refs_heads_master, const char *logmsg);\n extern int validate_headref(const char *ref);\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex 653ec95..e0f1332 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -174,6 +174,19 @@ void add_reflog_for_walk(struct reflog_walk_info *info,\n \t\t\tbranch = xstrdup(head);\n \t\t}\n \t\treflogs = read_complete_reflog(branch);\n+\t\tif (!reflogs || reflogs->nr == 0) {\n+\t\t\tunsigned char sha1[20];\n+\t\t\tchar *b;\n+\t\t\tif (dwim_log(branch, strlen(branch), sha1, &b) == 1) {\n+\t\t\t\tif (reflogs) {\n+\t\t\t\t\tfree(reflogs->ref);\n+\t\t\t\t\tfree(reflogs);\n+\t\t\t\t}\n+\t\t\t\tfree(branch);\n+\t\t\t\tbranch = b;\n+\t\t\t\treflogs = read_complete_reflog(branch);\n+\t\t\t}\n+\t\t}\n \t\tif (!reflogs || reflogs->nr == 0)\n \t\t\tdie(\"No reflogs found for '%s'\", branch);\n \t\tpath_list_insert(branch, &info->complete_reflogs)->util\ndiff --git a/sha1_name.c b/sha1_name.c\nindex d0d9536..c50a378 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -268,7 +268,7 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)\n \treturn refs_found;\n }\n \n-static int dwim_log(const char *str, int len, unsigned char *sha1, char **log)\n+int dwim_log(const char *str, int len, unsigned char *sha1, char **log)\n {\n \tconst char **p;\n \tint logs_found = 0;\n-- \n1.5.0.rc4.2051.g679c-dirty\n"},{"id":"34033","messageId":"7vtzxwuhb1.fsf@assigned-by-dhcp.cox.net","threadId":"6732","inReplyTo":"Pine.LNX.4.63.0702090127510.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] log --reflog: use dwim_log","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-09T03:43:30Z","receivedAt":"2007-02-09T03:43:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Since \"git log origin/master\" uses dwim_log() to match\n> \"refs/remotes/origin/master\", it makes sense to do that for\n> \"git log --reflog\", too.\n\nThis is a bit sad.\n\nWhen there is remotes/origin/HEAD symref that points at\nremotes/origin/master (and usually there is, in a repository\ninitialized with the current git-clone), you can say \"git log\norigin\".  Even with this patch, I do not think dwim_log would\nallow you to say \"git log -g origin\" to mean \"git log -g\norigin/master\".\n"},{"id":"34037","messageId":"7v4ppvvluo.fsf@assigned-by-dhcp.cox.net","threadId":"6732","inReplyTo":"7vtzxwuhb1.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] log --reflog: use dwim_log","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-09T07:19:59Z","receivedAt":"2007-02-09T07:19:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When refs/remotes/gfi/master and refs/remotes/gfi/HEAD exist,\nand the latter is a symref that points at the former, dwim_ref()\nresolves string \"gfi\" to \"refs/remotes/gfi/master\" as expected,\nbut dwim_log() does not understand \"gfi@{1.day}\" and needs to be\ntold \"gfi/master@{1.day}\".  This is confusing.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n Junio C Hamano <junkio@cox.net> writes:\n\n > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n >\n >> Since \"git log origin/master\" uses dwim_log() to match\n >> \"refs/remotes/origin/master\", it makes sense to do that for\n >> \"git log --reflog\", too.\n >\n > This is a bit sad.\n >\n > When there is remotes/origin/HEAD symref that points at\n > remotes/origin/master (and usually there is, in a repository\n > initialized with the current git-clone), you can say \"git log\n > origin\".  Even with this patch, I do not think dwim_log would\n > allow you to say \"git log -g origin\" to mean \"git log -g\n > origin/master\".\n\n I think there should be a cleaner way to fix this, but at least\n this seems to work.\n\n sha1_name.c |   29 +++++++++++++++++++++--------\n 1 files changed, 21 insertions(+), 8 deletions(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex f79a7c9..09c63ed 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -275,16 +275,29 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)\n \t*log = NULL;\n \tfor (p = ref_fmt; *p; p++) {\n \t\tstruct stat st;\n-\t\tchar *path = mkpath(*p, len, str);\n+\t\tunsigned char hash[20];\n+\t\tchar path[PATH_MAX];\n+\t\tchar *ref, *it;\n+\n+\t\tstrcpy(path, mkpath(*p, len, str));\n+\t\tref = resolve_ref(path, hash, 0, NULL);\n+\t\tif (!ref)\n+\t\t\tcontinue;\n \t\tif (!stat(git_path(\"logs/%s\", path), &st) &&\n-\t\t    S_ISREG(st.st_mode)) {\n-\t\t\tif (!logs_found++) {\n-\t\t\t\t*log = xstrdup(path);\n-\t\t\t\tresolve_ref(path, sha1, 0, NULL);\n-\t\t\t}\n-\t\t\tif (!warn_ambiguous_refs)\n-\t\t\t\tbreak;\n+\t\t    S_ISREG(st.st_mode))\n+\t\t\tit = path;\n+\t\telse if (strcmp(ref, path) &&\n+\t\t\t !stat(git_path(\"logs/%s\", ref), &st) &&\n+\t\t\t S_ISREG(st.st_mode))\n+\t\t\tit = ref;\n+\t\telse\n+\t\t\tcontinue;\n+\t\tif (!logs_found++) {\n+\t\t\t*log = xstrdup(it);\n+\t\t\thashcpy(sha1, hash);\n \t\t}\n+\t\tif (!warn_ambiguous_refs)\n+\t\t\tbreak;\n \t}\n \treturn logs_found;\n }\n"}]}