#!/bin/sh global test_description := ''diff order'' source ./test-lib.sh proc create_files { echo $1 >a.h && echo $1 >b.c && echo $1 >c/Makefile && echo $1 >d.txt && git add a.h b.c c/Makefile d.txt && git commit -m"$1" } test_expect_success 'setup' ' mkdir c && create_files 1 && create_files 2 && cat >order_file_1 <<-\EOF && *Makefile *.txt *.h EOF cat >order_file_2 <<-\EOF && *Makefile *.h *.c EOF cat >expect_none <<-\EOF && a.h b.c c/Makefile d.txt EOF cat >expect_1 <<-\EOF && c/Makefile d.txt a.h b.c EOF cat >expect_2 <<-\EOF c/Makefile a.h b.c d.txt EOF ' test_expect_success "no order (=tree object order)" ' git diff --name-only HEAD^..HEAD >actual && test_cmp expect_none actual ' test_expect_success 'missing orderfile' ' rm -f bogus_file && test_must_fail git diff -Obogus_file --name-only HEAD^..HEAD ' test_expect_success POSIXPERM,SANITY 'unreadable orderfile' ' >unreadable_file && chmod -r unreadable_file && test_must_fail git diff -Ounreadable_file --name-only HEAD^..HEAD ' test_expect_success "orderfile using option from subdir with --output" ' mkdir subdir && git -C subdir diff -O../order_file_1 --output ../actual --name-only HEAD^..HEAD && test_cmp expect_1 actual ' for i in [1 2] { test_expect_success "orderfile using option ($i)" ' git diff -Oorder_file_$i --name-only HEAD^..HEAD >actual && test_cmp expect_$i actual ' test_expect_success PIPE "orderfile is fifo ($i)" ' rm -f order_fifo && mkfifo order_fifo && { cat order_file_$i >order_fifo & } && git diff -O order_fifo --name-only HEAD^..HEAD >actual && wait && test_cmp expect_$i actual ' test_expect_success "orderfile using config ($i)" ' git -c diff.orderfile=order_file_$i diff --name-only HEAD^..HEAD >actual && test_cmp expect_$i actual ' test_expect_success "cancelling configured orderfile ($i)" ' git -c diff.orderfile=order_file_$i diff -O/dev/null --name-only HEAD^..HEAD >actual && test_cmp expect_none actual ' } test_expect_success 'setup for testing combine-diff order' ' git checkout -b tmp HEAD~ && create_files 3 && git checkout master && git merge --no-commit -s ours tmp && create_files 5 ' test_expect_success "combine-diff: no order (=tree object order)" ' git diff --name-only HEAD HEAD^ HEAD^2 >actual && test_cmp expect_none actual ' for i in [1 2] { test_expect_success "combine-diff: orderfile using option ($i)" ' git diff -Oorder_file_$i --name-only HEAD HEAD^ HEAD^2 >actual && test_cmp expect_$i actual ' } test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"diff order">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: create_files body: (BraceGroup children: [ (AndOr children: [ (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Number "$1"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(a.h)} spids:[29])] ) (AndOr children: [ (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Number "$1"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(b.c)} spids:[41])] ) (AndOr children: [ (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Number "$1"))}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(c/Makefile)} spids: [53] ) ] ) (AndOr children: [ (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Number "$1"))}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(d.txt)} spids: [65] ) ] ) (AndOr children: [ (C {(git)} {(add)} {(a.h)} {(b.c)} {(c/Makefile)} {(d.txt)}) (C {(git)} {(commit)} {(-m) (DQ ($ VSub_Number "$1"))}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [20] ) spids: [15 19] ) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\tmkdir c &&\n"> <"\tcreate_files 1 &&\n"> <"\tcreate_files 2 &&\n"> <"\n"> <"\tcat >order_file_1 <<-\\EOF &&\n"> <"\t*Makefile\n"> <"\t*.txt\n"> <"\t*.h\n"> <"\tEOF\n"> <"\n"> <"\tcat >order_file_2 <<-\\EOF &&\n"> <"\t*Makefile\n"> <"\t*.h\n"> <"\t*.c\n"> <"\tEOF\n"> <"\n"> <"\tcat >expect_none <<-\\EOF &&\n"> <"\ta.h\n"> <"\tb.c\n"> <"\tc/Makefile\n"> <"\td.txt\n"> <"\tEOF\n"> <"\n"> <"\tcat >expect_1 <<-\\EOF &&\n"> <"\tc/Makefile\n"> <"\td.txt\n"> <"\ta.h\n"> <"\tb.c\n"> <"\tEOF\n"> <"\n"> <"\tcat >expect_2 <<-\\EOF\n"> <"\tc/Makefile\n"> <"\ta.h\n"> <"\tb.c\n"> <"\td.txt\n"> <"\tEOF\n"> ) } ) (C {(test_expect_success)} {(DQ ("no order (=tree object order)"))} { (SQ <"\n"> <"\tgit diff --name-only HEAD^..HEAD >actual &&\n"> <"\ttest_cmp expect_none actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"missing orderfile">)} { (SQ <"\n"> <"\trm -f bogus_file &&\n"> <"\ttest_must_fail git diff -Obogus_file --name-only HEAD^..HEAD\n"> ) } ) (C {(test_expect_success)} {(POSIXPERM) (Lit_Comma ",") (SANITY)} {(SQ <"unreadable orderfile">)} { (SQ <"\n"> <"\t>unreadable_file &&\n"> <"\tchmod -r unreadable_file &&\n"> <"\ttest_must_fail git diff -Ounreadable_file --name-only HEAD^..HEAD\n"> ) } ) (C {(test_expect_success)} {(DQ ("orderfile using option from subdir with --output"))} { (SQ <"\n"> <"\tmkdir subdir &&\n"> < "\tgit -C subdir diff -O../order_file_1 --output ../actual --name-only HEAD^..HEAD &&\n" > <"\ttest_cmp expect_1 actual\n"> ) } ) (ForEach iter_name: i iter_words: [{(1)} {(2)}] do_arg_iter: False body: (DoGroup children: [ (C {(test_expect_success)} {(DQ ("orderfile using option (") ($ VSub_Name "$i") (")"))} { (SQ <"\n"> <"\t\tgit diff -Oorder_file_$i --name-only HEAD^..HEAD >actual &&\n"> <"\t\ttest_cmp expect_$i actual\n"> <"\t"> ) } ) (C {(test_expect_success)} {(PIPE)} {(DQ ("orderfile is fifo (") ($ VSub_Name "$i") (")"))} { (SQ <"\n"> <"\t\trm -f order_fifo &&\n"> <"\t\tmkfifo order_fifo &&\n"> <"\t\t{\n"> <"\t\t\tcat order_file_$i >order_fifo &\n"> <"\t\t} &&\n"> <"\t\tgit diff -O order_fifo --name-only HEAD^..HEAD >actual &&\n"> <"\t\twait &&\n"> <"\t\ttest_cmp expect_$i actual\n"> <"\t"> ) } ) (C {(test_expect_success)} {(DQ ("orderfile using config (") ($ VSub_Name "$i") (")"))} { (SQ <"\n"> < "\t\tgit -c diff.orderfile=order_file_$i diff --name-only HEAD^..HEAD >actual &&\n" > <"\t\ttest_cmp expect_$i actual\n"> <"\t"> ) } ) (C {(test_expect_success)} {(DQ ("cancelling configured orderfile (") ($ VSub_Name "$i") (")"))} { (SQ <"\n"> < "\t\tgit -c diff.orderfile=order_file_$i diff -O/dev/null --name-only HEAD^..HEAD >actual &&\n" > <"\t\ttest_cmp expect_none actual\n"> <"\t"> ) } ) ] spids: [213 290] ) spids: [208 -1] ) (C {(test_expect_success)} {(SQ <"setup for testing combine-diff order">)} { (SQ <"\n"> <"\tgit checkout -b tmp HEAD~ &&\n"> <"\tcreate_files 3 &&\n"> <"\tgit checkout master &&\n"> <"\tgit merge --no-commit -s ours tmp &&\n"> <"\tcreate_files 5\n"> ) } ) (C {(test_expect_success)} {(DQ ("combine-diff: no order (=tree object order)"))} { (SQ <"\n"> <"\tgit diff --name-only HEAD HEAD^ HEAD^2 >actual &&\n"> <"\ttest_cmp expect_none actual\n"> ) } ) (ForEach iter_name: i iter_words: [{(1)} {(2)}] do_arg_iter: False body: (DoGroup children: [ (C {(test_expect_success)} {(DQ ("combine-diff: orderfile using option (") ($ VSub_Name "$i") (")"))} { (SQ <"\n"> <"\t\tgit diff -Oorder_file_$i --name-only HEAD HEAD^ HEAD^2 >actual &&\n"> <"\t\ttest_cmp expect_$i actual\n"> <"\t"> ) } ) ] spids: [332 350] ) spids: [327 -1] ) (C {(test_done)}) ] )