Skip to content

Commit

Permalink
name-rev: do not omit leading components of ref name.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Jan 11, 2006
1 parent a94d994 commit 2c817df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions name-rev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions t/t6010-merge-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2c817df

Please sign in to comment.