diff options
Diffstat (limited to 't/t4038-diff-combined.sh')
-rwxr-xr-x | t/t4038-diff-combined.sh | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh index b9d876efa2..aeac203c42 100755 --- a/t/t4038-diff-combined.sh +++ b/t/t4038-diff-combined.sh @@ -2,8 +2,11 @@ test_description='combined diff' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh -. "$TEST_DIRECTORY"/diff-lib.sh +. "$TEST_DIRECTORY"/lib-diff.sh setup_helper () { one=$1 branch=$2 side=$3 && @@ -115,7 +118,7 @@ test_expect_success 'check --cc --raw with forty trees' ' ' test_expect_success 'setup combined ignore spaces' ' - git checkout master && + git checkout main && >test && git add test && git commit -m initial && @@ -143,7 +146,7 @@ test_expect_success 'setup combined ignore spaces' ' EOF git commit -m "test other space changes" -a && - test_must_fail git merge master && + test_must_fail git merge main && tr -d Q <<-\EOF >test && eol spaces Q space change @@ -354,7 +357,7 @@ test_expect_failure 'combine diff coalesce three parents' ' ' # Test for a bug reported at -# https://public-inbox.org/git/20130515143508.GO25742@login.drsnuggles.stderr.nl/ +# https://lore.kernel.org/git/20130515143508.GO25742@login.drsnuggles.stderr.nl/ # where a delete lines were missing from combined diff output when they # occurred exactly before the context lines of a later change. test_expect_success 'combine diff missing delete bug' ' @@ -404,7 +407,7 @@ test_expect_success 'combine diff missing delete bug' ' test_expect_success 'combine diff gets tree sorting right' ' # create a directory and a file that sort differently in trees # versus byte-wise (implied "/" sorts after ".") - git checkout -f master && + git checkout -f main && mkdir foo && echo base >foo/one && echo base >foo/two && @@ -414,9 +417,9 @@ test_expect_success 'combine diff gets tree sorting right' ' # one side modifies a file in the directory, along with the root # file... - echo master >foo/one && - echo master >foo.ext && - git commit -a -m master && + echo main >foo/one && + echo main >foo.ext && + git commit -a -m main && # the other side modifies the other file in the directory git checkout -b other HEAD^ && @@ -426,7 +429,7 @@ test_expect_success 'combine diff gets tree sorting right' ' # And now we merge. The files in the subdirectory will resolve cleanly, # meaning that a combined diff will not find them interesting. But it # will find the tree itself interesting, because it had to be merged. - git checkout master && + git checkout main && git merge other && printf "MM\tfoo\n" >expect && @@ -440,11 +443,13 @@ test_expect_success 'setup for --combined-all-paths' ' git branch side2c && git checkout side1c && test_seq 1 10 >filename-side1c && + side1cf=$(git hash-object filename-side1c) && git add filename-side1c && git commit -m with && git checkout side2c && test_seq 1 9 >filename-side2c && echo ten >>filename-side2c && + side2cf=$(git hash-object filename-side2c) && git add filename-side2c && git commit -m iam && git checkout -b mergery side1c && @@ -452,13 +457,14 @@ test_expect_success 'setup for --combined-all-paths' ' git rm filename-side1c && echo eleven >>filename-side2c && git mv filename-side2c filename-merged && + mergedf=$(git hash-object filename-merged) && git add filename-merged && git commit ' test_expect_success '--combined-all-paths and --raw' ' - cat <<-\EOF >expect && - ::100644 100644 100644 f00c965d8307308469e537302baa73048488f162 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 333b9c62519f285e1854830ade0fe1ef1d40ee1b RR filename-side1c filename-side2c filename-merged + cat <<-EOF >expect && + ::100644 100644 100644 $side1cf $side2cf $mergedf RR filename-side1c filename-side2c filename-merged EOF git diff-tree -c -M --raw --combined-all-paths HEAD >actual.tmp && sed 1d <actual.tmp >actual && @@ -482,11 +488,13 @@ test_expect_success FUNNYNAMES 'setup for --combined-all-paths with funny names' git checkout side1d && test_seq 1 10 >"$(printf "file\twith\ttabs")" && git add file* && + side1df=$(git hash-object *tabs) && git commit -m with && git checkout side2d && test_seq 1 9 >"$(printf "i\tam\ttabbed")" && echo ten >>"$(printf "i\tam\ttabbed")" && git add *tabbed && + side2df=$(git hash-object *tabbed) && git commit -m iam && git checkout -b funny-names-mergery side1d && git merge --no-commit side2d && @@ -494,12 +502,14 @@ test_expect_success FUNNYNAMES 'setup for --combined-all-paths with funny names' echo eleven >>"$(printf "i\tam\ttabbed")" && git mv "$(printf "i\tam\ttabbed")" "$(printf "fickle\tnaming")" && git add fickle* && - git commit + headf=$(git hash-object fickle*) && + git commit && + head=$(git rev-parse HEAD) ' test_expect_success FUNNYNAMES '--combined-all-paths and --raw and funny names' ' - cat <<-\EOF >expect && - ::100644 100644 100644 f00c965d8307308469e537302baa73048488f162 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 333b9c62519f285e1854830ade0fe1ef1d40ee1b RR "file\twith\ttabs" "i\tam\ttabbed" "fickle\tnaming" + cat <<-EOF >expect && + ::100644 100644 100644 $side1df $side2df $headf RR "file\twith\ttabs" "i\tam\ttabbed" "fickle\tnaming" EOF git diff-tree -c -M --raw --combined-all-paths HEAD >actual.tmp && sed 1d <actual.tmp >actual && @@ -507,7 +517,7 @@ test_expect_success FUNNYNAMES '--combined-all-paths and --raw and funny names' ' test_expect_success FUNNYNAMES '--combined-all-paths and --raw -and -z and funny names' ' - printf "aaf8087c3cbd4db8e185a2d074cf27c53cfb75d7\0::100644 100644 100644 f00c965d8307308469e537302baa73048488f162 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 333b9c62519f285e1854830ade0fe1ef1d40ee1b RR\0file\twith\ttabs\0i\tam\ttabbed\0fickle\tnaming\0" >expect && + printf "$head\0::100644 100644 100644 $side1df $side2df $headf RR\0file\twith\ttabs\0i\tam\ttabbed\0fickle\tnaming\0" >expect && git diff-tree -c -M --raw --combined-all-paths -z HEAD >actual && test_cmp expect actual ' |