Browse Source

Merge branch 'mh/blame-worktree'

* mh/blame-worktree:
  blame: fix segfault on untracked files
maint
Junio C Hamano 9 years ago
parent
commit
4762bf36d9
  1. 3
      builtin/blame.c
  2. 5
      t/t8002-blame.sh

3
builtin/blame.c

@ -2244,7 +2244,8 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path) @@ -2244,7 +2244,8 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)
pos = cache_name_pos(path, strlen(path));
if (pos >= 0)
; /* path is in the index */
else if (!strcmp(active_cache[-1 - pos]->name, path))
else if (-1 - pos < active_nr &&
!strcmp(active_cache[-1 - pos]->name, path))
; /* path is in the index, unmerged */
else
die("no such path '%s' in HEAD", path);

5
t/t8002-blame.sh

@ -6,6 +6,11 @@ test_description='git blame' @@ -6,6 +6,11 @@ test_description='git blame'
PROG='git blame -c'
. "$TEST_DIRECTORY"/annotate-tests.sh

test_expect_success 'blame untracked file in empty repo' '
>untracked &&
test_must_fail git blame untracked
'

PROG='git blame -c -e'
test_expect_success 'blame --show-email' '
check_count \

Loading…
Cancel
Save