Merge branch 'sb/t3600-cleanup'
authorJunio C Hamano <gitster@pobox.com>
Mon, 19 Dec 2016 22:45:39 +0000 (14:45 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 19 Dec 2016 22:45:40 +0000 (14:45 -0800)
Code cleanup.

* sb/t3600-cleanup:
t3600: slightly modernize style
t3600: remove useless redirect

1  2 
t/t3600-rm.sh
diff --combined t/t3600-rm.sh
index 14f0edca2b6f67e6ae98379702b5566e4083d8e0,66092f042dfe64706b8257ab89359bf24efd475e..bcbb68065113f6a2032a3879fabb3353c42e79d0
@@@ -14,7 -14,7 +14,7 @@@ test_expect_success 
       git add -- foo bar baz 'space embedded' -q &&
       git commit -m 'add normal files'"
  
 -if touch -- 'tab      embedded' 'newline
 +if test_have_prereq !MINGW && touch -- 'tab   embedded' 'newline
  embedded' 2>/dev/null
  then
        test_set_prereq FUNNYNAMES
@@@ -38,37 -38,37 +38,37 @@@ test_expect_success 
  
  test_expect_success \
      'Test that git rm --cached foo succeeds if the index matches the file' \
 -    'echo content > foo
 -     git add foo
 +    'echo content >foo &&
 +     git add foo &&
       git rm --cached foo'
  
  test_expect_success \
      'Test that git rm --cached foo succeeds if the index matches the file' \
 -    'echo content > foo
 -     git add foo
 -     git commit -m foo
 -     echo "other content" > foo
 +    'echo content >foo &&
 +     git add foo &&
 +     git commit -m foo &&
 +     echo "other content" >foo &&
       git rm --cached foo'
  
  test_expect_success \
      'Test that git rm --cached foo fails if the index matches neither the file nor HEAD' '
 -     echo content > foo
 -     git add foo
 -     git commit -m foo
 -     echo "other content" > foo
 -     git add foo
 -     echo "yet another content" > foo
 +     echo content >foo &&
 +     git add foo &&
 +     git commit -m foo --allow-empty &&
 +     echo "other content" >foo &&
 +     git add foo &&
 +     echo "yet another content" >foo &&
       test_must_fail git rm --cached foo
  '
  
  test_expect_success \
      'Test that git rm --cached -f foo works in case where --cached only did not' \
 -    'echo content > foo
 -     git add foo
 -     git commit -m foo
 -     echo "other content" > foo
 -     git add foo
 -     echo "yet another content" > foo
 +    'echo content >foo &&
 +     git add foo &&
 +     git commit -m foo --allow-empty &&
 +     echo "other content" >foo &&
 +     git add foo &&
 +     echo "yet another content" >foo &&
       git rm --cached -f foo'
  
  test_expect_success \
@@@ -111,21 -111,21 +111,21 @@@ test_expect_success 'Remove nonexisten
  '
  
  test_expect_success '"rm" command printed' '
-       echo frotz > test-file &&
+       echo frotz >test-file &&
        git add test-file &&
        git commit -m "add file for rm test" &&
-       git rm test-file > rm-output &&
+       git rm test-file >rm-output &&
        test $(grep "^rm " rm-output | wc -l) = 1 &&
        rm -f test-file rm-output &&
        git commit -m "remove file from rm test"
  '
  
  test_expect_success '"rm" command suppressed with --quiet' '
-       echo frotz > test-file &&
+       echo frotz >test-file &&
        git add test-file &&
        git commit -m "add file for rm --quiet test" &&
-       git rm --quiet test-file > rm-output &&
-       test $(wc -l < rm-output) = 0 &&
+       git rm --quiet test-file >rm-output &&
+       test_must_be_empty rm-output &&
        rm -f test-file rm-output &&
        git commit -m "remove file from rm --quiet test"
  '
@@@ -170,7 -170,7 +170,7 @@@ test_expect_success 'but with -f it sho
        git rm -f foo baz &&
        test ! -f foo &&
        test ! -f baz &&
 -      test_must_fail git ls-files --error-unmatch foo
 +      test_must_fail git ls-files --error-unmatch foo &&
        test_must_fail git ls-files --error-unmatch baz
  '
  
@@@ -183,7 -183,7 +183,7 @@@ test_expect_success 'refuse to remove c
  
  test_expect_success 'remove intent-to-add file without --force' '
        echo content >intent-to-add &&
 -      git add -N intent-to-add
 +      git add -N intent-to-add &&
        git rm --cached intent-to-add
  '
  
@@@ -201,7 -201,7 +201,7 @@@ test_expect_success 'Recursive without 
  '
  
  test_expect_success 'Recursive with -r but dirty' '
 -      echo qfwfq >>frotz/nitfol
 +      echo qfwfq >>frotz/nitfol &&
        test_must_fail git rm -r frotz &&
        test -d frotz &&
        test -f frotz/nitfol
@@@ -221,7 -221,7 +221,7 @@@ test_expect_success 'Call "rm" from out
        mkdir repo &&
        (cd repo &&
         git init &&
-        echo something > somefile &&
+        echo something >somefile &&
         git add somefile &&
         git commit -m "add a file" &&
         (cd .. &&
@@@ -287,7 -287,7 +287,7 @@@ test_expect_success 'rm removes empty s
        git commit -m "add submodule" &&
        git rm submod &&
        test ! -e submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual &&
        test_must_fail git config -f .gitmodules submodule.sub.url &&
        test_must_fail git config -f .gitmodules submodule.sub.path
@@@ -298,7 -298,7 +298,7 @@@ test_expect_success 'rm removes remove
        git submodule update &&
        rm -rf submod &&
        git rm submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual &&
        test_must_fail git config -f .gitmodules submodule.sub.url &&
        test_must_fail git config -f .gitmodules submodule.sub.path
@@@ -309,7 -309,7 +309,7 @@@ test_expect_success 'rm removes work tr
        git submodule update &&
        git rm submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual &&
        test_must_fail git config -f .gitmodules submodule.sub.url &&
        test_must_fail git config -f .gitmodules submodule.sub.path
@@@ -320,7 -320,7 +320,7 @@@ test_expect_success 'rm removes a submo
        git submodule update &&
        git rm submod/ &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
  '
  
@@@ -335,17 -335,15 +335,15 @@@ test_expect_success 'rm succeeds when g
  test_expect_success 'rm of a populated submodule with different HEAD fails unless forced' '
        git reset --hard &&
        git submodule update &&
-       (cd submod &&
-               git checkout HEAD^
-       ) &&
+       git -C submod checkout HEAD^ &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.modified actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual &&
        test_must_fail git config -f .gitmodules submodule.sub.url &&
        test_must_fail git config -f .gitmodules submodule.sub.path
@@@ -418,34 -416,30 +416,30 @@@ test_expect_success 'rm issues a warnin
  test_expect_success 'rm of a populated submodule with modifications fails unless forced' '
        git reset --hard &&
        git submodule update &&
-       (cd submod &&
-               echo X >empty
-       ) &&
+       echo X >submod/empty &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.modified actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
  '
  
  test_expect_success 'rm of a populated submodule with untracked files fails unless forced' '
        git reset --hard &&
        git submodule update &&
-       (cd submod &&
-               echo X >untracked
-       ) &&
+       echo X >submod/untracked &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.modified actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
  '
  
@@@ -461,16 -455,12 +455,12 @@@ test_expect_success 'setup submodule co
        git add nitfol &&
        git commit -m "added nitfol 2" &&
        git checkout -b conflict1 master &&
-       (cd submod &&
-               git fetch &&
-               git checkout branch1
-       ) &&
+       git -C submod fetch &&
+       git -C submod checkout branch1 &&
        git add submod &&
        git commit -m "submod 1" &&
        git checkout -b conflict2 master &&
-       (cd submod &&
-               git checkout branch2
-       ) &&
+       git -C submod checkout branch2 &&
        git add submod &&
        git commit -m "submod 2"
  '
@@@ -486,7 -476,7 +476,7 @@@ test_expect_success 'rm removes work tr
        test_must_fail git merge conflict2 &&
        git rm submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
  '
  
@@@ -494,18 -484,16 +484,16 @@@ test_expect_success 'rm of a conflicte
        git checkout conflict1 &&
        git reset --hard &&
        git submodule update &&
-       (cd submod &&
-               git checkout HEAD^
-       ) &&
+       git -C submod checkout HEAD^ &&
        test_must_fail git merge conflict2 &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.conflict actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual &&
        test_must_fail git config -f .gitmodules submodule.sub.url &&
        test_must_fail git config -f .gitmodules submodule.sub.path
@@@ -515,18 -503,16 +503,16 @@@ test_expect_success 'rm of a conflicte
        git checkout conflict1 &&
        git reset --hard &&
        git submodule update &&
-       (cd submod &&
-               echo X >empty
-       ) &&
+       echo X >submod/empty &&
        test_must_fail git merge conflict2 &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.conflict actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual &&
        test_must_fail git config -f .gitmodules submodule.sub.url &&
        test_must_fail git config -f .gitmodules submodule.sub.path
@@@ -536,18 -522,16 +522,16 @@@ test_expect_success 'rm of a conflicte
        git checkout conflict1 &&
        git reset --hard &&
        git submodule update &&
-       (cd submod &&
-               echo X >untracked
-       ) &&
+       echo X >submod/untracked &&
        test_must_fail git merge conflict2 &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.conflict actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
  '
  
@@@ -564,12 -548,12 +548,12 @@@ test_expect_success 'rm of a conflicte
        test_must_fail git rm submod &&
        test -d submod &&
        test -d submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.conflict actual &&
        test_must_fail git rm -f submod &&
        test -d submod &&
        test -d submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.conflict actual &&
        git merge --abort &&
        rm -rf submod
@@@ -581,7 -565,7 +565,7 @@@ test_expect_success 'rm of a conflicte
        test_must_fail git merge conflict2 &&
        git rm submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
  '
  
@@@ -597,12 -581,12 +581,12 @@@ test_expect_success 'rm of a populated 
        test_must_fail git rm submod &&
        test -d submod &&
        test -d submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        ! test -s actual &&
        test_must_fail git rm -f submod &&
        test -d submod &&
        test -d submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        ! test -s actual &&
        rm -rf submod
  '
@@@ -629,58 -613,52 +613,52 @@@ test_expect_success 'setup subsubmodule
  test_expect_success 'rm recursively removes work tree of unmodified submodules' '
        git rm submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
  '
  
  test_expect_success 'rm of a populated nested submodule with different nested HEAD fails unless forced' '
        git reset --hard &&
        git submodule update --recursive &&
-       (cd submod/subsubmod &&
-               git checkout HEAD^
-       ) &&
+       git -C submod/subsubmod checkout HEAD^ &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.modified actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
  '
  
  test_expect_success 'rm of a populated nested submodule with nested modifications fails unless forced' '
        git reset --hard &&
        git submodule update --recursive &&
-       (cd submod/subsubmod &&
-               echo X >empty
-       ) &&
+       echo X >submod/subsubmod/empty &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.modified actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
  '
  
  test_expect_success 'rm of a populated nested submodule with nested untracked files fails unless forced' '
        git reset --hard &&
        git submodule update --recursive &&
-       (cd submod/subsubmod &&
-               echo X >untracked
-       ) &&
+       echo X >submod/subsubmod/untracked &&
        test_must_fail git rm submod &&
        test -d submod &&
        test -f submod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect.modified actual &&
        git rm -f submod &&
        test ! -d submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        test_cmp expect actual
  '
  
@@@ -695,12 -673,12 +673,12 @@@ test_expect_success 'rm of a populated 
        test_must_fail git rm submod &&
        test -d submod &&
        test -d submod/subsubmod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        ! test -s actual &&
        test_must_fail git rm -f submod &&
        test -d submod &&
        test -d submod/subsubmod/.git &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        ! test -s actual &&
        rm -rf submod
  '
@@@ -709,14 -687,15 +687,14 @@@ test_expect_success 'checking out a com
        git commit -m "submodule removal" submod &&
        git checkout HEAD^ &&
        git submodule update &&
-       git checkout -q HEAD^ 2>actual &&
+       git checkout -q HEAD^ &&
        git checkout -q master 2>actual &&
 -      echo "warning: unable to rmdir submod: Directory not empty" >expected &&
 -      test_i18ncmp expected actual &&
 +      test_i18ngrep "^warning: unable to rmdir submod:" actual &&
        git status -s submod >actual &&
        echo "?? submod/" >expected &&
        test_cmp expected actual &&
        rm -rf submod &&
-       git status -s -uno --ignore-submodules=none > actual &&
+       git status -s -uno --ignore-submodules=none >actual &&
        ! test -s actual
  '
  
@@@ -881,9 -860,4 +859,9 @@@ test_expect_success 'rm files with two 
        test_i18ncmp expect actual
  '
  
 +test_expect_success 'rm empty string should invoke warning' '
 +      git rm -rf "" 2>output &&
 +      test_i18ngrep "warning: empty strings" output
 +'
 +
  test_done