aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-01-11 14:20:09 -0800
committerJunio C Hamano <junkio@cox.net>2006-01-11 14:47:20 -0800
commit2c817df25d54b557d6cac0800cacfd0a255cd56d (patch)
tree0217463c24b8d982aea3d83a165c1875e988c495
parenta94d9948da539fdafc26c74afb335b2fe9f8f21d (diff)
downloadgit-2c817df25d54b557d6cac0800cacfd0a255cd56d.tar.gz
git-2c817df25d54b557d6cac0800cacfd0a255cd56d.tar.xz
name-rev: do not omit leading components of ref name.
In a repository with mainto/1.0 (to keep maintaining the 1.0.X series) and fixo/1.0 (to keep fixes that apply to both 1.0.X series and upwards) branches, "git-name-rev mainto/1.0" answered just "1.0" making things ambiguous. Show refnames unambiguously like show-branch does. Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--name-rev.c7
-rwxr-xr-xt/t6010-merge-base.sh6
2 files changed, 7 insertions, 6 deletions
diff --git a/name-rev.c b/name-rev.c
index 65333d416..bbadb91aa 100644
--- a/name-rev.c
+++ b/name-rev.c
@@ -93,10 +93,11 @@ static int name_ref(const char *path, const unsigned char *sha1)
}
if (o && o->type == commit_type) {
struct commit *commit = (struct commit *)o;
- const char *p;
- while ((p = strchr(path, '/')))
- path = p+1;
+ if (!strncmp(path, "refs/heads/", 11))
+ path = path + 11;
+ else if (!strncmp(path, "refs/", 5))
+ path = path + 5;
name_rev(commit, strdup(path), 0, 0, deref);
}
diff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh
index c3a9680e2..1dce123ae 100755
--- a/t/t6010-merge-base.sh
+++ b/t/t6010-merge-base.sh
@@ -46,14 +46,14 @@ H=$(doit 8 H $A $F)
test_expect_success 'compute merge-base (single)' \
'MB=$(git-merge-base G H) &&
- expr "$(git-name-rev "$MB")" : "[0-9a-f]* B"'
+ expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
test_expect_success 'compute merge-base (all)' \
'MB=$(git-merge-base --all G H) &&
- expr "$(git-name-rev "$MB")" : "[0-9a-f]* B"'
+ expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
test_expect_success 'compute merge-base with show-branch' \
'MB=$(git-show-branch --merge-base G H) &&
- expr "$(git-name-rev "$MB")" : "[0-9a-f]* B"'
+ expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
test_done