git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jay Soffian <jaysoffian@gmail.com>
To: git@vger.kernel.org
Cc: Jay Soffian <jaysoffian@gmail.com>,
	gitster@pobox.com, sverre@rabbelier.nl
Subject: [PATCH v2 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin
Date: Tue, 27 Jan 2009 22:27:41 -0500	[thread overview]
Message-ID: <1233113262-17491-1-git-send-email-jaysoffian@gmail.com> (raw)

When git am is called w/o arguments, w/o a patch on stdin and the user hits
ctrl-c, it leaves behind a partially populated $dotest directory. After this
commit, it emits usage when called w/o arguments and w/o a patch on stdin.

Also ensure that $dotest is cleaned up if user manages to interupt mailsplit
while it is processing input, but not if mailsplit exits non-zero due to
error.

Noticed by Sverre Rabbelier

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
Change from v1: don't remove $dotest if mailsplit exits non-zero

 git-am.sh |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/git-am.sh b/git-am.sh
index b1c05c9..65285a0 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -254,10 +254,13 @@ else
 		done
 		shift
 	fi
-	git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" ||  {
-		rm -fr "$dotest"
+	test $# = 0 && test -t 0 && usage
+	trap 'rm -fr "$dotest"' 0
+	git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || {
+		trap - 0
 		exit 1
 	}
+	trap - 0
 
 	# -s, -u, -k, --whitespace, -3, -C and -p flags are kept
 	# for the resuming session after a patch failure.
-- 
1.6.1.224.gb56c

             reply	other threads:[~2009-01-28  3:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-28  3:27 Jay Soffian [this message]
2009-01-28  3:27 ` [PATCH v2 2/2] git-am: minor cleanups Jay Soffian
2009-01-28  4:18   ` Junio C Hamano
2009-01-28 14:26     ` Jay Soffian
2009-01-28  4:17 ` [PATCH v2 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin Junio C Hamano
2009-01-28 10:32   ` Sverre Rabbelier
2009-01-28 14:28   ` Jay Soffian
2009-01-28 18:10     ` Junio C Hamano

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=1233113262-17491-1-git-send-email-jaysoffian@gmail.com \
    --to=jaysoffian@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sverre@rabbelier.nl \
    /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).