From 3f96d75ef548039632d48552d0e6bc4435b2382b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 23 Jan 2021 14:00:37 +0100 Subject: cache-tree tests: refactor for modern test style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor the cache-tree test file to use our current recommended patterns. This makes a subsequent meaningful change easier to read. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh index 5a63369..45e1cc8 100755 --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@ -10,7 +10,8 @@ cache-tree extension. cmp_cache_tree () { test-tool dump-cache-tree | sed -e '/#(ref)/d' >actual && sed "s/$OID_REGEX/SHA/" filtered && - test_cmp "$1" filtered + test_cmp "$1" filtered && + rm filtered } # We don't bother with actually checking the SHA1: @@ -54,7 +55,7 @@ test_invalid_cache_tree () { } test_no_cache_tree () { - : >expect && + >expect && cmp_cache_tree expect } @@ -83,18 +84,6 @@ test_expect_success 'git-add in subdir invalidates cache-tree' ' test_invalid_cache_tree ' -cat >before <<\EOF -SHA (3 entries, 2 subtrees) -SHA dir1/ (1 entries, 0 subtrees) -SHA dir2/ (1 entries, 0 subtrees) -EOF - -cat >expect <<\EOF -invalid (2 subtrees) -invalid dir1/ (0 subtrees) -SHA dir2/ (1 entries, 0 subtrees) -EOF - test_expect_success 'git-add in subdir does not invalidate sibling cache-tree' ' git tag no-children && test_when_finished "git reset --hard no-children; git read-tree HEAD" && @@ -102,9 +91,20 @@ test_expect_success 'git-add in subdir does not invalidate sibling cache-tree' ' test_commit dir1/a && test_commit dir2/b && echo "I changed this file" >dir1/a && + test_when_finished "rm before" && + cat >before <<-\EOF && + SHA (3 entries, 2 subtrees) + SHA dir1/ (1 entries, 0 subtrees) + SHA dir2/ (1 entries, 0 subtrees) + EOF cmp_cache_tree before && echo "I changed this file" >dir1/a && git add dir1/a && + cat >expect <<-\EOF && + invalid (2 subtrees) + invalid dir1/ (0 subtrees) + SHA dir2/ (1 entries, 0 subtrees) + EOF cmp_cache_tree expect ' -- cgit v0.10.2-6-g49f6 From 32267255070604efe0672793a1bbb797558765bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 23 Jan 2021 14:00:38 +0100 Subject: cache-tree tests: remove unused $2 parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the $2 paramater. This appears to have been some work-in-progress code from an earlier version of 9c4d6c0297 (cache-tree: Write updated cache-tree after commit, 2014-07-13) which was left in the final version. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh index 45e1cc8..7ff7f04 100755 --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@ -19,7 +19,6 @@ cmp_cache_tree () { # correct. generate_expected_cache_tree_rec () { dir="$1${1:+/}" && - parent="$2" && # ls-files might have foo/bar, foo/bar/baz, and foo/bar/quux # We want to count only foo because it's the only direct child git ls-files >files && @@ -30,10 +29,9 @@ generate_expected_cache_tree_rec () { for subtree in $subtrees do cd "$subtree" - generate_expected_cache_tree_rec "$dir$subtree" "$dir" || return 1 + generate_expected_cache_tree_rec "$dir$subtree" || return 1 cd .. - done && - dir=$parent + done } generate_expected_cache_tree () { -- cgit v0.10.2-6-g49f6 From fa6edee7765028daa8c69051b404c8374d0c2a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 23 Jan 2021 14:00:39 +0100 Subject: cache-tree tests: use a sub-shell with less indirection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change a "cd xyz && work && cd .." pattern introduced in 9c4d6c0297 (cache-tree: Write updated cache-tree after commit, 2014-07-13) to use a sub-shell instead with less indirection. We did actually recover correctly if we failed in this function since we were wrapped in a subshell one function call up. Let's just use the sub-shell at the point where we want to change the directory instead. It's important that the "|| return 1" is outside the subshell. Normally, we `exit 1` from within subshells[1], but that wouldn't help us exit this loop early[1][2]. Since we can get rid of the wrapper function let's rename the main function to drop the "rec" (for "recursion") suffix[3]. 1. https://lore.kernel.org/git/CAPig+cToj8nQmyBCqC1k7DXF2vXaonCEA-fCJ4x7JBZG2ixYBw@mail.gmail.com/ 2. https://lore.kernel.org/git/20150325052952.GE31924@peff.net/ 3. https://lore.kernel.org/git/YARsCsgXuiXr4uFX@coredump.intra.peff.net/ Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh index 7ff7f04..5bb4f75 100755 --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@ -17,7 +17,7 @@ cmp_cache_tree () { # We don't bother with actually checking the SHA1: # test-tool dump-cache-tree already verifies that all existing data is # correct. -generate_expected_cache_tree_rec () { +generate_expected_cache_tree () { dir="$1${1:+/}" && # ls-files might have foo/bar, foo/bar/baz, and foo/bar/quux # We want to count only foo because it's the only direct child @@ -28,18 +28,13 @@ generate_expected_cache_tree_rec () { printf "SHA $dir (%d entries, %d subtrees)\n" "$entries" "$subtree_count" && for subtree in $subtrees do - cd "$subtree" - generate_expected_cache_tree_rec "$dir$subtree" || return 1 - cd .. + ( + cd "$subtree" && + generate_expected_cache_tree "$dir$subtree" + ) || return 1 done } -generate_expected_cache_tree () { - ( - generate_expected_cache_tree_rec - ) -} - test_cache_tree () { generate_expected_cache_tree >expect && cmp_cache_tree expect -- cgit v0.10.2-6-g49f6 From ef839700591743685159a0794d76a444a9070bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 23 Jan 2021 14:00:40 +0100 Subject: cache-tree tests: explicitly test HEAD and index differences MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test code added in 9c4d6c0297 (cache-tree: Write updated cache-tree after commit, 2014-07-13) used "ls-files" in lieu of "ls-tree" because it wanted to test the data in the index, since this test is testing the cache-tree extension. Change the test to instead use "ls-tree" for traversal, and then explicitly check how HEAD differs from the index. This is more easily understood, and less fragile as numerous past bug fixes[1][2][3] to the old code we're replacing demonstrate. As an aside this would be a bit easier if empty pathspecs hadn't been made an error in d426430e6e (pathspec: warn on empty strings as pathspec, 2016-06-22) and 9e4e8a64c2 (pathspec: die on empty strings as pathspec, 2017-06-06). If that was still allowed this code could be simplified slightly: diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh index 9bf66c9e68..0b02881f55 100755 --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@ -18,19 +18,18 @@ cmp_cache_tree () { # test-tool dump-cache-tree already verifies that all existing data is # correct. generate_expected_cache_tree () { - pathspec="$1" && - dir="$2${2:+/}" && + pathspec="$1${1:+/}" && git ls-tree --name-only HEAD -- "$pathspec" >files && git ls-tree --name-only -d HEAD -- "$pathspec" >subtrees && - printf "SHA %s (%d entries, %d subtrees)\n" "$dir" $(wc -l expect && + generate_expected_cache_tree >expect && cmp_cache_tree expect && rm expect actual files subtrees && git status --porcelain -- ':!status' ':!expected.status' >status && 1. c8db708d5d (t0090: avoid passing empty string to printf %d, 2014-09-30) 2. d69360c6b1 (t0090: tweak awk statement for Solaris /usr/xpg4/bin/awk, 2014-12-22) 3. 9b5a9fa60a (t0090: stop losing return codes of git commands, 2019-11-27) Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh index 5bb4f75..9bf66c9 100755 --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@ -18,26 +18,28 @@ cmp_cache_tree () { # test-tool dump-cache-tree already verifies that all existing data is # correct. generate_expected_cache_tree () { - dir="$1${1:+/}" && - # ls-files might have foo/bar, foo/bar/baz, and foo/bar/quux - # We want to count only foo because it's the only direct child - git ls-files >files && - subtrees=$(grep / files|cut -d / -f 1|uniq) && - subtree_count=$(echo "$subtrees"|awk -v c=0 '$1 != "" {++c} END {print c}') && - entries=$(wc -l files && + git ls-tree --name-only -d HEAD -- "$pathspec" >subtrees && + printf "SHA %s (%d entries, %d subtrees)\n" "$dir" $(wc -l expect && - cmp_cache_tree expect + generate_expected_cache_tree "." >expect && + cmp_cache_tree expect && + rm expect actual files subtrees && + git status --porcelain -- ':!status' ':!expected.status' >status && + if test -n "$1" + then + test_cmp "$1" status + else + test_must_be_empty status + fi } test_invalid_cache_tree () { @@ -126,6 +128,7 @@ test_expect_success 'second commit has cache-tree' ' ' test_expect_success PERL 'commit --interactive gives cache-tree on partial commit' ' + test_when_finished "git reset --hard" && cat <<-\EOT >foo.c && int foo() { @@ -152,7 +155,10 @@ test_expect_success PERL 'commit --interactive gives cache-tree on partial commi EOT test_write_lines p 1 "" s n y q | git commit --interactive -m foo && - test_cache_tree + cat <<-\EOF >expected.status && + M foo.c + EOF + test_cache_tree expected.status ' test_expect_success PERL 'commit -p with shrinking cache-tree' ' @@ -243,7 +249,10 @@ test_expect_success 'partial commit gives cache-tree' ' git add one.t && echo "some other change" >two.t && git commit two.t -m partial && - test_cache_tree + cat <<-\EOF >expected.status && + M one.t + EOF + test_cache_tree expected.status ' test_expect_success 'no phantom error when switching trees' ' -- cgit v0.10.2-6-g49f6 From 4669917e8f20c047974ee162c5ec3b28bb6016c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 23 Jan 2021 14:00:41 +0100 Subject: git svn mergeinfo tests: modernize redirection & quoting style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use " Signed-off-by: Junio C Hamano diff --git a/t/t9151-svn-mergeinfo.sh b/t/t9151-svn-mergeinfo.sh index 4f6c06e..59c5847 100755 --- a/t/t9151-svn-mergeinfo.sh +++ b/t/t9151-svn-mergeinfo.sh @@ -9,37 +9,37 @@ test_description='git-svn svn mergeinfo properties' test_expect_success 'load svn dump' " svnadmin load -q '$rawsvnrepo' \ - < '$TEST_DIRECTORY/t9151/svn-mergeinfo.dump' && + <'$TEST_DIRECTORY/t9151/svn-mergeinfo.dump' && git svn init --minimize-url -R svnmerge \ --rewrite-root=http://svn.example.org \ -T trunk -b branches '$svnrepo' && git svn fetch --all - " +" test_expect_success 'all svn merges became git merge commits' ' unmarked=$(git rev-list --parents --all --grep=Merge | grep -v " .* " | cut -f1 -d" ") && [ -z "$unmarked" ] - ' +' test_expect_success 'cherry picks did not become git merge commits' ' bad_cherries=$(git rev-list --parents --all --grep=Cherry | grep " .* " | cut -f1 -d" ") && [ -z "$bad_cherries" ] - ' +' test_expect_success 'svn non-merge merge commits did not become git merge commits' ' bad_non_merges=$(git rev-list --parents --all --grep=non-merge | grep " .* " | cut -f1 -d" ") && [ -z "$bad_non_merges" ] - ' +' test_expect_success 'commit made to merged branch is reachable from the merge' ' before_commit=$(git rev-list --all --grep="trunk commit before merging trunk to b2") && merge_commit=$(git rev-list --all --grep="Merge trunk to b2") && not_reachable=$(git rev-list -1 $before_commit --not $merge_commit) && [ -z "$not_reachable" ] - ' +' test_expect_success 'merging two branches in one commit is detected correctly' ' f1_commit=$(git rev-list --all --grep="make f1 branch from trunk") && @@ -47,11 +47,11 @@ test_expect_success 'merging two branches in one commit is detected correctly' ' merge_commit=$(git rev-list --all --grep="Merge f1 and f2 to trunk") && not_reachable=$(git rev-list -1 $f1_commit $f2_commit --not $merge_commit) && [ -z "$not_reachable" ] - ' +' test_expect_failure 'everything got merged in the end' ' unmerged=$(git rev-list --all --not master) && [ -z "$unmerged" ] - ' +' test_done -- cgit v0.10.2-6-g49f6 From f918a89e50d4e31fe5b2db979122e76992951bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 23 Jan 2021 14:00:42 +0100 Subject: git svn mergeinfo tests: refactor "test -z" to use test_must_be_empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor some old-style test code to use test_must_be_empty instead of "test -z". This makes a follow-up commit easier to read. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano diff --git a/t/t9151-svn-mergeinfo.sh b/t/t9151-svn-mergeinfo.sh index 59c5847..806eff4 100755 --- a/t/t9151-svn-mergeinfo.sh +++ b/t/t9151-svn-mergeinfo.sh @@ -17,41 +17,42 @@ test_expect_success 'load svn dump' " " test_expect_success 'all svn merges became git merge commits' ' - unmarked=$(git rev-list --parents --all --grep=Merge | - grep -v " .* " | cut -f1 -d" ") && - [ -z "$unmarked" ] + git rev-list --parents --all --grep=Merge | + grep -v " .* " | cut -f1 -d" " >unmarked && + test_must_be_empty unmarked ' + test_expect_success 'cherry picks did not become git merge commits' ' - bad_cherries=$(git rev-list --parents --all --grep=Cherry | - grep " .* " | cut -f1 -d" ") && - [ -z "$bad_cherries" ] + git rev-list --parents --all --grep=Cherry | + grep " .* " | cut -f1 -d" " >bad-cherries && + test_must_be_empty bad-cherries ' test_expect_success 'svn non-merge merge commits did not become git merge commits' ' - bad_non_merges=$(git rev-list --parents --all --grep=non-merge | - grep " .* " | cut -f1 -d" ") && - [ -z "$bad_non_merges" ] + git rev-list --parents --all --grep=non-merge | + grep " .* " | cut -f1 -d" " >bad-non-merges && + test_must_be_empty bad-non-merges ' test_expect_success 'commit made to merged branch is reachable from the merge' ' before_commit=$(git rev-list --all --grep="trunk commit before merging trunk to b2") && merge_commit=$(git rev-list --all --grep="Merge trunk to b2") && - not_reachable=$(git rev-list -1 $before_commit --not $merge_commit) && - [ -z "$not_reachable" ] + git rev-list -1 $before_commit --not $merge_commit >not-reachable && + test_must_be_empty not-reachable ' test_expect_success 'merging two branches in one commit is detected correctly' ' f1_commit=$(git rev-list --all --grep="make f1 branch from trunk") && f2_commit=$(git rev-list --all --grep="make f2 branch from trunk") && merge_commit=$(git rev-list --all --grep="Merge f1 and f2 to trunk") && - not_reachable=$(git rev-list -1 $f1_commit $f2_commit --not $merge_commit) && - [ -z "$not_reachable" ] + git rev-list -1 $f1_commit $f2_commit --not $merge_commit >not-reachable && + test_must_be_empty not-reachable ' test_expect_failure 'everything got merged in the end' ' - unmerged=$(git rev-list --all --not master) && - [ -z "$unmerged" ] + git rev-list --all --not master >unmerged && + test_must_be_empty unmerged ' test_done -- cgit v0.10.2-6-g49f6 From 796c248dc1eeaa99cf8074c30dec3ce7642f811e Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sat, 23 Jan 2021 14:00:43 +0100 Subject: git-svn tests: rewrite brittle tests to use "--[no-]merges". MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rewrite a brittle tests which used "rev-list" without "--[no-]merges" to figure out if a set of commits turned into merge commits or not. Signed-off-by: Jeff King [ÆAB: wrote commit message] Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano diff --git a/t/t9151-svn-mergeinfo.sh b/t/t9151-svn-mergeinfo.sh index 806eff4..c33bae9 100755 --- a/t/t9151-svn-mergeinfo.sh +++ b/t/t9151-svn-mergeinfo.sh @@ -17,21 +17,17 @@ test_expect_success 'load svn dump' " " test_expect_success 'all svn merges became git merge commits' ' - git rev-list --parents --all --grep=Merge | - grep -v " .* " | cut -f1 -d" " >unmarked && + git rev-list --all --no-merges --grep=Merge >unmarked && test_must_be_empty unmarked ' - test_expect_success 'cherry picks did not become git merge commits' ' - git rev-list --parents --all --grep=Cherry | - grep " .* " | cut -f1 -d" " >bad-cherries && + git rev-list --all --merges --grep=Cherry >bad-cherries && test_must_be_empty bad-cherries ' test_expect_success 'svn non-merge merge commits did not become git merge commits' ' - git rev-list --parents --all --grep=non-merge | - grep " .* " | cut -f1 -d" " >bad-non-merges && + git rev-list --all --merges --grep=non-merge >bad-non-merges && test_must_be_empty bad-non-merges ' -- cgit v0.10.2-6-g49f6 From 9aebc4708ad21cc18f6d5c6909381abb0fe01023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 23 Jan 2021 14:00:44 +0100 Subject: upload-pack tests: avoid a non-zero "grep" exit status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Continue changing a test that 763b47bafa (t5703: stop losing return codes of git commands, 2019-11-27) already refactored. This was originally added as part of a series to add support for running under bash's "set -o pipefail", under that mode this test will fail because sometimes there's no commits in the "objs" output. It's easier to fix that than exempt these tests under a hypothetical "set -o pipefail" test mode. It looks like we probably won't have that, but once we've dug this code up let's refactor it[2] so we don't hide a potential pipe failure. 1. https://lore.kernel.org/git/xmqqzh18o8o6.fsf@gitster.c.googlers.com/ Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh index eab9669..5d825b1 100755 --- a/t/t5703-upload-pack-ref-in-want.sh +++ b/t/t5703-upload-pack-ref-in-want.sh @@ -16,7 +16,8 @@ get_actual_commits () { test-tool pkt-line unpack-sideband o.pack && git index-pack o.pack && git verify-pack -v o.idx >objs && - grep commit objs | cut -d" " -f1 | sort >actual_commits + sed -n -e 's/\([0-9a-f][0-9a-f]*\) commit .*/\1/p' objs >objs.sed && + sort >actual_commits Date: Sat, 23 Jan 2021 14:00:45 +0100 Subject: archive tests: use a cheaper "zipinfo -h" invocation to get header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change an invocation of zipinfo added in 19ee29401d (t5004: test ZIP archives with many entries, 2015-08-22) to simply ask zipinfo for the header info, rather than spewing out info about the entire archive and race to kill it with SIGPIPE due to the downstream "head -2". I ran across this because I'm adding a "set -o pipefail" test mode. This won't be needed for the version of the mode that I'm introducing (which currently relies on a patch to GNU bash), but I think this is a good idea anyway. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh index 3e7b23c..2d32d0e 100755 --- a/t/t5004-archive-corner-cases.sh +++ b/t/t5004-archive-corner-cases.sh @@ -153,7 +153,8 @@ test_expect_success ZIPINFO 'zip archive with many entries' ' # check the number of entries in the ZIP file directory expr 65536 + 256 >expect && - "$ZIPINFO" many.zip | head -2 | sed -n "2s/.* //p" >actual && + "$ZIPINFO" -h many.zip >zipinfo && + sed -n "2s/.* //p" actual && test_cmp expect actual ' -- cgit v0.10.2-6-g49f6 From db89a82b5b24fbe21ad273c8d8b442eef59aadd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 23 Jan 2021 14:00:46 +0100 Subject: rm tests: actually test for SIGPIPE in SIGPIPE test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change a test initially added in 50cd31c652 (t3600: comment on inducing SIGPIPE in `git rm`, 2019-11-27) to explicitly test for SIGPIPE using a pattern initially established in 7559a1be8a (unblock and unignore SIGPIPE, 2014-09-18). The problem with using that pattern is that it requires us to skip the test on MINGW[1]. If we kept the test with its initial semantics[2] we'd get coverage there, at the cost of not checking whether we actually had SIGPIPE outside of MinGW. Arguably we should just remove this test. Between the test added in 7559a1be8a and the change made in 12e0437f23 (common-main: call restore_sigpipe_to_default(), 2016-07-01) it's a bit arbitrary to only check this for "git rm". But in lieu of having wider test coverage for other "git" subcommands let's refactor this to explicitly test for SIGPIPE outside of MinGW, and then just that we remove the ".git/index.lock" (as before) on all platforms. 1. https://lore.kernel.org/git/xmqq1rec5ckf.fsf@gitster.c.googlers.com/ 2. 0693f9ddad (Make sure lockfiles are unlocked when dying on SIGPIPE, 2008-12-18) Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index efec8d1..185e39c 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -240,7 +240,7 @@ test_expect_success 'refresh index before checking if it is up-to-date' ' test_path_is_missing frotz/nitfol ' -test_expect_success 'choking "git rm" should not let it die with cruft' ' +choke_git_rm_setup() { git reset -q --hard && test_when_finished "rm -f .git/index.lock && git reset -q --hard" && i=0 && @@ -249,12 +249,24 @@ test_expect_success 'choking "git rm" should not let it die with cruft' ' do echo "100644 $hash 0 some-file-$i" i=$(( $i + 1 )) - done | git update-index --index-info && + done | git update-index --index-info +} + +test_expect_success 'choking "git rm" should not let it die with cruft (induce SIGPIPE)' ' + choke_git_rm_setup && # git command is intentionally placed upstream of pipe to induce SIGPIPE git rm -n "some-file-*" | : && test_path_is_missing .git/index.lock ' + +test_expect_success !MINGW 'choking "git rm" should not let it die with cruft (induce and check SIGPIPE)' ' + choke_git_rm_setup && + OUT=$( ((trap "" PIPE; git rm -n "some-file-*"; echo $? 1>&3) | :) 3>&1 ) && + test_match_signal 13 "$OUT" && + test_path_is_missing .git/index.lock +' + test_expect_success 'Resolving by removal is not a warning-worthy event' ' git reset -q --hard && test_when_finished "rm -f .git/index.lock msg && git reset -q --hard" && -- cgit v0.10.2-6-g49f6