{"thread":{"id":"21323","subject":"git describe is failing","startedAt":"2009-10-22T14:47:10Z","lastAt":"2009-10-28T22:10:06Z","messageCount":13,"participants":["Eugene Sajine","Mikael Magnusson","Thomas Rast","Alex Riesen","Junio C Hamano","Nicolas Pitre"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"125703","messageId":"76c5b8580910220747w709d2b41s4f7b121e421e843c@mail.gmail.com","threadId":"21323","inReplyTo":null,"subject":"git describe is failing","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2009-10-22T14:47:10Z","receivedAt":"2009-10-22T14:47:10Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"Hi,\n\nI have a test repo which I'm playing with. It has about 15 commits and\none branch only (master) and couple of tags. Somehow it got to a state\nwhen\n\n$ git describe\n\ngives:\n\nfatal: cannot describe 'SHA-1'\n\nThe command is working ok with my other repo. It doesn't seem that the\ntest repo is corrupted. I can commit, push and pull, see the history\nwith gitk... How can I check or repair it?\n\nThanks,\nEugene\n"},{"id":"125704","messageId":"237967ef0910220759r509775e1oc2e20af90800198c@mail.gmail.com","threadId":"21323","inReplyTo":"76c5b8580910220747w709d2b41s4f7b121e421e843c@mail.gmail.com","subject":"Re: git describe is failing","fromName":"Mikael Magnusson","fromEmail":"mikachu@gmail.com","sentAt":"2009-10-22T14:59:30Z","receivedAt":"2009-10-22T14:59:30Z","isPatch":false,"sender":{"key":"mikachu@gmail.com","avatar":null},"body":"2009/10/22 Eugene Sajine <euguess@gmail.com>:\n> Hi,\n>\n> I have a test repo which I'm playing with. It has about 15 commits and\n> one branch only (master) and couple of tags. Somehow it got to a state\n> when\n>\n> $ git describe\n>\n> gives:\n>\n> fatal: cannot describe 'SHA-1'\n>\n> The command is working ok with my other repo. It doesn't seem that the\n> test repo is corrupted. I can commit, push and pull, see the history\n> with gitk... How can I check or repair it?\n>\n> Thanks,\n> Eugene\n\nYour tags are probably not annotated (lightweight tags), use git\ndescribe --tags.\n\n-- \nMikael Magnusson\n"},{"id":"125705","messageId":"200910221702.39452.trast@student.ethz.ch","threadId":"21323","inReplyTo":"76c5b8580910220747w709d2b41s4f7b121e421e843c@mail.gmail.com","subject":"Re: git describe is failing","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-10-22T15:02:37Z","receivedAt":"2009-10-22T15:02:37Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Eugene Sajine wrote:\n> $ git describe\n> \n> gives:\n> \n> fatal: cannot describe 'SHA-1'\n\nman git-describe:\n\nDESCRIPTION\n       The command finds the most recent tag that is reachable from a\n       commit.\n[...]\n       By default (without --all or --tags) git describe only shows\n       annotated tags. For more information about creating annotated\n       tags see the -a and -s options to git-tag(1).\n\nIf there is no such tag, it refuses to work.  Annotate your tags, or\ntry --always.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"125706","messageId":"76c5b8580910220810n389d065di349339ab38909ef7@mail.gmail.com","threadId":"21323","inReplyTo":"200910221702.39452.trast@student.ethz.ch","subject":"Re: git describe is failing","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2009-10-22T15:10:06Z","receivedAt":"2009-10-22T15:10:06Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"> man git-describe:\n>\n> DESCRIPTION\n>       The command finds the most recent tag that is reachable from a\n>       commit.\n> [...]\n>       By default (without --all or --tags) git describe only shows\n>       annotated tags. For more information about creating annotated\n>       tags see the -a and -s options to git-tag(1).\n>\n> If there is no such tag, it refuses to work.  Annotate your tags, or\n> try --always.\n>\n> --\n> Thomas Rast\n> trast@{inf,student}.ethz.ch\n>\n\nThanks! It is working ok.\nAlthough it is probably not the best error handling.\nI believe git should fail with some meaningful message in this case...\n\nThanks,\nEugene\n"},{"id":"125709","messageId":"f1e86b9095d63c6541d0a8df6a1cf8eadfe247bb.1256226187.git.trast@student.ethz.ch","threadId":"21323","inReplyTo":"76c5b8580910220810n389d065di349339ab38909ef7@mail.gmail.com","subject":"[PATCH] describe: when failing, tell the user about options that work","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-10-22T15:44:39Z","receivedAt":"2009-10-22T15:44:39Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Users seem to call git-describe without reading the manpage, and then\nwonder why it doesn't work with unannotated tags by default.\n\nMake a minimal effort towards seeing if there would have been\nunannotated tags, and tell the user.  Specifically, we say that --tags\ncould work if we found any unannotated tags.  If not, we say that\n--always would have given results.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n\nEugene Sajine wrote:\n> [git-describe fails if you don't have annotated tags]\n>  \n> Thanks! It is working ok.\n> Although it is probably not the best error handling.\n> I believe git should fail with some meaningful message in this case...\n\nWe already had most of the information available, so hey, why not.\n\n\n builtin-describe.c |   16 ++++++++++++----\n 1 files changed, 12 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin-describe.c b/builtin-describe.c\nindex 2dcfd3d..1ffa0d8 100644\n--- a/builtin-describe.c\n+++ b/builtin-describe.c\n@@ -96,8 +96,6 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void \n \tif (!all) {\n \t\tif (!prio)\n \t\t\treturn 0;\n-\t\tif (!tags && prio < 2)\n-\t\t\treturn 0;\n \t}\n \tadd_to_known_names(all ? path + 5 : path + 10, commit, prio, sha1);\n \treturn 0;\n@@ -184,6 +182,7 @@ static void describe(const char *arg, int last_one)\n \tstruct possible_tag all_matches[MAX_TAGS];\n \tunsigned int match_cnt = 0, annotated_cnt = 0, cur_match;\n \tunsigned long seen_commits = 0;\n+\tunsigned int unannotated_cnt = 0;\n \n \tif (get_sha1(arg, sha1))\n \t\tdie(\"Not a valid object name %s\", arg);\n@@ -217,7 +216,9 @@ static void describe(const char *arg, int last_one)\n \t\tseen_commits++;\n \t\tn = c->util;\n \t\tif (n) {\n-\t\t\tif (match_cnt < max_candidates) {\n+\t\t\tif (!tags && !all && n->prio < 2) {\n+\t\t\t\tunannotated_cnt++;\n+\t\t\t} else if (match_cnt < max_candidates) {\n \t\t\t\tstruct possible_tag *t = &all_matches[match_cnt++];\n \t\t\t\tt->name = n;\n \t\t\t\tt->depth = seen_commits - 1;\n@@ -259,7 +260,14 @@ static void describe(const char *arg, int last_one)\n \t\t\tprintf(\"%s\\n\", find_unique_abbrev(sha1, abbrev));\n \t\t\treturn;\n \t\t}\n-\t\tdie(\"cannot describe '%s'\", sha1_to_hex(sha1));\n+\t\tif (unannotated_cnt)\n+\t\t\tdie(\"cannot describe '%s'\"\n+\t\t\t    \" with only\\nannotated tags. Try --tags.\",\n+\t\t\t    sha1_to_hex(sha1));\n+\t\telse\n+\t\t\tdie(\"cannot describe '%s'\"\n+\t\t\t    \" with tags\\nTry --always, or create some tags.\",\n+\t\t\t    sha1_to_hex(sha1));\n \t}\n \n \tqsort(all_matches, match_cnt, sizeof(all_matches[0]), compare_pt);\n-- \n1.6.5.1.70.g1383ae\n"},{"id":"125712","messageId":"81b0412b0910220940n78ddb774i30338147327b198a@mail.gmail.com","threadId":"21323","inReplyTo":"f1e86b9095d63c6541d0a8df6a1cf8eadfe247bb.1256226187.git.trast@student.ethz.ch","subject":"Re: [PATCH] describe: when failing, tell the user about options that work","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-10-22T16:40:33Z","receivedAt":"2009-10-22T16:40:33Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Thu, Oct 22, 2009 at 17:44, Thomas Rast <trast@student.ethz.ch> wrote:\n> @@ -259,7 +260,14 @@ static void describe(const char *arg, int last_one)\n>                        printf(\"%s\\n\", find_unique_abbrev(sha1, abbrev));\n>                        return;\n>                }\n> -               die(\"cannot describe '%s'\", sha1_to_hex(sha1));\n> +               if (unannotated_cnt)\n> +                       die(\"cannot describe '%s'\"\n> +                           \" with only\\nannotated tags. Try --tags.\",\n> +                           sha1_to_hex(sha1));\n> +               else\n> +                       die(\"cannot describe '%s'\"\n> +                           \" with tags\\nTry --always, or create some tags.\",\n> +                           sha1_to_hex(sha1));\n\nThese are quite verbose. Could they be conditional on something like\nadvice.describeHints?\n"},{"id":"125753","messageId":"7v63a7f4ka.fsf@alter.siamese.dyndns.org","threadId":"21323","inReplyTo":"81b0412b0910220940n78ddb774i30338147327b198a@mail.gmail.com","subject":"Re: [PATCH] describe: when failing, tell the user about options that work","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-22T22:26:45Z","receivedAt":"2009-10-22T22:26:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> writes:\n\n> These are quite verbose. Could they be conditional on something like\n> advice.describeHints?\n\nConcurred.  Please make it so.\n"},{"id":"125758","messageId":"alpine.LFD.2.00.0910222011200.21460@xanadu.home","threadId":"21323","inReplyTo":"7v63a7f4ka.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] describe: when failing, tell the user about options that work","fromName":"Nicolas Pitre","fromEmail":"nico@fluxnic.net","sentAt":"2009-10-23T00:13:14Z","receivedAt":"2009-10-23T00:13:14Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Thu, 22 Oct 2009, Junio C Hamano wrote:\n\n> Alex Riesen <raa.lkml@gmail.com> writes:\n> \n> > These are quite verbose. Could they be conditional on something like\n> > advice.describeHints?\n> \n> Concurred.  Please make it so.\n\nI don't have a strong opinion either ways, but is having a less verbose \nmessage in the _error_ path really a big issue?\n\n\nNicolas\n"},{"id":"125759","messageId":"7vljj3dkid.fsf@alter.siamese.dyndns.org","threadId":"21323","inReplyTo":"f1e86b9095d63c6541d0a8df6a1cf8eadfe247bb.1256226187.git.trast@student.ethz.ch","subject":"Re: [PATCH] describe: when failing, tell the user about options that work","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-23T00:25:14Z","receivedAt":"2009-10-23T00:25:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Rast <trast@student.ethz.ch> writes:\n\n> @@ -259,7 +260,14 @@ static void describe(const char *arg, int last_one)\n>  \t\t\tprintf(\"%s\\n\", find_unique_abbrev(sha1, abbrev));\n>  \t\t\treturn;\n>  \t\t}\n> -\t\tdie(\"cannot describe '%s'\", sha1_to_hex(sha1));\n> +\t\tif (unannotated_cnt)\n> +\t\t\tdie(\"cannot describe '%s'\"\n> +\t\t\t    \" with only\\nannotated tags. Try --tags.\",\n\nDid you mean UNannotated tags here?\n\n> +\t\t\t    sha1_to_hex(sha1));\n> +\t\telse\n> +\t\t\tdie(\"cannot describe '%s'\"\n> +\t\t\t    \" with tags\\nTry --always, or create some tags.\",\n> +\t\t\t    sha1_to_hex(sha1));\n>  \t}\n>  \n>  \tqsort(all_matches, match_cnt, sizeof(all_matches[0]), compare_pt);\n"},{"id":"125760","messageId":"7vhbtrdkc4.fsf@alter.siamese.dyndns.org","threadId":"21323","inReplyTo":"alpine.LFD.2.00.0910222011200.21460@xanadu.home","subject":"Re: [PATCH] describe: when failing, tell the user about options that work","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-23T00:28:59Z","receivedAt":"2009-10-23T00:28:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nicolas Pitre <nico@fluxnic.net> writes:\n\n> On Thu, 22 Oct 2009, Junio C Hamano wrote:\n>\n>> Alex Riesen <raa.lkml@gmail.com> writes:\n>> \n>> > These are quite verbose. Could they be conditional on something like\n>> > advice.describeHints?\n>> \n>> Concurred.  Please make it so.\n>\n> I don't have a strong opinion either ways, but is having a less verbose \n> message in the _error_ path really a big issue?\n\nThanks for catching a thinko---I somehow thought the patch was about\nwarning when we give an annotated tag that is farther than an unannotated\none.\n\nIt should be good enough to unconditionally give hints upon an error, as\nlong as they are correct.\n"},{"id":"125777","messageId":"200910231034.09747.trast@student.ethz.ch","threadId":"21323","inReplyTo":"7vljj3dkid.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] describe: when failing, tell the user about options that work","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-10-23T08:34:07Z","receivedAt":"2009-10-23T08:34:07Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Junio C Hamano wrote:\n> Thomas Rast <trast@student.ethz.ch> writes:\n> \n> > @@ -259,7 +260,14 @@ static void describe(const char *arg, int last_one)\n> >  \t\t\tprintf(\"%s\\n\", find_unique_abbrev(sha1, abbrev));\n> >  \t\t\treturn;\n> >  \t\t}\n> > -\t\tdie(\"cannot describe '%s'\", sha1_to_hex(sha1));\n> > +\t\tif (unannotated_cnt)\n> > +\t\t\tdie(\"cannot describe '%s'\"\n> > +\t\t\t    \" with only\\nannotated tags. Try --tags.\",\n> \n> Did you mean UNannotated tags here?\n\nNo, but I think I see where the misunderstanding came from.\n\nThis code path means that we did not find a tag to describe with, but\nwe counted some unannotated tags (and because of how the counting\nlogic is wrapped, this only triggers when neither --all nor --tags are\nin effect).\n\nSo I wanted it to say \"it is impossible to describe this with the tags\nyou told me to use\", which in this case are the annotated ones.\n\nI tried to keep the general structure of the message (\"cannot describe\n...\"), and with this restriction I can't seem to find a clearer\nwording.  However, it could be written e.g.\n\n  No annotated tags can describe '%s'.  However, there were\n  unannotated tags: try --tags.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"125798","messageId":"7vmy3iaqfr.fsf@alter.siamese.dyndns.org","threadId":"21323","inReplyTo":"200910231034.09747.trast@student.ethz.ch","subject":"Re: [PATCH] describe: when failing, tell the user about options that work","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-23T18:57:44Z","receivedAt":"2009-10-23T18:57:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Rast <trast@student.ethz.ch> writes:\n\n> Junio C Hamano wrote:\n>> Thomas Rast <trast@student.ethz.ch> writes:\n>> \n>> > @@ -259,7 +260,14 @@ static void describe(const char *arg, int last_one)\n>> >  \t\t\tprintf(\"%s\\n\", find_unique_abbrev(sha1, abbrev));\n>> >  \t\t\treturn;\n>> >  \t\t}\n>> > -\t\tdie(\"cannot describe '%s'\", sha1_to_hex(sha1));\n>> > +\t\tif (unannotated_cnt)\n>> > +\t\t\tdie(\"cannot describe '%s'\"\n>> > +\t\t\t    \" with only\\nannotated tags. Try --tags.\",\n>> \n>> Did you mean UNannotated tags here?\n>\n> No, but I think I see where the misunderstanding came from.\n>\n> This code path means that we did not find a tag to describe with, but\n> we counted some unannotated tags (and because of how the counting\n> logic is wrapped, this only triggers when neither --all nor --tags are\n> in effect).\n\nI think I read the code right ;-).\n\n> So I wanted it to say \"it is impossible to describe this with the tags\n> you told me to use\", which in this case are the annotated ones.\n\nThe way I read it was \"it is impossible to describe it in the way you told\nme to, when the tags you have are only unannotated kind.\"\n\n> However, it could be written e.g.\n>\n>   No annotated tags can describe '%s'.  However, there were\n>   unannotated tags: try --tags.\n\nSounds better.\n"},{"id":"126181","messageId":"956c69810977ac67ca2379a602fd7ffca3e0cae7.1256767275.git.trast@student.ethz.ch","threadId":"21323","inReplyTo":"7vmy3iaqfr.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2] describe: when failing, tell the user about options that work","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-10-28T22:10:06Z","receivedAt":"2009-10-28T22:10:06Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Users seem to call git-describe without reading the manpage, and then\nwonder why it doesn't work with unannotated tags by default.\n\nMake a minimal effort towards seeing if there would have been\nunannotated tags, and tell the user.  Specifically, we say that --tags\ncould work if we found any unannotated tags.  If not, we say that\n--always would have given results.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n\nJunio C Hamano wrote:\n> Thomas Rast <trast@student.ethz.ch> writes:\n> > However, it could be written e.g.\n> >\n> >   No annotated tags can describe '%s'.  However, there were\n> >   unannotated tags: try --tags.\n> \n> Sounds better.\n\nThen let's make it so.  Sorry for taking so long.\n\n\n builtin-describe.c |   16 ++++++++++++----\n 1 files changed, 12 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin-describe.c b/builtin-describe.c\nindex 2dcfd3d..4ea6f88 100644\n--- a/builtin-describe.c\n+++ b/builtin-describe.c\n@@ -96,8 +96,6 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void \n \tif (!all) {\n \t\tif (!prio)\n \t\t\treturn 0;\n-\t\tif (!tags && prio < 2)\n-\t\t\treturn 0;\n \t}\n \tadd_to_known_names(all ? path + 5 : path + 10, commit, prio, sha1);\n \treturn 0;\n@@ -184,6 +182,7 @@ static void describe(const char *arg, int last_one)\n \tstruct possible_tag all_matches[MAX_TAGS];\n \tunsigned int match_cnt = 0, annotated_cnt = 0, cur_match;\n \tunsigned long seen_commits = 0;\n+\tunsigned int unannotated_cnt = 0;\n \n \tif (get_sha1(arg, sha1))\n \t\tdie(\"Not a valid object name %s\", arg);\n@@ -217,7 +216,9 @@ static void describe(const char *arg, int last_one)\n \t\tseen_commits++;\n \t\tn = c->util;\n \t\tif (n) {\n-\t\t\tif (match_cnt < max_candidates) {\n+\t\t\tif (!tags && !all && n->prio < 2) {\n+\t\t\t\tunannotated_cnt++;\n+\t\t\t} else if (match_cnt < max_candidates) {\n \t\t\t\tstruct possible_tag *t = &all_matches[match_cnt++];\n \t\t\t\tt->name = n;\n \t\t\t\tt->depth = seen_commits - 1;\n@@ -259,7 +260,14 @@ static void describe(const char *arg, int last_one)\n \t\t\tprintf(\"%s\\n\", find_unique_abbrev(sha1, abbrev));\n \t\t\treturn;\n \t\t}\n-\t\tdie(\"cannot describe '%s'\", sha1_to_hex(sha1));\n+\t\tif (unannotated_cnt)\n+\t\t\tdie(\"No annotated tags can describe '%s'.\\n\"\n+\t\t\t    \"However, there were unannotated tags: try --tags.\",\n+\t\t\t    sha1_to_hex(sha1));\n+\t\telse\n+\t\t\tdie(\"No tags can describe '%s'.\\n\"\n+\t\t\t    \"Try --always, or create some tags.\",\n+\t\t\t    sha1_to_hex(sha1));\n \t}\n \n \tqsort(all_matches, match_cnt, sizeof(all_matches[0]), compare_pt);\n-- \n1.6.5.1.161.g3b9c0\n"}]}