{"thread":{"id":"34370","subject":"[PATCH 0/3] Iron output of describe --contains --all","startedAt":"2013-07-07T12:43:13Z","lastAt":"2013-07-08T13:18:33Z","messageCount":10,"participants":["Ramkumar Ramachandra","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"222739","messageId":"1373200996-9753-1-git-send-email-artagnon@gmail.com","threadId":"34370","inReplyTo":null,"subject":"[PATCH 0/3] Iron output of describe --contains --all","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-07T12:43:13Z","receivedAt":"2013-07-07T12:43:13Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\nI actually sent these patches to the list last month, but nobody\nseemed to be interested.  This is an unedited resend.\n\nI looked into adding tests, but decided that it was a lost cause: the\noutput is too loosely defined for any scripts to rely on it strongly.\n[1/3] already shows a race between branches and tags.  For another\nexample, consider two tags are pointing to same commit (D and R in\nt6120-describe.sh).  Run the following on the two tags and see what\nhappens for yourself:\n\n  $ git describe --contains\n  $ git describe --all\n  $ git describe --tags\n\nNow think about various combinations of these options.  I'm not saying\nthat it's a Bad Thing (TM), but that nobody has bothered tightening\nthe output.\n\nMy main motivation for doing this series is my prompt: I don't want to\nsee\n\n  artagnon|(tags/v1.8.3^0)~/src/git$\n\nwhen\n\n  artagnon|(v1.8.3)~/src/git$\n\nis so much more pleasant and consistent.  Obviously, hacking around\nthis problem in the prompt script is the Wrong thing to do.\n\nThanks.\n\nRamkumar Ramachandra (3):\n  name-rev: fix assumption about --name-only usage\n  name-rev: strip trailing ^0 in when --name-only\n  name-rev doc: rewrite --stdin paragraph\n\n Documentation/git-name-rev.txt       | 12 +++++++-----\n builtin/name-rev.c                   | 12 +++++++++++-\n t/t4202-log.sh                       |  8 ++++----\n t/t6007-rev-list-cherry-pick-file.sh | 32 ++++++++++++++++----------------\n 4 files changed, 38 insertions(+), 26 deletions(-)\n\n-- \n1.8.3.2.737.gcbc076a.dirty\n"},{"id":"222740","messageId":"1373200996-9753-2-git-send-email-artagnon@gmail.com","threadId":"34370","inReplyTo":"1373200996-9753-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 1/3] name-rev: fix assumption about --name-only usage","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-07T12:43:14Z","receivedAt":"2013-07-07T12:43:14Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"236157 (Teach git-describe how to run name-rev, 2007-05-21) introduced\n`git name-rev --name-only`, with the intent of using it to implement\n`git describe --contains`.  According to the message, users wanted to\nuse describe to figure out which tags contains a specific commit.\nname-rev already did this, but didn't print out in the same format as\ndescribe:\n\n  $ git describe v1.8.3~1\n  v1.8.3-rc3-8-g5e49f30\n\n  $ git name-rev v1.8.3~1\n  v1.8.3~1 tags/v1.8.3~1\n\nThere are two problems with using the output of name-rev in describe:\nfirst, it prints out the given argument before describing it.  Second,\nit prefixes \"tags/\" to the tag description.  To eliminate these two\nproblems, 236157 proposed that the --name-rev option would strip these\nthings when used with --tags, to match the describe output more closely:\n\n  $ git name-rev --name-only --tags v1.8.3~1\n  v1.8.3~1\n\n236157 did not anticipate a problem with always combining --name-rev\nwith --tags, because it was primarily intended to be used from describe,\nwhere it hard-coded these two arguments in the execv() of name-rev.\n\nLater, 3f7701 (make 'git describe --all --contains' work, 2007-12-19)\nnoticed that describe didn't work with --contains and --all.  This is\nbecause --contains implied a call to --name-rev (in with --tags was\nhard-coded), but --all implied that any ref should be used to describe\nthe given argument (not just tags).  3f7701 took the band-aid approach,\nand made --all disable --tags when calling name-rev.  As a result, while\n\n  $ git describe --contains v1.8.3~1\n  v1.8.3~1\n\nwould get name-rev to print output in the same format as describe,\n\n  $ git describe --contains --all v1.8.3~1\n  tags/v1.8.3~1\n\nwould not strip the leading \"tags/\".\n\nThe bug exists in git to this day.  Fix it by removing the assumption\nthat name-rev --name-only is only intended to be used with --tags.  Also\nupdate some tests.\n\nUsers and scripts have learnt to live with 3f7701, and it will continue\nto be a small quirk.  Even after this patch, notice\n\n  $ git checkout -b foom v1.8.3\n  $ git describe --contains @~1\n  v1.8.3~1\n  $ git describe --contains --all @~1\n  foom~1\n\nIn other words, --contains implies --tags in name-rev, which gives\nprecedence to tags; --all cancels that effect thereby giving precedence\nto branches in the case of a tie.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n Documentation/git-name-rev.txt       |  6 +++---\n builtin/name-rev.c                   |  3 +++\n t/t4202-log.sh                       |  8 ++++----\n t/t6007-rev-list-cherry-pick-file.sh | 32 ++++++++++++++++----------------\n 4 files changed, 26 insertions(+), 23 deletions(-)\n\ndiff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt\nindex 6b0f1ba..7cde4b3 100644\n--- a/Documentation/git-name-rev.txt\n+++ b/Documentation/git-name-rev.txt\n@@ -37,9 +37,9 @@ OPTIONS\n \n --name-only::\n \tInstead of printing both the SHA-1 and the name, print only\n-\tthe name.  If given with --tags the usual tag prefix of\n-\t\"tags/\" is also omitted from the name, matching the output\n-\tof `git-describe` more closely.\n+\tthe name.  The usual tag prefix of \"tags/\" is also omitted\n+\tfrom the name, matching the output of `git-describe` more\n+\tclosely.\n \n --no-undefined::\n \tDie with error code != 0 when a reference is undefined,\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 87d4854..37207a9 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -138,6 +138,9 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void\n \t\t\tpath = shorten_unambiguous_ref(path, 0);\n \t\telse if (!prefixcmp(path, \"refs/heads/\"))\n \t\t\tpath = path + 11;\n+\t\telse if (data->name_only\n+\t\t    && !prefixcmp(path, \"refs/tags/\"))\n+\t\t\tpath = path + 10;\n \t\telse if (!prefixcmp(path, \"refs/\"))\n \t\t\tpath = path + 5;\n \ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex cb03d28..9bec360 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -302,7 +302,7 @@ cat > expect <<\\EOF\n | |\n | |     side-2\n | |\n-| * commit tags/side-1\n+| * commit side-1\n | | Author: A U Thor <author@example.com>\n | |\n | |     side-1\n@@ -327,17 +327,17 @@ cat > expect <<\\EOF\n |\n |       fourth\n |\n-* commit tags/side-1~1\n+* commit side-1~1\n | Author: A U Thor <author@example.com>\n |\n |     third\n |\n-* commit tags/side-1~2\n+* commit side-1~2\n | Author: A U Thor <author@example.com>\n |\n |     second\n |\n-* commit tags/side-1~3\n+* commit side-1~3\n   Author: A U Thor <author@example.com>\n \n       initial\ndiff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh\nindex 28d4f6b..5a8175e 100755\n--- a/t/t6007-rev-list-cherry-pick-file.sh\n+++ b/t/t6007-rev-list-cherry-pick-file.sh\n@@ -49,8 +49,8 @@ test_expect_success setup '\n '\n \n cat >expect <<EOF\n-<tags/B\n->tags/C\n+<B\n+>C\n EOF\n \n test_expect_success '--left-right' '\n@@ -70,7 +70,7 @@ test_expect_success '--cherry-pick foo comes up empty' '\n '\n \n cat >expect <<EOF\n->tags/C\n+>C\n EOF\n \n test_expect_success '--cherry-pick bar does not come up empty' '\n@@ -88,8 +88,8 @@ test_expect_success 'bar does not come up empty' '\n '\n \n cat >expect <<EOF\n-<tags/F\n->tags/E\n+<F\n+>E\n EOF\n \n test_expect_success '--cherry-pick bar does not come up empty (II)' '\n@@ -100,10 +100,10 @@ test_expect_success '--cherry-pick bar does not come up empty (II)' '\n '\n \n cat >expect <<EOF\n-+tags/F\n-=tags/D\n-+tags/E\n-=tags/C\n++F\n+=D\n++E\n+=C\n EOF\n \n test_expect_success '--cherry-mark' '\n@@ -114,10 +114,10 @@ test_expect_success '--cherry-mark' '\n '\n \n cat >expect <<EOF\n-<tags/F\n-=tags/D\n->tags/E\n-=tags/C\n+<F\n+=D\n+>E\n+=C\n EOF\n \n test_expect_success '--cherry-mark --left-right' '\n@@ -128,7 +128,7 @@ test_expect_success '--cherry-mark --left-right' '\n '\n \n cat >expect <<EOF\n-tags/E\n+E\n EOF\n \n test_expect_success '--cherry-pick --right-only' '\n@@ -146,8 +146,8 @@ test_expect_success '--cherry-pick --left-only' '\n '\n \n cat >expect <<EOF\n-+tags/E\n-=tags/C\n++E\n+=C\n EOF\n \n test_expect_success '--cherry' '\n-- \n1.8.3.2.737.gcbc076a.dirty\n"},{"id":"222742","messageId":"1373200996-9753-3-git-send-email-artagnon@gmail.com","threadId":"34370","inReplyTo":"1373200996-9753-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 2/3] name-rev: strip trailing ^0 in when --name-only","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-07T12:43:15Z","receivedAt":"2013-07-07T12:43:15Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"236157 (Teach git-describe how to run name-rev, 2007-05-21) introduced\n`git name-rev --name-only`, with the intent of using it to implement\n`git describe --contains`.  According to the message, one of the primary\nobjectives of --name-only was to make the output of name-rev match that\nof describe.\n\n  $ git describe --contains --all master\n  master\n\n  $ git describe --contains --all master~1\n  master~1\n\n  $ git describe --contains --all v1.8.3~1\n  v1.8.3~1\n\n  $ git describe --contains --all v1.8.3\n  v1.8.3^0\n\nThe last invocation unnecessarily prints a trailing \"^0\" (--stdin does\nnot suffer from this defect).  Fix this.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n builtin/name-rev.c | 9 ++++++++-\n 1 file changed, 8 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 37207a9..8ba5d72 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -186,7 +186,14 @@ static void show_name(const struct object *obj,\n \tif (!name_only)\n \t\tprintf(\"%s \", caller_name ? caller_name : sha1_to_hex(sha1));\n \tname = get_rev_name(obj);\n-\tif (name)\n+\n+\tif (name && name_only) {\n+\t\t/* strip possible trailing ^0 from name */\n+\t\tint len = strlen(name);\n+\t\tif (len > 2 && !strcmp(name + len - 2, \"^0\"))\n+\t\t\tlen -= 2;\n+\t\tprintf(\"%.*s\\n\", len, name);\n+\t} else if (name)\n \t\tprintf(\"%s\\n\", name);\n \telse if (allow_undefined)\n \t\tprintf(\"undefined\\n\");\n-- \n1.8.3.2.737.gcbc076a.dirty\n"},{"id":"222741","messageId":"1373200996-9753-4-git-send-email-artagnon@gmail.com","threadId":"34370","inReplyTo":"1373200996-9753-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 3/3] name-rev doc: rewrite --stdin paragraph","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-07T12:43:16Z","receivedAt":"2013-07-07T12:43:16Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n Documentation/git-name-rev.txt | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt\nindex 7cde4b3..94bded8 100644\n--- a/Documentation/git-name-rev.txt\n+++ b/Documentation/git-name-rev.txt\n@@ -32,8 +32,10 @@ OPTIONS\n \tList all commits reachable from all refs\n \n --stdin::\n-\tRead from stdin, append \"(<rev_name>)\" to all sha1's of nameable\n-\tcommits, and pass to stdout\n+\tTransform stdin by substituting all the 40-character SHA-1\n+\thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n+\t--name-only, substitute with \"$rev_name\", omitting $hex\n+\taltogether.  Intended for the scripter's use.\n \n --name-only::\n \tInstead of printing both the SHA-1 and the name, print only\n-- \n1.8.3.2.737.gcbc076a.dirty\n"},{"id":"222762","messageId":"7vhag64578.fsf@alter.siamese.dyndns.org","threadId":"34370","inReplyTo":"1373200996-9753-4-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH 3/3] name-rev doc: rewrite --stdin paragraph","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-07T18:04:27Z","receivedAt":"2013-07-07T18:04:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n> ---\n>  Documentation/git-name-rev.txt | 6 ++++--\n>  1 file changed, 4 insertions(+), 2 deletions(-)\n>\n> diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt\n> index 7cde4b3..94bded8 100644\n> --- a/Documentation/git-name-rev.txt\n> +++ b/Documentation/git-name-rev.txt\n> @@ -32,8 +32,10 @@ OPTIONS\n>  \tList all commits reachable from all refs\n>  \n>  --stdin::\n> -\tRead from stdin, append \"(<rev_name>)\" to all sha1's of nameable\n> -\tcommits, and pass to stdout\n> +\tTransform stdin by substituting all the 40-character SHA-1\n> +\thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n> +\t--name-only, substitute with \"$rev_name\", omitting $hex\n> +\taltogether.  Intended for the scripter's use.\n>  \n>  --name-only::\n>  \tInstead of printing both the SHA-1 and the name, print only\n\nLooks obviously correct and more helpful description.\n\nThanks.\n"},{"id":"222763","messageId":"7vd2qu44mm.fsf@alter.siamese.dyndns.org","threadId":"34370","inReplyTo":"1373200996-9753-3-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH 2/3] name-rev: strip trailing ^0 in when --name-only","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-07T18:16:49Z","receivedAt":"2013-07-07T18:16:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n> 236157 (Teach git-describe how to run name-rev, 2007-05-21) introduced\n> `git name-rev --name-only`, with the intent of using it to implement\n> `git describe --contains`.  According to the message, one of the primary\n> objectives of --name-only was to make the output of name-rev match that\n> of describe.\n>\n>   $ git describe --contains --all master\n>   master\n>\n>   $ git describe --contains --all master~1\n>   master~1\n>\n>   $ git describe --contains --all v1.8.3~1\n>   v1.8.3~1\n>\n>   $ git describe --contains --all v1.8.3\n>   v1.8.3^0\n\nWRT \"describe --contains\", I do agree that both of these\n\n    $ git describe $(git rev-parse v1.8.3^0)\n    $ git describe --contains $(git rev-parse v1.8.3^0)\n        \nshould just say \"v1.8.3\" without ~0/^0/~0~0~0 etc. and the last\nexample you showed will be improved by dropping ^0 at the end.\n\nHowever.\n\nI was a bit bothered by the description talking _only_ about\ndescribe, but the actual change is to modify what name-rev gives its\ndirect users as well.  And that made me realize that the patch\nitself has an undesirable side effect.\n\n\"describe\" is _only_ about commit history graph, so in its context\nv1.8.3 means the same thing as v1.8.3^0 (we never want to get a tag;\nwe always want a commit).  But I do not think \"name-rev\" is limited\nto commits, in the sense that you would see this:\n\n    $ git rev-parse v1.8.3 v1.8.3^0 | git name-rev --stdin\n    8af06057d0c31a24e8737ae846ac2e116e8bafb9\n    edca4152560522a431a51fc0a06147fc680b5b18 (tags/v1.8.3^0)\n\nThe second object is _not_ v1.8.3 but is v1.8.3^0 in the context of\nname-rev, whose purpose is to give you a string you can feed\n\"rev-parse\" and get the object name back.  \"rev-parse v1.8.3\" will\nnot give you the commit object name, so you need to keep \"^0\".\n"},{"id":"222764","messageId":"7v61wm44k0.fsf@alter.siamese.dyndns.org","threadId":"34370","inReplyTo":"1373200996-9753-2-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH 1/3] name-rev: fix assumption about --name-only usage","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-07T18:18:23Z","receivedAt":"2013-07-07T18:18:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n> 236157 (Teach git-describe how to run name-rev, 2007-05-21) introduced\n> `git name-rev --name-only`, with the intent of using it to implement\n> `git describe --contains`.  According to the message, users wanted to\n> use describe to figure out which tags contains a specific commit.\n> name-rev already did this, but didn't print out in the same format as\n> describe:\n>\n>   $ git describe v1.8.3~1\n>   v1.8.3-rc3-8-g5e49f30\n>\n> ...  As a result, while\n>\n>   $ git describe --contains v1.8.3~1\n>   v1.8.3~1\n\nThe above two look consistent, yes.\n\n>\n> would get name-rev to print output in the same format as describe,\n>\n>   $ git describe --contains --all v1.8.3~1\n>   tags/v1.8.3~1\n>\n> would not strip the leading \"tags/\".\n\nIf you _know_ v1.8.3 does not appear outside \"tags/\", this does look\ninconsistent, but I do not think the code checks it.  Ahd if the\ncode does not, I am not sure not stripping \"tags/\" is necessarily a\nbad thing, because \"--all\" allows names to come outside \"tags/\"\nhierarchy.\n\nAlso how should this interact with v1.8.3-1-g98c5c4a that changed\nthe rule somewhat so that the common prefix is stripped when we know\nthe result is not ambiguous?\n"},{"id":"222778","messageId":"7vtxk62fkg.fsf@alter.siamese.dyndns.org","threadId":"34370","inReplyTo":"7vd2qu44mm.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/3] name-rev: strip trailing ^0 in when --name-only","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-07T22:03:27Z","receivedAt":"2013-07-07T22:03:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> WRT \"describe --contains\", I do agree that both of these\n>\n>     $ git describe $(git rev-parse v1.8.3^0)\n>     $ git describe --contains $(git rev-parse v1.8.3^0)\n>         \n> should just say \"v1.8.3\" without ~0/^0/~0~0~0 etc. and the last\n> example you showed will be improved by dropping ^0 at the end.\n>\n> However.\n>\n> I was a bit bothered by the description talking _only_ about\n> describe, but the actual change is to modify what name-rev gives its\n> direct users as well.  And that made me realize that the patch\n> itself has an undesirable side effect.\n>\n> \"describe\" is _only_ about commit history graph, so in its context\n> v1.8.3 means the same thing as v1.8.3^0 (we never want to get a tag;\n> we always want a commit).  But I do not think \"name-rev\" is limited\n> to commits, in the sense that you would see this:\n>\n>     $ git rev-parse v1.8.3 v1.8.3^0 | git name-rev --stdin\n>     8af06057d0c31a24e8737ae846ac2e116e8bafb9\n>     edca4152560522a431a51fc0a06147fc680b5b18 (tags/v1.8.3^0)\n>\n> The second object is _not_ v1.8.3 but is v1.8.3^0 in the context of\n> name-rev, whose purpose is to give you a string you can feed\n> \"rev-parse\" and get the object name back.  \"rev-parse v1.8.3\" will\n> not give you the commit object name, so you need to keep \"^0\".\n\nWell, the code in \"name-rev\" other than --stdin mode is already\nbroken (and the documentation half-describes this breakage) in that\nit describes the peeled commit and rejects anything other than\ncommit objects.  The reason I say \"half-describes\" is that it only\nsays that the command takes \"commit-ish\" and leaves it unclear if it\ncomes up with a name for the tag itself that happens to be\ncommit-ish, or it does so for the commit that is referred by the\ntag.\n\nI'll send out a WIP to fix that, and also help the topic to strip\nunnecessary \"^0\" suffix when name-rev is run as an implementation\ndetail of \"describe\" shortly.\n"},{"id":"222815","messageId":"CALkWK0mrOfx-EfS3YfS7mMBKqjFrwcyiVmQO=wMLN-BH1avqBg@mail.gmail.com","threadId":"34370","inReplyTo":"7vd2qu44mm.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/3] name-rev: strip trailing ^0 in when --name-only","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-08T13:00:07Z","receivedAt":"2013-07-08T13:00:07Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Junio C Hamano wrote:\n> But I do not think \"name-rev\" is limited\n> to commits, in the sense that you would see this:\n>\n>     $ git rev-parse v1.8.3 v1.8.3^0 | git name-rev --stdin\n>     8af06057d0c31a24e8737ae846ac2e116e8bafb9\n>     edca4152560522a431a51fc0a06147fc680b5b18 (tags/v1.8.3^0)\n>\n> The second object is _not_ v1.8.3 but is v1.8.3^0 in the context of\n> name-rev, whose purpose is to give you a string you can feed\n> \"rev-parse\" and get the object name back.  \"rev-parse v1.8.3\" will\n> not give you the commit object name, so you need to keep \"^0\".\n\nQuite frankly, I thought the unstripped ^0 in one codepath was an\nunintended quirk.  What exactly do you want name-rev to give you?\n\n  $ git tag foo @^\n  $ git name-rev foo\n  foo tags/foo\n\nSo you can distinguish between annotated tags, unannotated tags, and\nhead-refs.  Can you get it to tell you anything reliably though?\n\n  $ git tag bar @\n  $ git tag -a baz @\n  $ git name-rev @\n  $ git name-rev bar\n  $ git name-rev baz\n\nref, annotated, or unannotated tag?  I do not think name-rev is\nfundamentally different from describe: it is also only dependent on\nthe commit history graph.  Whether I specify a revision using @, HEAD,\nbaz, or bar, I should get the same answer (it's just a recursive\npeeler).  I'm not sure what you gain by knowing the object type of the\noutput.  If you wanted to feed something into rev-parse and get out a\ncommit, you'd send in $REV^0 without bothering about what it is, no?\n"},{"id":"222820","messageId":"CALkWK0=j_ZwiiQ+-PFxptH7mLvkRDyHXhyiTuoCT5gNXrJUFgg@mail.gmail.com","threadId":"34370","inReplyTo":"7v61wm44k0.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 1/3] name-rev: fix assumption about --name-only usage","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-08T13:18:33Z","receivedAt":"2013-07-08T13:18:33Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Junio C Hamano wrote:\n>> would get name-rev to print output in the same format as describe,\n>>\n>>   $ git describe --contains --all v1.8.3~1\n>>   tags/v1.8.3~1\n>>\n>> would not strip the leading \"tags/\".\n>\n> If you _know_ v1.8.3 does not appear outside \"tags/\", this does look\n> inconsistent, but I do not think the code checks it.  Ahd if the\n> code does not, I am not sure not stripping \"tags/\" is necessarily a\n> bad thing, because \"--all\" allows names to come outside \"tags/\"\n> hierarchy.\n\nYeah, you asked for it using --all.\n\n> Also how should this interact with v1.8.3-1-g98c5c4a that changed\n> the rule somewhat so that the common prefix is stripped when we know\n> the result is not ambiguous?\n\nCompletely independent of everything else.  The condition is \"if\nname-only && prefix == refs/tags\", strip that prefix.\n"}]}