Code

git-blame shouldn't crash if run in an unmerged tree
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 18 Oct 2007 06:31:30 +0000 (02:31 -0400)
committerShawn O. Pearce <spearce@spearce.org>
Thu, 18 Oct 2007 06:31:30 +0000 (02:31 -0400)
commitcd8ae20195ae09c06d0854f1ebf92d1f1164c927
treeed65d9843eac52619f5d696b865e2e2e14697d61
parent93a56c2cf7c8b29ca4c5e0740fe1e487324ffc73
git-blame shouldn't crash if run in an unmerged tree

If we are in the middle of resolving a merge conflict there may be
one or more files whose entries in the index represent an unmerged
state (index entries in the higher-order stages).

Attempting to run git-blame on any file in such a working directory
resulted in "fatal: internal error: ce_mode is 0" as we use the magic
marker for an unmerged entry is 0 (set up by things like diff-lib.c's
do_diff_cache() and builtin-read-tree.c's read_tree_unmerged())
and the ce_match_stat_basic() function gets upset about this.

I'm not entirely sure that the whole "ce_mode = 0" case is a good
idea to begin with, and maybe the right thing to do is to remove
that horrid freakish special case, but removing the internal error
seems to be the simplest fix for now.

                Linus

[sp: Thanks to Björn Steinbrink for the test case]

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
read-cache.c
t/t8004-blame.sh [new file with mode: 0755]