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>
Junio C Hamano committed
Jan 11, 2006 at 14:20 UTC
2c817df25d54b557d6cac0800cacfd0a255cd56d
2 files changed
+7
-6
name-rev.c
+4
-3
@@ -93,10 +93,11 @@ static int name_ref(const char *path, const unsigned char *sha1)
93
}
94
if (o && o->type == commit_type) {
95
struct commit *commit = (struct commit *)o;
96
- const char *p;
96
98
- while ((p = strchr(path, '/')))
99
- path = p+1;
97
+ if (!strncmp(path, "refs/heads/", 11))
98
+ path = path + 11;
99
+ else if (!strncmp(path, "refs/", 5))
100
+ path = path + 5;
101
102
name_rev(commit, strdup(path), 0, 0, deref);
103
}
t/t6010-merge-base.sh
+3
-3
@@ -46,14 +46,14 @@ H=$(doit 8 H $A $F)
46
47
test_expect_success 'compute merge-base (single)' \
48
'MB=$(git-merge-base G H) &&
49
- expr "$(git-name-rev "$MB")" : "[0-9a-f]* B"'
49
+ expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
50
51
test_expect_success 'compute merge-base (all)' \
52
'MB=$(git-merge-base --all G H) &&
53
- expr "$(git-name-rev "$MB")" : "[0-9a-f]* B"'
53
+ expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
54
55
test_expect_success 'compute merge-base with show-branch' \
56
'MB=$(git-show-branch --merge-base G H) &&
57
- expr "$(git-name-rev "$MB")" : "[0-9a-f]* B"'
57
+ expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"'
58
59
test_done