aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-04-15 14:11:43 -0700
committerJunio C Hamano <gitster@pobox.com>2024-04-15 14:11:43 -0700
commitd75ec4c62715fd768a56523f714fe9ecd2b1abb3 (patch)
tree0c14da40b63504b40b957f08eaf06ae37fa8c318 /t
parent6c142bc8461b557d88fde0be28faac76ad78053a (diff)
parent7de13cfef3042478223012841e07cd91d7234d22 (diff)
downloadgit-d75ec4c62715fd768a56523f714fe9ecd2b1abb3.tar.gz
Merge branch 'gt/add-u-commit-i-pathspec-check'
"git add -u <pathspec>" and "git commit [-i] <pathspec>" did not diagnose a pathspec element that did not match any files in certain situations, unlike "git add <pathspec>" did. * gt/add-u-commit-i-pathspec-check: builtin/add: error out when passing untracked path with -u builtin/commit: error out when passing untracked path with -i revision: optionally record matches with pathspec elements
Diffstat (limited to 't')
-rwxr-xr-xt/t2200-add-update.sh10
-rwxr-xr-xt/t7501-commit-basic-functionality.sh16
2 files changed, 11 insertions, 15 deletions
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index c01492f33f..df235ac306 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -65,6 +65,16 @@ test_expect_success 'update did not touch untracked files' '
test_must_be_empty out
'
+test_expect_success 'error out when passing untracked path' '
+ git reset --hard &&
+ echo content >>baz &&
+ echo content >>top &&
+ test_must_fail git add -u baz top 2>err &&
+ test_grep -e "error: pathspec .baz. did not match any file(s) known to git" err &&
+ git diff --cached --name-only >actual &&
+ test_must_be_empty actual
+'
+
test_expect_success 'cache tree has not been corrupted' '
git ls-files -s |
diff --git a/t/t7501-commit-basic-functionality.sh b/t/t7501-commit-basic-functionality.sh
index bced44a0fc..cc12f99f11 100755
--- a/t/t7501-commit-basic-functionality.sh
+++ b/t/t7501-commit-basic-functionality.sh
@@ -101,22 +101,8 @@ test_expect_success 'fail to commit untracked file (even with --include/--only)'
test_must_fail git commit --only -m "baz" baz 2>err &&
test_grep -e "$error" err &&
- # TODO: as for --include, the below command will fail because
- # nothing is staged. If something was staged, it would not fail
- # even though the provided pathspec does not match any tracked
- # path. (However, the untracked paths that match the pathspec are
- # not committed and only the staged changes get committed.)
- # In either cases, no error is returned to stderr like in (--only
- # and without --only/--include) cases. In a similar manner,
- # "git add -u baz" also does not error out.
- #
- # Therefore, the below test is just to document the current behavior
- # and is not an endorsement to the current behavior, and we may
- # want to fix this. And when that happens, this test should be
- # updated accordingly.
-
test_must_fail git commit --include -m "baz" baz 2>err &&
- test_must_be_empty err
+ test_grep -e "$error" err
'
test_expect_success 'setup: non-initial commit' '