Message ID | c7cd46d3a3bcbf4a5cfe2aa6aa71b3713801892b.1576511287.git.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Extend --pathspec-from-file to git add, checkout | expand |
"Alexandr Miloslavskiy via GitGitGadget" <gitgitgadget@gmail.com> writes: > + test_must_fail git commit --pathspec-from-file=- --interactive -m "Commit" <list 2>err && > + test_i18ngrep "\-\-pathspec-from-file is incompatible with \-\-interactive/\-\-patc h" err && What's with the overly-noisy quoting of dashes here? To match a string that happens to begin with a dash, either one of $ grep -e "-this string begins with and has-many-dashes-in-it" file $ grep "[-]this string begins with and has-many-dashes-in-it" file would be sufficient and more idiomatic. Or am I missing some other reason why the test is written this way? > + test_must_fail git commit --pathspec-from-file=- --patch -m "Commit" <list 2>err && > + test_i18ngrep "\-\-pathspec-from-file is incompatible with \-\-interactive/\-\-patch" err && > + > + test_must_fail git commit --pathspec-from-file=- -m "Commit" -- fileA.t <list 2>err && > + test_i18ngrep "\-\-pathspec-from-file is incompatible with pathspec arguments" err && > + > + test_must_fail git commit --pathspec-file-nul -m "Commit" 2>err && > + test_i18ngrep "\-\-pathspec-file-nul requires \-\-pathspec-from-file" err && > + > + test_must_fail git commit --pathspec-from-file=- --include -m "Commit" <empty_list 2>err && > + test_i18ngrep "No paths with \-\-include/\-\-only does not make sense." err && > + > + test_must_fail git commit --pathspec-from-file=- --only -m "Commit" <empty_list 2>err && > + test_i18ngrep "No paths with \-\-include/\-\-only does not make sense." err > +' > + > test_done
On 18.12.2019 23:02, Junio C Hamano wrote: >> + test_must_fail git commit --pathspec-from-file=- --interactive -m "Commit" <list 2>err && >> + test_i18ngrep "\-\-pathspec-from-file is incompatible with \-\-interactive/\-\-patc > h" err && > > What's with the overly-noisy quoting of dashes here? To match a > string that happens to begin with a dash, either one of > > $ grep -e "-this string begins with and has-many-dashes-in-it" file > $ grep "[-]this string begins with and has-many-dashes-in-it" file > > would be sufficient and more idiomatic. > > Or am I missing some other reason why the test is written this way? No, it's just my lack of experience. Thanks for your fix! I have applied it in V3.
diff --git a/t/t7526-commit-pathspec-file.sh b/t/t7526-commit-pathspec-file.sh index 4e592f7472..68920e8ff9 100755 --- a/t/t7526-commit-pathspec-file.sh +++ b/t/t7526-commit-pathspec-file.sh @@ -61,4 +61,28 @@ 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 commit --pathspec-from-file=- --interactive -m "Commit" <list 2>err && + test_i18ngrep "\-\-pathspec-from-file is incompatible with \-\-interactive/\-\-patch" err && + + test_must_fail git commit --pathspec-from-file=- --patch -m "Commit" <list 2>err && + test_i18ngrep "\-\-pathspec-from-file is incompatible with \-\-interactive/\-\-patch" err && + + test_must_fail git commit --pathspec-from-file=- -m "Commit" -- fileA.t <list 2>err && + test_i18ngrep "\-\-pathspec-from-file is incompatible with pathspec arguments" err && + + test_must_fail git commit --pathspec-file-nul -m "Commit" 2>err && + test_i18ngrep "\-\-pathspec-file-nul requires \-\-pathspec-from-file" err && + + test_must_fail git commit --pathspec-from-file=- --include -m "Commit" <empty_list 2>err && + test_i18ngrep "No paths with \-\-include/\-\-only does not make sense." err && + + test_must_fail git commit --pathspec-from-file=- --only -m "Commit" <empty_list 2>err && + test_i18ngrep "No paths with \-\-include/\-\-only does not make sense." err +' + test_done