Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2016-07-16 02:23:45 +0300
committerJunio C Hamano <gitster@pobox.com>2016-07-19 00:33:38 +0300
commit3b75ee93278179004bc2f117fcfe3d5d76a0a2fa (patch)
tree86f8d5603b6030f76206ec1f1beac1eb3d6ff45b /t/t8003-blame-corner-cases.sh
parent0b65a8dbdb38962e700ee16776a3042beb489060 (diff)
blame: allow to blame paths freshly added to the index
When blaming files, changes in the work tree are taken into account and displayed as being "Not Committed Yet". However, when blaming a file that is not known to the current HEAD, git blame fails with `no such path 'foo' in HEAD`, even when the file was git add'ed. Allowing such a blame is useful when the new file added to the index (not yet committed) was created by renaming an existing file. It also is useful when the new file was created from pieces already in HEAD, moved or copied from other files and blaming with copy detection (i.e. "-C"). Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t8003-blame-corner-cases.sh')
-rwxr-xr-xt/t8003-blame-corner-cases.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/t/t8003-blame-corner-cases.sh b/t/t8003-blame-corner-cases.sh
index a9b266f0d3..eab2e28094 100755
--- a/t/t8003-blame-corner-cases.sh
+++ b/t/t8003-blame-corner-cases.sh
@@ -137,6 +137,51 @@ test_expect_success 'blame wholesale copy and more' '
'
+test_expect_success 'blame wholesale copy and more in the index' '
+
+ cat >horse <<-\EOF &&
+ ABC
+ DEF
+ XXXX
+ YYYY
+ GHIJK
+ EOF
+ git add horse &&
+ test_when_finished "git rm -f horse" &&
+ git blame -f -C -C1 -- horse | sed -e "$pick_fc" >current &&
+ cat >expected <<-\EOF &&
+ mouse-Initial
+ mouse-Second
+ cow-Fifth
+ horse-Not
+ mouse-Third
+ EOF
+ test_cmp expected current
+
+'
+
+test_expect_success 'blame during cherry-pick with file rename conflict' '
+
+ test_when_finished "git reset --hard && git checkout master" &&
+ git checkout HEAD~3 &&
+ echo MOUSE >> mouse &&
+ git mv mouse rodent &&
+ git add rodent &&
+ GIT_AUTHOR_NAME=Rodent git commit -m "rodent" &&
+ git checkout --detach master &&
+ (git cherry-pick HEAD@{1} || test $? -eq 1) &&
+ git show HEAD@{1}:rodent > rodent &&
+ git add rodent &&
+ git blame -f -C -C1 rodent | sed -e "$pick_fc" >current &&
+ cat current &&
+ cat >expected <<-\EOF &&
+ mouse-Initial
+ mouse-Second
+ rodent-Not
+ EOF
+ test_cmp expected current
+'
+
test_expect_success 'blame path that used to be a directory' '
mkdir path &&
echo A A A A A >path/file &&