git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Collingbourne <peter@pcc.me.uk>
To: git@vger.kernel.org
Cc: Peter Collingbourne <peter@pcc.me.uk>
Subject: [PATCH v2 3/9] git rm: test failure behaviour for multiple removals
Date: Sat, 10 Apr 2010 19:23:44 +0100	[thread overview]
Message-ID: <1270923830-11830-4-git-send-email-peter@pcc.me.uk> (raw)
In-Reply-To: <1270923830-11830-1-git-send-email-peter@pcc.me.uk>

This patch causes the failure cases for the "git rm" command
to be tested.  Specifically it tests that if the first removal
fails the operation is aborted with an error message, and that
if subsequent removals fail, the operation proceeds.

Based-on-work-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Peter Collingbourne <peter@pcc.me.uk>
---
 t/t3600-rm.sh |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index 0aaf0ad..5186844 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -126,6 +126,60 @@ test_expect_success 'Remove nonexistent file with --ignore-unmatch' '
 	git rm --ignore-unmatch nonexistent
 '
 
+test_expect_success 'If the first (in alphabetical order) removal fails, rm is cancelled' '
+	touch xyzzy &&
+	mkdir -p plugh &&
+	touch plugh/xyzzy &&
+	git add xyzzy plugh/xyzzy &&
+	git commit --allow-empty -a -m "two files to remove" &&
+	chmod a-w plugh &&
+	git ls-files --stage >before &&
+	test $(grep xyzzy before | wc -l) = 2 &&
+
+	test_must_fail git rm xyzzy plugh/xyzzy &&
+
+	test -e plugh/xyzzy &&
+	test -e xyzzy &&
+	git ls-files --stage >after &&
+	test_cmp before after
+'
+! test -e plugh || chmod 775 plugh
+rm -fr before after plugh xyzzy
+
+test_expect_success 'Best-effort behavior if the second removal fails' '
+	touch plugh &&
+	mkdir -p xyzzy &&
+	touch xyzzy/plugh &&
+	git add plugh xyzzy/plugh &&
+	git commit --allow-empty -a -m "two files to remove" &&
+	chmod a-w xyzzy &&
+	: >expect &&
+
+	git rm plugh xyzzy/plugh &&
+
+	test -e xyzzy/plugh &&
+	! test -e plugh &&
+	git ls-files --stage plugh xyzzy/plugh >actual &&
+	test_cmp expect actual
+'
+! test -e xyzzy || chmod 775 xyzzy
+rm -fr expect actual plugh xyzzy
+
+test_expect_success 'Message when first removal fails' '
+	touch xyzzy &&
+	mkdir -p plugh &&
+	touch plugh/xyzzy &&
+	git add xyzzy plugh/xyzzy &&
+	git commit --allow-empty -a -m "two files to remove" &&
+	chmod a-w plugh &&
+
+	test_must_fail git rm xyzzy plugh/xyzzy 2>msg &&
+
+	grep "git rm: '\''plugh/xyzzy'\'':" msg
+'
+! test -e plugh || chmod 775 plugh
+rm -fr msg plugh xyzzy
+
 test_expect_success '"rm" command printed' '
 	echo frotz > test-file &&
 	git add test-file &&
-- 
1.6.5

  parent reply	other threads:[~2010-04-10 18:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-10 18:23 [PATCH v2 0/9] Improve handling of moving and removing submodules Peter Collingbourne
2010-04-10 18:23 ` [PATCH v2 1/9] Generate unique ID for submodules created using "git submodule add" Peter Collingbourne
2010-04-10 18:41   ` Sverre Rabbelier
2010-04-10 18:23 ` [PATCH v2 2/9] Implement "git mv" for submodules Peter Collingbourne
2010-04-11  1:25   ` Junio C Hamano
2010-04-10 18:23 ` Peter Collingbourne [this message]
2010-04-10 18:23 ` [PATCH v2 4/9] git rm: display a warning for every unremovable file Peter Collingbourne
2010-04-10 18:23 ` [PATCH v2 5/9] git rm: collect file modes Peter Collingbourne
2010-04-10 18:23 ` [PATCH v2 6/9] Add a mode parameter to the remove_path function Peter Collingbourne
2010-04-11  1:25   ` Junio C Hamano
2010-04-10 18:23 ` [PATCH v2 7/9] git rm: do not abort due to an initialised submodule Peter Collingbourne
2010-04-11  1:25   ` Junio C Hamano
2010-04-10 18:23 ` [PATCH v2 8/9] git submodule: infrastructure for reading .gitmodules files in arbitrary locations Peter Collingbourne
2010-04-10 18:23 ` [PATCH v2 9/9] git rm: remove submodule entries from .gitmodules Peter Collingbourne

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=1270923830-11830-4-git-send-email-peter@pcc.me.uk \
    --to=peter@pcc.me.uk \
    --cc=git@vger.kernel.org \
    /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).