]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t2072-restore-pathspec-file.sh
The sixth batch
[thirdparty/git.git] / t / t2072-restore-pathspec-file.sh
index db58e83735080269a85f80716678ab19838c434b..0d47946e8a9b06f044542e373f3de477e53e3261 100755 (executable)
@@ -109,7 +109,11 @@ test_expect_success 'CRLF delimiters' '
 test_expect_success 'quotes' '
        restore_checkpoint &&
 
-       printf "\"file\\101.t\"" | git restore --pathspec-from-file=- --source=HEAD^1 &&
+       cat >list <<-\EOF &&
+       "file\101.t"
+       EOF
+
+       git restore --pathspec-from-file=list --source=HEAD^1 &&
 
        cat >expect <<-\EOF &&
         M fileA.t
@@ -120,7 +124,10 @@ test_expect_success 'quotes' '
 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
        restore_checkpoint &&
 
-       printf "\"file\\101.t\"" >list &&
+       cat >list <<-\EOF &&
+       "file\101.t"
+       EOF
+
        test_must_fail git restore --pathspec-from-file=list --pathspec-file-nul --source=HEAD^1
 '
 
@@ -136,4 +143,22 @@ test_expect_success 'only touches what was listed' '
        verify_expect
 '
 
+test_expect_success 'error conditions' '
+       restore_checkpoint &&
+       echo fileA.t >list &&
+       >empty_list &&
+
+       test_must_fail git restore --pathspec-from-file=list --patch --source=HEAD^1 2>err &&
+       test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err &&
+
+       test_must_fail git restore --pathspec-from-file=list --source=HEAD^1 -- fileA.t 2>err &&
+       test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
+
+       test_must_fail git restore --pathspec-file-nul --source=HEAD^1 2>err &&
+       test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err &&
+
+       test_must_fail git restore --pathspec-from-file=empty_list --source=HEAD^1 2>err &&
+       test_i18ngrep -e "you must specify path(s) to restore" err
+'
+
 test_done