t: add tests for error conditions with --pathspec-from-file

Also move some old tests into the new tests: it doesn't seem reasonable
to have individual error condition tests.

Old test for `git commit` was corrected, previously it was instructed
to use stdin but wasn't provided with any stdin. While this works at
the moment, it's not exactly perfect.

Old tests for `git reset` were improved to test for a specific error
message.

Suggested-By: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Alexandr Miloslavskiy
2019-12-30 15:38:38 +00:00
committed by Junio C Hamano
parent d0654dc308
commit f94f7bd00d
5 changed files with 105 additions and 12 deletions

View File

@ -128,15 +128,6 @@ test_expect_success 'quotes not compatible with --pathspec-file-nul' '
test_must_fail verify_expect
'
test_expect_success '--pathspec-from-file is not compatible with --soft or --hard' '
restore_checkpoint &&
git rm fileA.t &&
echo fileA.t >list &&
test_must_fail git reset --soft --pathspec-from-file=list &&
test_must_fail git reset --hard --pathspec-from-file=list
'
test_expect_success 'only touches what was listed' '
restore_checkpoint &&
@ -152,4 +143,25 @@ test_expect_success 'only touches what was listed' '
verify_expect
'
test_expect_success 'error conditions' '
restore_checkpoint &&
echo fileA.t >list &&
git rm fileA.t &&
test_must_fail git reset --pathspec-from-file=list --patch 2>err &&
test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err &&
test_must_fail git reset --pathspec-from-file=list -- fileA.t 2>err &&
test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
test_must_fail git reset --pathspec-file-nul 2>err &&
test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err &&
test_must_fail git reset --soft --pathspec-from-file=list 2>err &&
test_i18ngrep -e "fatal: Cannot do soft reset with paths" err &&
test_must_fail git reset --hard --pathspec-from-file=list 2>err &&
test_i18ngrep -e "fatal: Cannot do hard reset with paths" err
'
test_done