* [PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin
@ 2009-01-28 2:38 Jay Soffian
2009-01-28 2:38 ` [PATCH 2/2] git-am: minor cleanups Jay Soffian
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jay Soffian @ 2009-01-28 2:38 UTC (permalink / raw)
To: git; +Cc: Jay Soffian, gitster, sverre
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.
Noticed by Sverre Rabbelier
---
git-am.sh | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index b1c05c9..36227c6 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -254,10 +254,10 @@ else
done
shift
fi
- git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || {
- rm -fr "$dotest"
- exit 1
- }
+ test $# = 0 && test -t 0 && usage
+ trap 'rm -fr "$dotest"' 0
+ git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || 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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] git-am: minor cleanups
2009-01-28 2:38 [PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin Jay Soffian
@ 2009-01-28 2:38 ` Jay Soffian
2009-01-28 2:53 ` [PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin Jay Soffian
2009-01-28 3:01 ` Junio C Hamano
2 siblings, 0 replies; 5+ messages in thread
From: Jay Soffian @ 2009-01-28 2:38 UTC (permalink / raw)
To: git; +Cc: Jay Soffian, gitster, sverre
Update usage statement to remove a no-longer supported option, and to hide two
options (one a no-op, one internal) unless --help-all is used.
Use "test -t 0" instead of deprecated "tty -s" to detect when stdin is a
terminal. (test -t 0 is used elsewhere in git-am and in other git shell
scripts, tty -s is not.)
Use "test ..." instead of "[ ... ]" and "die <msg>" instead of "echo <msg>
>&2; exit 1" to be consistent with rest of script.
---
While fixing Sverre's issue, I noticed a few other things about git-am that
seemed worth cleaning up. These seem much to small to split into separate
patches so I included them together. Let me know if they should be split.
git-am.sh | 12 ++++--------
1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index 36227c6..2ad229b 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -8,9 +8,8 @@ OPTIONS_SPEC="\
git am [options] [<mbox>|<Maildir>...]
git am [options] (--resolved | --skip | --abort)
--
-d,dotest= (removed -- do not use)
i,interactive run interactively
-b,binary (historical option -- no-op)
+b,binary* (historical option -- no-op)
3,3way allow fall back on 3way merging if needed
s,signoff add a Signed-off-by line to the commit message
u,utf8 recode into utf8 (default)
@@ -24,7 +23,7 @@ resolvemsg= override error message when patch failure occurs
r,resolved to be used after a patch failure
skip skip the current patch
abort restore the original branch and abort the patching operation.
-rebasing (internal use for git-rebase)"
+rebasing* (internal use for git-rebase)"
. git-sh-setup
prefix=$(git rev-parse --show-prefix)
@@ -204,7 +203,7 @@ then
# unreliable -- stdin could be /dev/null for example
# and the caller did not intend to feed us a patch but
# wanted to continue unattended.
- tty -s
+ test -t 0
;;
*)
false
@@ -280,10 +279,7 @@ fi
case "$resolved" in
'')
files=$(git diff-index --cached --name-only HEAD --) || exit
- if [ "$files" ]; then
- echo "Dirty index: cannot apply patches (dirty: $files)" >&2
- exit 1
- fi
+ test "$files" && die "Dirty index: cannot apply patches (dirty: $files)"
esac
if test "$(cat "$dotest/utf8")" = t
--
1.6.1.224.gb56c
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin
2009-01-28 2:38 [PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin Jay Soffian
2009-01-28 2:38 ` [PATCH 2/2] git-am: minor cleanups Jay Soffian
@ 2009-01-28 2:53 ` Jay Soffian
2009-01-28 3:01 ` Junio C Hamano
2 siblings, 0 replies; 5+ messages in thread
From: Jay Soffian @ 2009-01-28 2:53 UTC (permalink / raw)
To: git; +Cc: gitster, sverre
On Tue, Jan 27, 2009 at 9:38 PM, Jay Soffian <jaysoffian@gmail.com> wrote:
> 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.
>
> Noticed by Sverre Rabbelier
Ugh, I forgot to sign-off on this and the next patch. Should I resend
or is it okay to say:
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
j.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin
2009-01-28 2:38 [PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin Jay Soffian
2009-01-28 2:38 ` [PATCH 2/2] git-am: minor cleanups Jay Soffian
2009-01-28 2:53 ` [PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin Jay Soffian
@ 2009-01-28 3:01 ` Junio C Hamano
2009-01-28 3:08 ` Jay Soffian
2 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2009-01-28 3:01 UTC (permalink / raw)
To: Jay Soffian; +Cc: git, gitster, sverre
Jay Soffian <jaysoffian@gmail.com> writes:
> Also ensure that $dotest is cleaned up if user manages to interupt mailsplit
> while it is processing input.
I do not think this "Also ensure" part is necessary nor desirable. If
something goes wrong, we'd like to have a way to resurrect some partial
results from the split out result.
The rest looked fine. Perhaps a re-roll?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin
2009-01-28 3:01 ` Junio C Hamano
@ 2009-01-28 3:08 ` Jay Soffian
0 siblings, 0 replies; 5+ messages in thread
From: Jay Soffian @ 2009-01-28 3:08 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, sverre
On Tue, Jan 27, 2009 at 10:01 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Jay Soffian <jaysoffian@gmail.com> writes:
>
>> Also ensure that $dotest is cleaned up if user manages to interupt mailsplit
>> while it is processing input.
>
> I do not think this "Also ensure" part is necessary nor desirable. If
> something goes wrong, we'd like to have a way to resurrect some partial
> results from the split out result.
Hmm, git-am was already nuking $dotest if mailsplit exited non-zero,
so I kept that behavior, but also clean-up if user kills git-am while
mailsplit is running.
I still think it should nuke $dotest if user hits ctrl-c, but I agree
if mailsplit exits non-zero it should not (which would be a change
from what it does now).
> The rest looked fine. Perhaps a re-roll?
Sure.
j.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-01-28 3:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-28 2:38 [PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin Jay Soffian
2009-01-28 2:38 ` [PATCH 2/2] git-am: minor cleanups Jay Soffian
2009-01-28 2:53 ` [PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin Jay Soffian
2009-01-28 3:01 ` Junio C Hamano
2009-01-28 3:08 ` Jay Soffian
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).