mirror of
https://github.com/git/git.git
synced 2024-11-17 14:34:49 +01:00
a9b2d42486
When trying to see if the same path exists in the parent, we ran "diff-tree" with pathspec set to the path we are interested in with the parent, and expect either to have exactly one resulting filepair (either "changed from the parent", "created when there was none") or nothing (when there is no change from the parent). If the path used to be a directory, however, we will also see unbounded number of entries that talk about the files that used to exist underneath the directory in question. Correctly pick only the entry that describes the path we are interested in in such a case (namely, the creation of the path as a regular file). Noticed by Ben Willard. Signed-off-by: Junio C Hamano <gitster@pobox.com>
147 lines
2.5 KiB
Bash
Executable file
147 lines
2.5 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='git blame corner cases'
|
|
. ./test-lib.sh
|
|
|
|
pick_fc='s/^[0-9a-f^]* *\([^ ]*\) *(\([^ ]*\) .*/\1-\2/'
|
|
|
|
test_expect_success setup '
|
|
|
|
echo A A A A A >one &&
|
|
echo B B B B B >two &&
|
|
echo C C C C C >tres &&
|
|
echo ABC >mouse &&
|
|
git add one two tres mouse &&
|
|
test_tick &&
|
|
GIT_AUTHOR_NAME=Initial git commit -m Initial &&
|
|
|
|
cat one >uno &&
|
|
mv two dos &&
|
|
cat one >>tres &&
|
|
echo DEF >>mouse
|
|
git add uno dos tres mouse &&
|
|
test_tick &&
|
|
GIT_AUTHOR_NAME=Second git commit -a -m Second &&
|
|
|
|
echo GHIJK >>mouse &&
|
|
git add mouse &&
|
|
test_tick &&
|
|
GIT_AUTHOR_NAME=Third git commit -m Third &&
|
|
|
|
cat mouse >cow &&
|
|
git add cow &&
|
|
test_tick &&
|
|
GIT_AUTHOR_NAME=Fourth git commit -m Fourth &&
|
|
|
|
{
|
|
echo ABC
|
|
echo DEF
|
|
echo XXXX
|
|
echo GHIJK
|
|
} >cow &&
|
|
git add cow &&
|
|
test_tick &&
|
|
GIT_AUTHOR_NAME=Fifth git commit -m Fifth
|
|
'
|
|
|
|
test_expect_success 'straight copy without -C' '
|
|
|
|
git blame uno | grep Second
|
|
|
|
'
|
|
|
|
test_expect_success 'straight move without -C' '
|
|
|
|
git blame dos | grep Initial
|
|
|
|
'
|
|
|
|
test_expect_success 'straight copy with -C' '
|
|
|
|
git blame -C1 uno | grep Second
|
|
|
|
'
|
|
|
|
test_expect_success 'straight move with -C' '
|
|
|
|
git blame -C1 dos | grep Initial
|
|
|
|
'
|
|
|
|
test_expect_success 'straight copy with -C -C' '
|
|
|
|
git blame -C -C1 uno | grep Initial
|
|
|
|
'
|
|
|
|
test_expect_success 'straight move with -C -C' '
|
|
|
|
git blame -C -C1 dos | grep Initial
|
|
|
|
'
|
|
|
|
test_expect_success 'append without -C' '
|
|
|
|
git blame -L2 tres | grep Second
|
|
|
|
'
|
|
|
|
test_expect_success 'append with -C' '
|
|
|
|
git blame -L2 -C1 tres | grep Second
|
|
|
|
'
|
|
|
|
test_expect_success 'append with -C -C' '
|
|
|
|
git blame -L2 -C -C1 tres | grep Second
|
|
|
|
'
|
|
|
|
test_expect_success 'append with -C -C -C' '
|
|
|
|
git blame -L2 -C -C -C1 tres | grep Initial
|
|
|
|
'
|
|
|
|
test_expect_success 'blame wholesale copy' '
|
|
|
|
git blame -f -C -C1 HEAD^ -- cow | sed -e "$pick_fc" >current &&
|
|
{
|
|
echo mouse-Initial
|
|
echo mouse-Second
|
|
echo mouse-Third
|
|
} >expected &&
|
|
test_cmp expected current
|
|
|
|
'
|
|
|
|
test_expect_success 'blame wholesale copy and more' '
|
|
|
|
git blame -f -C -C1 HEAD -- cow | sed -e "$pick_fc" >current &&
|
|
{
|
|
echo mouse-Initial
|
|
echo mouse-Second
|
|
echo cow-Fifth
|
|
echo mouse-Third
|
|
} >expected &&
|
|
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 &&
|
|
echo B B B B B >path/elif &&
|
|
git add path &&
|
|
test_tick &&
|
|
git commit -m "path was a directory" &&
|
|
rm -fr path &&
|
|
echo A A A A A >path &&
|
|
git add path &&
|
|
test_tick &&
|
|
git commit -m "path is a regular file" &&
|
|
git blame HEAD^.. -- path
|
|
'
|
|
|
|
test_done
|