From: Chris Packham <judge.packham@gmail.com>
To: git@vger.kernel.org
Cc: peff@peff.net, szeder@ira.uka.de,
Chris Packham <judge.packham@gmail.com>
Subject: [PATCH] test for add with non-existent pathspec
Date: Tue, 9 Feb 2010 16:31:40 -0500 [thread overview]
Message-ID: <1265751100-21558-1-git-send-email-judge.packham@gmail.com> (raw)
In-Reply-To: <a038bef51002090643g23b35bb6xaa765ff13b80f5bb@mail.gmail.com>
Add a test for 'git add -u pathspec' and 'git add pathspec' where
pathspec does not exist. The expected result is that git add exits with
an error message and an appropriate exit code.
This adds 1 expected failure to t/t2200-add-update.sh.
Signed-off-by: Chris Packham <judge.packham@gmail.com>
---
If anyone feels like pursuing this heres a patch to two simple tests around
this behaviour. I made an initial attempt to change builtin-add.c to print an
error message and set the exit code to a non-zero value but my naive attempt
broke the normal usage of 'git add pathspec'.
t/t2200-add-update.sh | 5 +++++
t/t3700-add.sh | 5 +++++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index 9120750..dbabc3c 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -176,4 +176,9 @@ test_expect_success 'add -u resolves unmerged paths' '
'
+test_expect_failure 'error out when attempting to add -u non-existent pathspec' '
+ test_must_fail git add -u non-existent &&
+ ! (git ls-files | grep "non-existent")
+'
+
test_done
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 85eb0fb..c77bb71 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -255,4 +255,9 @@ test_expect_success 'git add to resolve conflicts on otherwise ignored path' '
git add track-this
'
+test_expect_success 'error out when attempting to add non-existent pathspec' '
+ test_must_fail git add non-existent &&
+ ! (git ls-files | grep "non-existent")
+'
+
test_done
--
1.6.4.2
next prev parent reply other threads:[~2010-02-09 21:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-08 18:29 git add -u nonexistent-file SZEDER Gábor
2010-02-08 19:12 ` Chris Packham
2010-02-09 0:39 ` Jeff King
2010-02-09 14:43 ` Chris Packham
2010-02-09 21:31 ` Chris Packham [this message]
2010-02-09 21:58 ` Junio C Hamano
2010-02-09 22:17 ` Chris Packham
2010-02-09 22:30 ` Chris Packham
2010-02-09 22:30 ` [PATCH 1/3] test for add with non-existent pathspec Chris Packham
2010-02-09 22:30 ` [PATCH 2/3] git add -u: give an error if pathspec unmatched Chris Packham
2010-02-09 22:30 ` [PATCH 3/3] t2200-add-update.sh: change expected fail to success Chris Packham
2010-02-09 23:18 ` git add -u nonexistent-file Junio C Hamano
2010-02-10 5:57 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1265751100-21558-1-git-send-email-judge.packham@gmail.com \
--to=judge.packham@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=szeder@ira.uka.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).