{"thread":{"id":"3049","subject":"[PATCH - maint review] name-rev: do not omit leading components of ref name.","startedAt":"2006-01-12T00:04:59Z","lastAt":"2006-01-12T00:04:59Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"14516","messageId":"7vzmm2jopg.fsf@assigned-by-dhcp.cox.net","threadId":"3049","inReplyTo":null,"subject":"[PATCH - maint review] name-rev: do not omit leading components of ref name.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-12T00:04:59Z","receivedAt":"2006-01-12T00:04:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"In a repository with mainto/1.0 (to keep maintaining the 1.0.X\nseries) and fixo/1.0 (to keep fixes that apply to both 1.0.X\nseries and upwards) branches, \"git-name-rev mainto/1.0\" answered\njust \"1.0\" making things ambiguous.  Show refnames unambiguously\nlike show-branch does.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n * For 1.0.10 and 1.1.2\n\n name-rev.c            |    7 ++++---\n t/t6010-merge-base.sh |    6 +++---\n 2 files changed, 7 insertions(+), 6 deletions(-)\n\n2c817df25d54b557d6cac0800cacfd0a255cd56d\ndiff --git a/name-rev.c b/name-rev.c\nindex 65333d4..bbadb91 100644\n--- a/name-rev.c\n+++ b/name-rev.c\n@@ -93,10 +93,11 @@ static int name_ref(const char *path, co\n \t}\n \tif (o && o->type == commit_type) {\n \t\tstruct commit *commit = (struct commit *)o;\n-\t\tconst char *p;\n \n-\t\twhile ((p = strchr(path, '/')))\n-\t\t\tpath = p+1;\n+\t\tif (!strncmp(path, \"refs/heads/\", 11))\n+\t\t\tpath = path + 11;\n+\t\telse if (!strncmp(path, \"refs/\", 5))\n+\t\t\tpath = path + 5;\n \n \t\tname_rev(commit, strdup(path), 0, 0, deref);\n \t}\ndiff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh\nindex c3a9680..1dce123 100755\n--- a/t/t6010-merge-base.sh\n+++ b/t/t6010-merge-base.sh\n@@ -46,14 +46,14 @@ H=$(doit 8 H $A $F)\n \n test_expect_success 'compute merge-base (single)' \\\n     'MB=$(git-merge-base G H) &&\n-     expr \"$(git-name-rev \"$MB\")\" : \"[0-9a-f]* B\"'\n+     expr \"$(git-name-rev \"$MB\")\" : \"[0-9a-f]* tags/B\"'\n \n test_expect_success 'compute merge-base (all)' \\\n     'MB=$(git-merge-base --all G H) &&\n-     expr \"$(git-name-rev \"$MB\")\" : \"[0-9a-f]* B\"'\n+     expr \"$(git-name-rev \"$MB\")\" : \"[0-9a-f]* tags/B\"'\n \n test_expect_success 'compute merge-base with show-branch' \\\n     'MB=$(git-show-branch --merge-base G H) &&\n-     expr \"$(git-name-rev \"$MB\")\" : \"[0-9a-f]* B\"'\n+     expr \"$(git-name-rev \"$MB\")\" : \"[0-9a-f]* tags/B\"'\n \n test_done\n-- \n1.1.1-g8ecb\n"}]}