Skip to content

Commit

Permalink
t6022: Additional tests checking for unnecessary updates of files
Browse files Browse the repository at this point in the history
I stumbled across a case, this one not involving a content merge, where
git currently rewrites a file unnecessarily.  A quick audit uncovered two
additional situations (also not involving content merges) with the same
problem.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Elijah Newren authored and Junio C Hamano committed Aug 14, 2011
1 parent f53d397 commit 3e333a6
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions t/t6022-merge-rename.sh
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,97 @@ test_expect_success 'avoid unnecessary update, with D/F conflict' '
test_cmp expect actual # "df" should have stayed intact
'

test_expect_success 'setup avoid unnecessary update, dir->(file,nothing)' '
git rm -rf . &&
git clean -fdqx &&
rm -rf .git &&
git init &&
>irrelevant &&
mkdir df &&
>df/file &&
git add -A &&
git commit -mA &&
git checkout -b side
git rm -rf df &&
git commit -mB &&
git checkout master &&
git rm -rf df &&
echo bla >df &&
git add -A &&
git commit -m "Add a newfile"
'

test_expect_failure 'avoid unnecessary update, dir->(file,nothing)' '
git checkout -q master^0 &&
test-chmtime =1000000000 df &&
test-chmtime -v +0 df >expect &&
git merge side &&
test-chmtime -v +0 df >actual &&
test_cmp expect actual # "df" should have stayed intact
'

test_expect_success 'setup avoid unnecessary update, modify/delete' '
git rm -rf . &&
git clean -fdqx &&
rm -rf .git &&
git init &&
>irrelevant &&
>file &&
git add -A &&
git commit -mA &&
git checkout -b side
git rm -f file &&
git commit -m "Delete file" &&
git checkout master &&
echo bla >file &&
git add -A &&
git commit -m "Modify file"
'

test_expect_failure 'avoid unnecessary update, modify/delete' '
git checkout -q master^0 &&
test-chmtime =1000000000 file &&
test-chmtime -v +0 file >expect &&
test_must_fail git merge side &&
test-chmtime -v +0 file >actual &&
test_cmp expect actual # "file" should have stayed intact
'

test_expect_success 'setup avoid unnecessary update, rename/add-dest' '
git rm -rf . &&
git clean -fdqx &&
rm -rf .git &&
git init &&
printf "1\n2\n3\n4\n5\n6\n7\n8\n" >file &&
git add -A &&
git commit -mA &&
git checkout -b side
cp file newfile &&
git add -A &&
git commit -m "Add file copy" &&
git checkout master &&
git mv file newfile &&
git commit -m "Rename file"
'

test_expect_failure 'avoid unnecessary update, rename/add-dest' '
git checkout -q master^0 &&
test-chmtime =1000000000 newfile &&
test-chmtime -v +0 newfile >expect &&
git merge side &&
test-chmtime -v +0 newfile >actual &&
test_cmp expect actual # "file" should have stayed intact
'

test_expect_success 'setup merge of rename + small change' '
git reset --hard &&
git checkout --orphan rename-plus-small-change &&
Expand Down

0 comments on commit 3e333a6

Please sign in to comment.