git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 2/2] git-am: minor cleanups

From
Jay Soffian <jaysoffian@gmail.com>
Date
Jan 28, 2009, 15:03 UTC
Message-ID
<1233154990-19745-2-git-send-email-jaysoffian@gmail.com>
In-Reply-To
<1233154990-19745-1-git-send-email-jaysoffian@gmail.com>

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 "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, and appears to be deprecated by POSIX)

Use "test ..." instead of "[ ... ]" and "die <msg>" instead of "echo <msg>
>&2; exit 1" to be consistent with rest of script.
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
Change from v2: mention who deprecated "tty -s" in commit message.
 git-am.sh |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index 92a64b2..670fc02 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
@@ -281,10 +280,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
Previous: Jay SoffianNext: Pieter de Bie
Message 2 of 9 in “git-am: emit usage when called w/o arguments and w/o patch on stdin”
  1. 1/2 git-am: emit usage when called w/o arguments and w/o patch on stdinJay Soffian, Jan 28, 2009
  2. 2/2 git-am: minor cleanupsJay Soffian, Jan 28, 2009
  3. Pieter de BieJan 28, 2009
  4. Jay SoffianJan 28, 2009
  5. Junio C HamanoJan 28, 2009
  6. Jay SoffianJan 28, 2009
  7. Sverre RabbelierJan 28, 2009
  8. Jeff KingJan 28, 2009
  9. Junio C HamanoJan 28, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.