{"thread":{"id":"52539","subject":"[PATCH 0/1] t: add tests for error conditions with --pathspec-from-file","startedAt":"2019-12-30T15:38:42Z","lastAt":"2019-12-30T15:38:43Z","messageCount":2,"participants":["Alexandr Miloslavskiy via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"389065","messageId":"pull.502.git.1577720318.gitgitgadget@gmail.com","threadId":"52539","inReplyTo":null,"subject":"[PATCH 0/1] t: add tests for error conditions with --pathspec-from-file","fromName":"Alexandr Miloslavskiy via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-12-30T15:38:37Z","receivedAt":"2019-12-30T15:38:42Z","isPatch":true,"sender":{"key":"alexandr.miloslavskiy@syntevo.com","avatar":null},"body":"This patch adds tests for various cases where using `--pathspec-from-file` would result in a git error, such as using incompatible options.\n\nThis branch is a follow-up for [1] where part of branch was merged into `master` via [2].\nThe idea for these tests is from [3] where another error condition was added together with a test.\n\n[1] https://lore.kernel.org/git/pull.490.git.1576161385.gitgitgadget@gmail.com/\n[2] https://public-inbox.org/git/pull.445.v4.git.1575381738.gitgitgadget@gmail.com/\n[3] https://public-inbox.org/git/4401823b-8039-99b4-2436-ed2f1a571d78@gmail.com/\n\nAlexandr Miloslavskiy (1):\n  t: add tests for error conditions with --pathspec-from-file\n\n t/t2026-checkout-pathspec-file.sh | 17 +++++++++++++++++\n t/t2072-restore-pathspec-file.sh  | 18 ++++++++++++++++++\n t/t3704-add-pathspec-file.sh      | 25 +++++++++++++++++++++++++\n t/t7107-reset-pathspec-file.sh    | 30 +++++++++++++++++++++---------\n t/t7526-commit-pathspec-file.sh   | 27 ++++++++++++++++++++++++---\n 5 files changed, 105 insertions(+), 12 deletions(-)\n\n\nbase-commit: 0a76bd7381ec0dbb7c43776eb6d1ac906bca29e6\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-502%2FSyntevoAlex%2F%230207(git)_2a_test_error_conditions-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-502/SyntevoAlex/#0207(git)_2a_test_error_conditions-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/502\n-- \ngitgitgadget\n"},{"id":"389066","messageId":"7a30d7ef0c556ddc743ae53afc871c26e800ce1f.1577720318.git.gitgitgadget@gmail.com","threadId":"52539","inReplyTo":"pull.502.git.1577720318.gitgitgadget@gmail.com","subject":"[PATCH 1/1] t: add tests for error conditions with --pathspec-from-file","fromName":"Alexandr Miloslavskiy via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-12-30T15:38:38Z","receivedAt":"2019-12-30T15:38:43Z","isPatch":true,"sender":{"key":"alexandr.miloslavskiy@syntevo.com","avatar":null},"body":"From: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>\n\nAlso move some old tests into the new tests: it doesn't seem reasonable\nto have individual error condition tests.\n\nOld test for `git commit` was corrected, previously it was instructed\nto use stdin but wasn't provided with any stdin. While this works at\nthe moment, it's not exactly perfect.\n\nOld tests for `git reset` were improved to test for a specific error\nmessage.\n\nSuggested-By: Phillip Wood <phillip.wood@dunelm.org.uk>\nSigned-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>\n---\n t/t2026-checkout-pathspec-file.sh | 17 +++++++++++++++++\n t/t2072-restore-pathspec-file.sh  | 18 ++++++++++++++++++\n t/t3704-add-pathspec-file.sh      | 25 +++++++++++++++++++++++++\n t/t7107-reset-pathspec-file.sh    | 30 +++++++++++++++++++++---------\n t/t7526-commit-pathspec-file.sh   | 27 ++++++++++++++++++++++++---\n 5 files changed, 105 insertions(+), 12 deletions(-)\n\ndiff --git a/t/t2026-checkout-pathspec-file.sh b/t/t2026-checkout-pathspec-file.sh\nindex f62fd27440..0926312370 100755\n--- a/t/t2026-checkout-pathspec-file.sh\n+++ b/t/t2026-checkout-pathspec-file.sh\n@@ -136,4 +136,21 @@ test_expect_success 'only touches what was listed' '\n \tverify_expect\n '\n \n+test_expect_success 'error conditions' '\n+\trestore_checkpoint &&\n+\techo fileA.t >list &&\n+\n+\ttest_must_fail git checkout --pathspec-from-file=list --detach 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file is incompatible with --detach\" err &&\n+\n+\ttest_must_fail git checkout --pathspec-from-file=list --patch 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file is incompatible with --patch\" err &&\n+\n+\ttest_must_fail git checkout --pathspec-from-file=list -- fileA.t 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file is incompatible with pathspec arguments\" err &&\n+\n+\ttest_must_fail git checkout --pathspec-file-nul 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-file-nul requires --pathspec-from-file\" err\n+'\n+\n test_done\ndiff --git a/t/t2072-restore-pathspec-file.sh b/t/t2072-restore-pathspec-file.sh\nindex db58e83735..5c7abbbce3 100755\n--- a/t/t2072-restore-pathspec-file.sh\n+++ b/t/t2072-restore-pathspec-file.sh\n@@ -136,4 +136,22 @@ test_expect_success 'only touches what was listed' '\n \tverify_expect\n '\n \n+test_expect_success 'error conditions' '\n+\trestore_checkpoint &&\n+\techo fileA.t >list &&\n+\t>empty_list &&\n+\n+\ttest_must_fail git restore --pathspec-from-file=list --patch --source=HEAD^1 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file is incompatible with --patch\" err &&\n+\n+\ttest_must_fail git restore --pathspec-from-file=list --source=HEAD^1 -- fileA.t 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file is incompatible with pathspec arguments\" err &&\n+\n+\ttest_must_fail git restore --pathspec-file-nul --source=HEAD^1 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-file-nul requires --pathspec-from-file\" err &&\n+\n+\ttest_must_fail git restore --pathspec-from-file=empty_list --source=HEAD^1 2>err &&\n+\ttest_i18ngrep -e \"you must specify path(s) to restore\" err\n+'\n+\n test_done\ndiff --git a/t/t3704-add-pathspec-file.sh b/t/t3704-add-pathspec-file.sh\nindex 3cfdb669b7..a1696e1a39 100755\n--- a/t/t3704-add-pathspec-file.sh\n+++ b/t/t3704-add-pathspec-file.sh\n@@ -124,4 +124,29 @@ test_expect_success 'only touches what was listed' '\n \tverify_expect\n '\n \n+test_expect_success 'error conditions' '\n+\trestore_checkpoint &&\n+\techo fileA.t >list &&\n+\t>empty_list &&\n+\n+\ttest_must_fail git add --pathspec-from-file=list --interactive 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file is incompatible with --interactive/--patch\" err &&\n+\n+\ttest_must_fail git add --pathspec-from-file=list --patch 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file is incompatible with --interactive/--patch\" err &&\n+\n+\ttest_must_fail git add --pathspec-from-file=list --edit 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file is incompatible with --edit\" err &&\n+\n+\ttest_must_fail git add --pathspec-from-file=list -- fileA.t 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file is incompatible with pathspec arguments\" err &&\n+\n+\ttest_must_fail git add --pathspec-file-nul 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-file-nul requires --pathspec-from-file\" err &&\n+\n+\t# This case succeeds, but still prints to stderr\n+\tgit add --pathspec-from-file=empty_list 2>err &&\n+\ttest_i18ngrep -e \"Nothing specified, nothing added.\" err\n+'\n+\n test_done\ndiff --git a/t/t7107-reset-pathspec-file.sh b/t/t7107-reset-pathspec-file.sh\nindex 6b1a731fff..975a9a930a 100755\n--- a/t/t7107-reset-pathspec-file.sh\n+++ b/t/t7107-reset-pathspec-file.sh\n@@ -128,15 +128,6 @@ test_expect_success 'quotes not compatible with --pathspec-file-nul' '\n \ttest_must_fail verify_expect\n '\n \n-test_expect_success '--pathspec-from-file is not compatible with --soft or --hard' '\n-\trestore_checkpoint &&\n-\n-\tgit rm fileA.t &&\n-\techo fileA.t >list &&\n-\ttest_must_fail git reset --soft --pathspec-from-file=list &&\n-\ttest_must_fail git reset --hard --pathspec-from-file=list\n-'\n-\n test_expect_success 'only touches what was listed' '\n \trestore_checkpoint &&\n \n@@ -152,4 +143,25 @@ test_expect_success 'only touches what was listed' '\n \tverify_expect\n '\n \n+test_expect_success 'error conditions' '\n+\trestore_checkpoint &&\n+\techo fileA.t >list &&\n+\tgit rm fileA.t &&\n+\n+\ttest_must_fail git reset --pathspec-from-file=list --patch 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file is incompatible with --patch\" err &&\n+\n+\ttest_must_fail git reset --pathspec-from-file=list -- fileA.t 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file is incompatible with pathspec arguments\" err &&\n+\n+\ttest_must_fail git reset --pathspec-file-nul 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-file-nul requires --pathspec-from-file\" err &&\n+\n+\ttest_must_fail git reset --soft --pathspec-from-file=list 2>err &&\n+\ttest_i18ngrep -e \"fatal: Cannot do soft reset with paths\" err &&\n+\n+\ttest_must_fail git reset --hard --pathspec-from-file=list 2>err &&\n+\ttest_i18ngrep -e \"fatal: Cannot do hard reset with paths\" err\n+'\n+\n test_done\ndiff --git a/t/t7526-commit-pathspec-file.sh b/t/t7526-commit-pathspec-file.sh\nindex 4b58901ed6..336197449f 100755\n--- a/t/t7526-commit-pathspec-file.sh\n+++ b/t/t7526-commit-pathspec-file.sh\n@@ -127,10 +127,31 @@ test_expect_success 'only touches what was listed' '\n \tverify_expect\n '\n \n-test_expect_success '--pathspec-from-file and --all cannot be used together' '\n+test_expect_success 'error conditions' '\n \trestore_checkpoint &&\n-\ttest_must_fail git commit --pathspec-from-file=- --all -m \"Commit\" 2>err &&\n-\ttest_i18ngrep \"[-]-pathspec-from-file with -a does not make sense\" err\n+\techo fileA.t >list &&\n+\t>empty_list &&\n+\n+\ttest_must_fail git commit --pathspec-from-file=list --interactive -m \"Commit\" 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file is incompatible with --interactive/--patch\" err &&\n+\n+\ttest_must_fail git commit --pathspec-from-file=list --patch -m \"Commit\" 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file is incompatible with --interactive/--patch\" err &&\n+\n+\ttest_must_fail git commit --pathspec-from-file=list --all -m \"Commit\" 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file with -a does not make sense\" err &&\n+\n+\ttest_must_fail git commit --pathspec-from-file=list -m \"Commit\" -- fileA.t 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-from-file is incompatible with pathspec arguments\" err &&\n+\n+\ttest_must_fail git commit --pathspec-file-nul -m \"Commit\" 2>err &&\n+\ttest_i18ngrep -e \"--pathspec-file-nul requires --pathspec-from-file\" err &&\n+\n+\ttest_must_fail git commit --pathspec-from-file=empty_list --include -m \"Commit\" 2>err &&\n+\ttest_i18ngrep -e \"No paths with --include/--only does not make sense.\" err &&\n+\n+\ttest_must_fail git commit --pathspec-from-file=empty_list --only -m \"Commit\" 2>err &&\n+\ttest_i18ngrep -e \"No paths with --include/--only does not make sense.\" err\n '\n \n test_done\n-- \ngitgitgadget\n"}]}