#!/bin/sh global test_description := ''combined diff'' source ./test-lib.sh source "$TEST_DIRECTORY"/diff-lib.sh proc setup_helper { global one := $1, branch := $2, side := $3 && git branch $side $branch && for l in [$one two three fyra] { echo $l } >file && git add file && test_tick && git commit -m $branch && git checkout $side && for l in [$one two three quatro] { echo $l } >file && git add file && test_tick && git commit -m $side && test_must_fail git merge $branch && for l in [$one three four] { echo $l } >file && git add file && test_tick && git commit -m "merge $branch into $side" } proc verify_helper { global it := $1 && # Ignore lines that were removed only from the other parent sed -e ' 1,/^@@@/d /^ -/d s/^\(.\)./\1/ ' $it >"$it.actual.1" && sed -e ' 1,/^@@@/d /^- /d s/^.\(.\)/\1/ ' $it >"$it.actual.2" && git diff "$it^" $it -- | sed -e '1,/^@@/d' >"$it.expect.1" && test_cmp "$it.expect.1" "$it.actual.1" && git diff "$it^2" $it -- | sed -e '1,/^@@/d' >"$it.expect.2" && test_cmp "$it.expect.2" "$it.actual.2" } test_expect_success setup ' >file && git add file && test_tick && git commit -m initial && git branch withone && git branch sansone && git checkout withone && setup_helper one withone sidewithone && git checkout sansone && setup_helper "" sansone sidesansone ' test_expect_success 'check combined output (1)' ' git show sidewithone -- >sidewithone && verify_helper sidewithone ' test_expect_success 'check combined output (2)' ' git show sidesansone -- >sidesansone && verify_helper sidesansone ' test_expect_success 'diagnose truncated file' ' >file && git add file && git commit --amend -C HEAD && git show >out && grep "diff --cc file" out ' test_expect_success 'setup for --cc --raw' ' blob=$(echo file | git hash-object --stdin -w) && base_tree=$(echo "100644 blob $blob file" | git mktree) && trees= && for i in $(test_seq 1 40) do blob=$(echo file$i | git hash-object --stdin -w) && trees="$trees$(echo "100644 blob $blob file" | git mktree)$LF" done ' test_expect_success 'check --cc --raw with four trees' ' four_trees=$(echo "$trees" | sed -e 4q) && git diff --cc --raw $four_trees $base_tree >out && # Check for four leading colons in the output: grep "^::::[^:]" out ' test_expect_success 'check --cc --raw with forty trees' ' git diff --cc --raw $trees $base_tree >out && # Check for forty leading colons in the output: grep "^::::::::::::::::::::::::::::::::::::::::[^:]" out ' test_expect_success 'setup combined ignore spaces' ' git checkout master && >test && git add test && git commit -m initial && tr -d Q <<-\EOF >test && always coalesce eol space coalesce Q space change coalesce all spa ces coalesce eol spaces Q space change all spa ces EOF git commit -m "test space change" -a && git checkout -b side HEAD^ && tr -d Q <<-\EOF >test && always coalesce eol space coalesce space change coalesce all spaces coalesce eol spaces space change all spaces EOF git commit -m "test other space changes" -a && test_must_fail git merge master && tr -d Q <<-\EOF >test && eol spaces Q space change all spa ces EOF git commit -m merged -a ' test_expect_success 'check combined output (no ignore space)' ' git show >actual.tmp && sed -e "1,/^@@@/d" < actual.tmp >actual && tr -d Q <<-\EOF >expected && --always coalesce - eol space coalesce - space change coalesce - all spaces coalesce - eol spaces - space change - all spaces -eol space coalesce Q -space change coalesce -all spa ces coalesce + eol spaces Q + space change + all spa ces EOF compare_diff_patch expected actual ' test_expect_success 'check combined output (ignore space at eol)' ' git show --ignore-space-at-eol >actual.tmp && sed -e "1,/^@@@/d" < actual.tmp >actual && tr -d Q <<-\EOF >expected && --always coalesce --eol space coalesce - space change coalesce - all spaces coalesce -space change coalesce -all spa ces coalesce eol spaces Q - space change - all spaces + space change + all spa ces EOF compare_diff_patch expected actual ' test_expect_success 'check combined output (ignore space change)' ' git show -b >actual.tmp && sed -e "1,/^@@@/d" < actual.tmp >actual && tr -d Q <<-\EOF >expected && --always coalesce --eol space coalesce --space change coalesce - all spaces coalesce -all spa ces coalesce eol spaces Q space change - all spaces + all spa ces EOF compare_diff_patch expected actual ' test_expect_success 'check combined output (ignore all spaces)' ' git show -w >actual.tmp && sed -e "1,/^@@@/d" < actual.tmp >actual && tr -d Q <<-\EOF >expected && --always coalesce --eol space coalesce --space change coalesce --all spaces coalesce eol spaces Q space change all spa ces EOF compare_diff_patch expected actual ' test_expect_success 'combine diff coalesce simple' ' >test && git add test && git commit -m initial && test_seq 4 >test && git commit -a -m empty1 && git branch side1 && git checkout HEAD^ && test_seq 5 >test && git commit -a -m empty2 && test_must_fail git merge side1 && >test && git commit -a -m merge && git show >actual.tmp && sed -e "1,/^@@@/d" < actual.tmp >actual && tr -d Q <<-\EOF >expected && --1 --2 --3 --4 - 5 EOF compare_diff_patch expected actual ' test_expect_success 'combine diff coalesce tricky' ' >test && git add test && git commit -m initial --allow-empty && cat <<-\EOF >test && 3 1 2 3 4 EOF git commit -a -m empty1 && git branch -f side1 && git checkout HEAD^ && cat <<-\EOF >test && 1 3 5 4 EOF git commit -a -m empty2 && git branch -f side2 && test_must_fail git merge side1 && >test && git commit -a -m merge && git show >actual.tmp && sed -e "1,/^@@@/d" < actual.tmp >actual && tr -d Q <<-\EOF >expected && -3 --1 -2 --3 - 5 --4 EOF compare_diff_patch expected actual && git checkout -f side1 && test_must_fail git merge side2 && >test && git commit -a -m merge && git show >actual.tmp && sed -e "1,/^@@@/d" < actual.tmp >actual && tr -d Q <<-\EOF >expected && - 3 --1 - 2 --3 -5 --4 EOF compare_diff_patch expected actual ' test_expect_failure 'combine diff coalesce three parents' ' >test && git add test && git commit -m initial --allow-empty && cat <<-\EOF >test && 3 1 2 3 4 EOF git commit -a -m empty1 && git checkout -B side1 && git checkout HEAD^ && cat <<-\EOF >test && 1 3 7 5 4 EOF git commit -a -m empty2 && git branch -f side2 && git checkout HEAD^ && cat <<-\EOF >test && 3 1 6 5 4 EOF git commit -a -m empty3 && >test && git add test && TREE=$(git write-tree) && COMMIT=$(git commit-tree -p HEAD -p side1 -p side2 -m merge $TREE) && git show $COMMIT >actual.tmp && sed -e "1,/^@@@/d" < actual.tmp >actual && tr -d Q <<-\EOF >expected && -- 3 ---1 - 6 - 2 --3 -7 - -5 ---4 EOF compare_diff_patch expected actual ' # Test for a bug reported at # http://thread.gmane.org/gmane.comp.version-control.git/224410 # 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' ' git commit -m initial --allow-empty && cat <<-\EOF >test && 1 2 3 4 EOF git add test && git commit -a -m side1 && git checkout -B side1 && git checkout HEAD^ && cat <<-\EOF >test && 0 1 2 3 4modified EOF git add test && git commit -m side2 && git branch -f side2 && test_must_fail git merge --no-commit side1 && cat <<-\EOF >test && 1 2 3 4modified EOF git add test && git commit -a -m merge && git diff-tree -c -p HEAD >actual.tmp && sed -e "1,/^@@@/d" < actual.tmp >actual && tr -d Q <<-\EOF >expected && - 0 1 2 3 -4 +4modified EOF compare_diff_patch expected actual ' 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 && mkdir foo && echo base >foo/one && echo base >foo/two && echo base >foo.ext && git add foo foo.ext && git commit -m base && # 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 && # the other side modifies the other file in the directory git checkout -b other HEAD^ && echo other >foo/two && git commit -a -m other && # 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 merge other && printf "MM\tfoo\n" >expect && git diff-tree -c --name-status -t HEAD >actual.tmp && sed 1d actual && test_cmp expect actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"combined diff">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/diff-lib.sh)}) (FuncDef name: setup_helper body: (BraceGroup children: [ (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:one) op: Equal rhs: {($ VSub_Number "$1")} spids: [30] ) (assign_pair lhs: (LhsName name:branch) op: Equal rhs: {($ VSub_Number "$2")} spids: [33] ) (assign_pair lhs: (LhsName name:side) op: Equal rhs: {($ VSub_Number "$3")} spids: [36] ) ] spids: [30] ) (AndOr children: [ (C {(git)} {(branch)} {($ VSub_Name "$side")} {($ VSub_Name "$branch")}) (AndOr children: [ (ForEach iter_name: l iter_words: [{($ VSub_Name "$one")} {(two)} {(three)} {(fyra)}] do_arg_iter: False body: (DoGroup children:[(C {(echo)} {($ VSub_Name "$l")})] spids:[6977]) redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(file)} spids:[79])] spids: [59 -1] ) (AndOr children: [ (C {(git)} {(add)} {(file)}) (AndOr children: [ (C {(test_tick)}) (AndOr children: [ (C {(git)} {(commit)} {(-m)} {($ VSub_Name "$branch")}) (AndOr children: [ (C {(git)} {(checkout)} {($ VSub_Name "$side")}) (AndOr children: [ (ForEach iter_name: l iter_words: [ {($ VSub_Name "$one")} {(two)} {(three)} {(quatro)} ] do_arg_iter: False body: (DoGroup children: [(C {(echo)} {($ VSub_Name "$l")})] spids: [134 142] ) redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(file)} spids: [144] ) ] spids: [124 -1] ) (AndOr children: [ (C {(git)} {(add)} {(file)}) (AndOr children: [ (C {(test_tick)}) (AndOr children: [ (C {(git)} {(commit)} {(-m)} {($ VSub_Name "$side")} ) (AndOr children: [ (C {(test_must_fail)} {(git)} {(merge)} {($ VSub_Name "$branch")} ) (AndOr children: [ (ForEach iter_name: l iter_words: [ {($ VSub_Name "$one")} {(three)} {(four)} ] do_arg_iter: False body: (DoGroup children: [ (C {(echo)} {($ VSub_Name "$l")} ) ] spids: [199 207] ) redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(file)} spids: [209] ) ] spids: [191 -1] ) (AndOr children: [ (C {(git)} {(add)} {(file)}) (AndOr children: [ (C {(test_tick)}) (C {(git)} {(commit)} {(-m)} { (DQ ("merge ") ($ VSub_Name "$branch") (" into ") ($ VSub_Name "$side") ) } ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [27] ) spids: [22 26] ) (FuncDef name: verify_helper body: (BraceGroup children: [ (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:it) op: Equal rhs: {($ VSub_Number "$1")} spids: [253] ) ] spids: [253] ) (AndOr children: [ (SimpleCommand words: [ {(sed)} {(-e)} { (SQ <"\n"> <"\t\t1,/^@@@/d\n"> <"\t\t/^ -/d\n"> <"\t\ts/^\\(.\\)./\\1/\n"> <"\t"> ) } {(DQ ($ VSub_Name "$it"))} ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$it") (.actual.1))} spids: [280] ) ] ) (AndOr children: [ (SimpleCommand words: [ {(sed)} {(-e)} { (SQ <"\n"> <"\t\t1,/^@@@/d\n"> <"\t\t/^- /d\n"> <"\t\ts/^.\\(.\\)/\\1/\n"> <"\t"> ) } {(DQ ($ VSub_Name "$it"))} ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$it") (.actual.2))} spids: [305] ) ] ) (AndOr children: [ (Pipeline children: [ (C {(git)} {(diff)} {(DQ ($ VSub_Name "$it") ("^"))} {(DQ ($ VSub_Name "$it"))} {(--)} ) (SimpleCommand words: [{(sed)} {(-e)} {(SQ <"1,/^@@/d">)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$it") (.expect.1))} spids: [340] ) ] ) ] negated: False ) (AndOr children: [ (C {(test_cmp)} {(DQ ($ VSub_Name "$it") (.expect.1))} {(DQ ($ VSub_Name "$it") (.actual.1))} ) (AndOr children: [ (Pipeline children: [ (C {(git)} {(diff)} {(DQ ($ VSub_Name "$it") ("^2"))} {(DQ ($ VSub_Name "$it"))} {(--)} ) (SimpleCommand words: [{(sed)} {(-e)} {(SQ <"1,/^@@/d">)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$it") (.expect.2))} spids: [390] ) ] ) ] negated: False ) (C {(test_cmp)} {(DQ ($ VSub_Name "$it") (.expect.2))} {(DQ ($ VSub_Name "$it") (.actual.2))} ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [250] ) spids: [245 249] ) (C {(test_expect_success)} {(setup)} { (SQ <"\n"> <"\t>file &&\n"> <"\tgit add file &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m initial &&\n"> <"\n"> <"\tgit branch withone &&\n"> <"\tgit branch sansone &&\n"> <"\n"> <"\tgit checkout withone &&\n"> <"\tsetup_helper one withone sidewithone &&\n"> <"\n"> <"\tgit checkout sansone &&\n"> <"\tsetup_helper \"\" sansone sidesansone\n"> ) } ) (C {(test_expect_success)} {(SQ <"check combined output (1)">)} {(SQ <"\n"> <"\tgit show sidewithone -- >sidewithone &&\n"> <"\tverify_helper sidewithone\n">)} ) (C {(test_expect_success)} {(SQ <"check combined output (2)">)} {(SQ <"\n"> <"\tgit show sidesansone -- >sidesansone &&\n"> <"\tverify_helper sidesansone\n">)} ) (C {(test_expect_success)} {(SQ <"diagnose truncated file">)} { (SQ <"\n"> <"\t>file &&\n"> <"\tgit add file &&\n"> <"\tgit commit --amend -C HEAD &&\n"> <"\tgit show >out &&\n"> <"\tgrep \"diff --cc file\" out\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup for --cc --raw">)} { (SQ <"\n"> <"\tblob=$(echo file | git hash-object --stdin -w) &&\n"> <"\tbase_tree=$(echo \"100644 blob $blob\tfile\" | git mktree) &&\n"> <"\ttrees= &&\n"> <"\tfor i in $(test_seq 1 40)\n"> <"\tdo\n"> <"\t\tblob=$(echo file$i | git hash-object --stdin -w) &&\n"> <"\t\ttrees=\"$trees$(echo \"100644 blob $blob\tfile\" | git mktree)$LF\"\n"> <"\tdone\n"> ) } ) (C {(test_expect_success)} {(SQ <"check --cc --raw with four trees">)} { (SQ <"\n"> <"\tfour_trees=$(echo \"$trees\" | sed -e 4q) &&\n"> <"\tgit diff --cc --raw $four_trees $base_tree >out &&\n"> <"\t# Check for four leading colons in the output:\n"> <"\tgrep \"^::::[^:]\" out\n"> ) } ) (C {(test_expect_success)} {(SQ <"check --cc --raw with forty trees">)} { (SQ <"\n"> <"\tgit diff --cc --raw $trees $base_tree >out &&\n"> <"\t# Check for forty leading colons in the output:\n"> <"\tgrep \"^::::::::::::::::::::::::::::::::::::::::[^:]\" out\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup combined ignore spaces">)} { (SQ <"\n"> <"\tgit checkout master &&\n"> <"\t>test &&\n"> <"\tgit add test &&\n"> <"\tgit commit -m initial &&\n"> <"\n"> <"\ttr -d Q <<-\\EOF >test &&\n"> <"\talways coalesce\n"> <"\teol space coalesce Q\n"> <"\tspace change coalesce\n"> <"\tall spa ces coalesce\n"> <"\teol spaces Q\n"> <"\tspace change\n"> <"\tall spa ces\n"> <"\tEOF\n"> <"\tgit commit -m \"test space change\" -a &&\n"> <"\n"> <"\tgit checkout -b side HEAD^ &&\n"> <"\ttr -d Q <<-\\EOF >test &&\n"> <"\talways coalesce\n"> <"\teol space coalesce\n"> <"\tspace change coalesce\n"> <"\tall spaces coalesce\n"> <"\teol spaces\n"> <"\tspace change\n"> <"\tall spaces\n"> <"\tEOF\n"> <"\tgit commit -m \"test other space changes\" -a &&\n"> <"\n"> <"\ttest_must_fail git merge master &&\n"> <"\ttr -d Q <<-\\EOF >test &&\n"> <"\teol spaces Q\n"> <"\tspace change\n"> <"\tall spa ces\n"> <"\tEOF\n"> <"\tgit commit -m merged -a\n"> ) } ) (C {(test_expect_success)} {(SQ <"check combined output (no ignore space)">)} { (SQ <"\n"> <"\tgit show >actual.tmp &&\n"> <"\tsed -e \"1,/^@@@/d\" < actual.tmp >actual &&\n"> <"\ttr -d Q <<-\\EOF >expected &&\n"> <"\t--always coalesce\n"> <"\t- eol space coalesce\n"> <"\t- space change coalesce\n"> <"\t- all spaces coalesce\n"> <"\t- eol spaces\n"> <"\t- space change\n"> <"\t- all spaces\n"> <"\t -eol space coalesce Q\n"> <"\t -space change coalesce\n"> <"\t -all spa ces coalesce\n"> <"\t+ eol spaces Q\n"> <"\t+ space change\n"> <"\t+ all spa ces\n"> <"\tEOF\n"> <"\tcompare_diff_patch expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"check combined output (ignore space at eol)">)} { (SQ <"\n"> <"\tgit show --ignore-space-at-eol >actual.tmp &&\n"> <"\tsed -e \"1,/^@@@/d\" < actual.tmp >actual &&\n"> <"\ttr -d Q <<-\\EOF >expected &&\n"> <"\t--always coalesce\n"> <"\t--eol space coalesce\n"> <"\t- space change coalesce\n"> <"\t- all spaces coalesce\n"> <"\t -space change coalesce\n"> <"\t -all spa ces coalesce\n"> <"\t eol spaces Q\n"> <"\t- space change\n"> <"\t- all spaces\n"> <"\t+ space change\n"> <"\t+ all spa ces\n"> <"\tEOF\n"> <"\tcompare_diff_patch expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"check combined output (ignore space change)">)} { (SQ <"\n"> <"\tgit show -b >actual.tmp &&\n"> <"\tsed -e \"1,/^@@@/d\" < actual.tmp >actual &&\n"> <"\ttr -d Q <<-\\EOF >expected &&\n"> <"\t--always coalesce\n"> <"\t--eol space coalesce\n"> <"\t--space change coalesce\n"> <"\t- all spaces coalesce\n"> <"\t -all spa ces coalesce\n"> <"\t eol spaces Q\n"> <"\t space change\n"> <"\t- all spaces\n"> <"\t+ all spa ces\n"> <"\tEOF\n"> <"\tcompare_diff_patch expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"check combined output (ignore all spaces)">)} { (SQ <"\n"> <"\tgit show -w >actual.tmp &&\n"> <"\tsed -e \"1,/^@@@/d\" < actual.tmp >actual &&\n"> <"\ttr -d Q <<-\\EOF >expected &&\n"> <"\t--always coalesce\n"> <"\t--eol space coalesce\n"> <"\t--space change coalesce\n"> <"\t--all spaces coalesce\n"> <"\t eol spaces Q\n"> <"\t space change\n"> <"\t all spa ces\n"> <"\tEOF\n"> <"\tcompare_diff_patch expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"combine diff coalesce simple">)} { (SQ <"\n"> <"\t>test &&\n"> <"\tgit add test &&\n"> <"\tgit commit -m initial &&\n"> <"\ttest_seq 4 >test &&\n"> <"\tgit commit -a -m empty1 &&\n"> <"\tgit branch side1 &&\n"> <"\tgit checkout HEAD^ &&\n"> <"\ttest_seq 5 >test &&\n"> <"\tgit commit -a -m empty2 &&\n"> <"\ttest_must_fail git merge side1 &&\n"> <"\t>test &&\n"> <"\tgit commit -a -m merge &&\n"> <"\tgit show >actual.tmp &&\n"> <"\tsed -e \"1,/^@@@/d\" < actual.tmp >actual &&\n"> <"\ttr -d Q <<-\\EOF >expected &&\n"> <"\t--1\n"> <"\t--2\n"> <"\t--3\n"> <"\t--4\n"> <"\t- 5\n"> <"\tEOF\n"> <"\tcompare_diff_patch expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"combine diff coalesce tricky">)} { (SQ <"\n"> <"\t>test &&\n"> <"\tgit add test &&\n"> <"\tgit commit -m initial --allow-empty &&\n"> <"\tcat <<-\\EOF >test &&\n"> <"\t3\n"> <"\t1\n"> <"\t2\n"> <"\t3\n"> <"\t4\n"> <"\tEOF\n"> <"\tgit commit -a -m empty1 &&\n"> <"\tgit branch -f side1 &&\n"> <"\tgit checkout HEAD^ &&\n"> <"\tcat <<-\\EOF >test &&\n"> <"\t1\n"> <"\t3\n"> <"\t5\n"> <"\t4\n"> <"\tEOF\n"> <"\tgit commit -a -m empty2 &&\n"> <"\tgit branch -f side2 &&\n"> <"\ttest_must_fail git merge side1 &&\n"> <"\t>test &&\n"> <"\tgit commit -a -m merge &&\n"> <"\tgit show >actual.tmp &&\n"> <"\tsed -e \"1,/^@@@/d\" < actual.tmp >actual &&\n"> <"\ttr -d Q <<-\\EOF >expected &&\n"> <"\t -3\n"> <"\t--1\n"> <"\t -2\n"> <"\t--3\n"> <"\t- 5\n"> <"\t--4\n"> <"\tEOF\n"> <"\tcompare_diff_patch expected actual &&\n"> <"\tgit checkout -f side1 &&\n"> <"\ttest_must_fail git merge side2 &&\n"> <"\t>test &&\n"> <"\tgit commit -a -m merge &&\n"> <"\tgit show >actual.tmp &&\n"> <"\tsed -e \"1,/^@@@/d\" < actual.tmp >actual &&\n"> <"\ttr -d Q <<-\\EOF >expected &&\n"> <"\t- 3\n"> <"\t--1\n"> <"\t- 2\n"> <"\t--3\n"> <"\t -5\n"> <"\t--4\n"> <"\tEOF\n"> <"\tcompare_diff_patch expected actual\n"> ) } ) (C {(test_expect_failure)} {(SQ <"combine diff coalesce three parents">)} { (SQ <"\n"> <"\t>test &&\n"> <"\tgit add test &&\n"> <"\tgit commit -m initial --allow-empty &&\n"> <"\tcat <<-\\EOF >test &&\n"> <"\t3\n"> <"\t1\n"> <"\t2\n"> <"\t3\n"> <"\t4\n"> <"\tEOF\n"> <"\tgit commit -a -m empty1 &&\n"> <"\tgit checkout -B side1 &&\n"> <"\tgit checkout HEAD^ &&\n"> <"\tcat <<-\\EOF >test &&\n"> <"\t1\n"> <"\t3\n"> <"\t7\n"> <"\t5\n"> <"\t4\n"> <"\tEOF\n"> <"\tgit commit -a -m empty2 &&\n"> <"\tgit branch -f side2 &&\n"> <"\tgit checkout HEAD^ &&\n"> <"\tcat <<-\\EOF >test &&\n"> <"\t3\n"> <"\t1\n"> <"\t6\n"> <"\t5\n"> <"\t4\n"> <"\tEOF\n"> <"\tgit commit -a -m empty3 &&\n"> <"\t>test &&\n"> <"\tgit add test &&\n"> <"\tTREE=$(git write-tree) &&\n"> <"\tCOMMIT=$(git commit-tree -p HEAD -p side1 -p side2 -m merge $TREE) &&\n"> <"\tgit show $COMMIT >actual.tmp &&\n"> <"\tsed -e \"1,/^@@@/d\" < actual.tmp >actual &&\n"> <"\ttr -d Q <<-\\EOF >expected &&\n"> <"\t-- 3\n"> <"\t---1\n"> <"\t- 6\n"> <"\t - 2\n"> <"\t --3\n"> <"\t -7\n"> <"\t- -5\n"> <"\t---4\n"> <"\tEOF\n"> <"\tcompare_diff_patch expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"combine diff missing delete bug">)} { (SQ <"\n"> <"\tgit commit -m initial --allow-empty &&\n"> <"\tcat <<-\\EOF >test &&\n"> <"\t1\n"> <"\t2\n"> <"\t3\n"> <"\t4\n"> <"\tEOF\n"> <"\tgit add test &&\n"> <"\tgit commit -a -m side1 &&\n"> <"\tgit checkout -B side1 &&\n"> <"\tgit checkout HEAD^ &&\n"> <"\tcat <<-\\EOF >test &&\n"> <"\t0\n"> <"\t1\n"> <"\t2\n"> <"\t3\n"> <"\t4modified\n"> <"\tEOF\n"> <"\tgit add test &&\n"> <"\tgit commit -m side2 &&\n"> <"\tgit branch -f side2 &&\n"> <"\ttest_must_fail git merge --no-commit side1 &&\n"> <"\tcat <<-\\EOF >test &&\n"> <"\t1\n"> <"\t2\n"> <"\t3\n"> <"\t4modified\n"> <"\tEOF\n"> <"\tgit add test &&\n"> <"\tgit commit -a -m merge &&\n"> <"\tgit diff-tree -c -p HEAD >actual.tmp &&\n"> <"\tsed -e \"1,/^@@@/d\" < actual.tmp >actual &&\n"> <"\ttr -d Q <<-\\EOF >expected &&\n"> <"\t- 0\n"> <"\t 1\n"> <"\t 2\n"> <"\t 3\n"> <"\t -4\n"> <"\t +4modified\n"> <"\tEOF\n"> <"\tcompare_diff_patch expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"combine diff gets tree sorting right">)} { (SQ <"\n"> <"\t# create a directory and a file that sort differently in trees\n"> <"\t# versus byte-wise (implied \"/\" sorts after \".\")\n"> <"\tgit checkout -f master &&\n"> <"\tmkdir foo &&\n"> <"\techo base >foo/one &&\n"> <"\techo base >foo/two &&\n"> <"\techo base >foo.ext &&\n"> <"\tgit add foo foo.ext &&\n"> <"\tgit commit -m base &&\n"> <"\n"> <"\t# one side modifies a file in the directory, along with the root\n"> <"\t# file...\n"> <"\techo master >foo/one &&\n"> <"\techo master >foo.ext &&\n"> <"\tgit commit -a -m master &&\n"> <"\n"> <"\t# the other side modifies the other file in the directory\n"> <"\tgit checkout -b other HEAD^ &&\n"> <"\techo other >foo/two &&\n"> <"\tgit commit -a -m other &&\n"> <"\n"> <"\t# And now we merge. The files in the subdirectory will resolve cleanly,\n"> <"\t# meaning that a combined diff will not find them interesting. But it\n"> <"\t# will find the tree itself interesting, because it had to be merged.\n"> <"\tgit checkout master &&\n"> <"\tgit merge other &&\n"> <"\n"> <"\tprintf \"MM\\tfoo\\n\" >expect &&\n"> <"\tgit diff-tree -c --name-status -t HEAD >actual.tmp &&\n"> <"\tsed 1d actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_done)}) ] )