From b3c32ead20bc4d3baa6cffe00dd862f069463869 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 16 Jun 2009 15:32:57 -0700 Subject: [PATCH 1/6] t4150: test applying with a newline in subject Commit 4b7cc26 (git-am: use printf instead of echo on user-supplied strings, 2007-05-25) fixed a bug where subjects with newlines would cause git-am to echo multiple lines when it says "Applying: ". This test ensures that fix stays valid. Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- t/t4150-am.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/t4150-am.sh b/t/t4150-am.sh index d6ebbaebe2..51c369ad14 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -305,4 +305,12 @@ test_expect_success 'am into an unborn branch' ' test "z$result" = "z$(git rev-parse first^{tree})" ' +test_expect_success 'am newline in subject' ' + git checkout first && + test_tick && + sed -e "s/second/second \\\n foo/" patch1 > patchnl && + git am < patchnl > output.out 2>&1 && + grep "^Applying: second \\\n foo$" output.out +' + test_done From 3ddd170323fcf24af8c4a321ed9c73cda532986e Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 16 Jun 2009 15:32:58 -0700 Subject: [PATCH 2/6] am: suppress apply errors when using 3-way git-am with 3-way outputs errors when applying, even though the 3-way will usually be successful. We suppress these errors from git-apply because they are not "true" errors until the 3-way has been attempted. Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- git-am.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/git-am.sh b/git-am.sh index 578780be13..e26c54a3e2 100755 --- a/git-am.sh +++ b/git-am.sh @@ -502,7 +502,14 @@ do case "$resolved" in '') - eval 'git apply '"$git_apply_opt"' --index "$dotest/patch"' + # When we are allowed to fall back to 3-way later, don't give + # false errors during the initial attempt. + squelch= + if test "$threeway" = t + then + squelch='>/dev/null 2>&1 ' + fi + eval "git apply $squelch$git_apply_opt"' --index "$dotest/patch"' apply_status=$? ;; t) From e064c170b4abe21f50658f2ec3b07e4ec7520767 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 16 Jun 2009 15:32:59 -0700 Subject: [PATCH 3/6] git-sh-setup: introduce say() for quiet options Scripts should use say() when they want to output non-error messages. This function helps future script writers easily implement a quiet option by setting GIT_QUIET to enable suppression of non-error messages. Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- git-sh-setup.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 80acb7de72..c41c2f7439 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -44,6 +44,15 @@ die() { exit 1 } +GIT_QUIET= + +say () { + if test -z "$GIT_QUIET" + then + printf '%s\n' "$*" + fi +} + if test -n "$OPTIONS_SPEC"; then usage() { "$0" -h From 2e6a30ef8fbaedc5f2ee199d36f7256bb0cfdf1e Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 16 Jun 2009 15:33:00 -0700 Subject: [PATCH 4/6] submodule, repack: migrate to git-sh-setup's say() Now that there is say() in git-sh-setup, these scripts don't need to use their own. Migrate them over by setting GIT_QUIET and removing their custom say() functions. Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- git-repack.sh | 12 +++++------- git-submodule.sh | 24 ++++++------------------ 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/git-repack.sh b/git-repack.sh index 0868734723..1bf239499c 100755 --- a/git-repack.sh +++ b/git-repack.sh @@ -24,7 +24,7 @@ SUBDIRECTORY_OK='Yes' . git-sh-setup no_update_info= all_into_one= remove_redundant= unpack_unreachable= -local= quiet= no_reuse= extra= +local= no_reuse= extra= while test $# != 0 do case "$1" in @@ -33,7 +33,7 @@ do -A) all_into_one=t unpack_unreachable=--unpack-unreachable ;; -d) remove_redundant=t ;; - -q) quiet=-q ;; + -q) GIT_QUIET=t ;; -f) no_reuse=--no-reuse-object ;; -l) local=--local ;; --max-pack-size|--window|--window-memory|--depth) @@ -80,13 +80,11 @@ case ",$all_into_one," in ;; esac -args="$args $local $quiet $no_reuse$extra" +args="$args $local ${GIT_QUIET:+-q} $no_reuse$extra" names=$(git pack-objects --honor-pack-keep --non-empty --all --reflog $args Date: Tue, 16 Jun 2009 15:33:01 -0700 Subject: [PATCH 5/6] am, rebase: teach quiet option git-am and git-rebase are talkative scripts. Teach them to be quiet when told, allowing them to speak only when they fail or experience errors. The quiet option is maintained when git-am or git-rebase fails to apply a patch. This means subsequent --resolved, --continue, --skip, --abort invocations will be quiet if the original invocation was quiet. Drop a handful of >&2 redirection; the rest of the program sends all the info messages to stdout, not to stderr. Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- Documentation/git-am.txt | 6 ++++- Documentation/git-rebase.txt | 4 +++ git-am.sh | 26 +++++++++++++------ git-rebase.sh | 48 ++++++++++++++++++++++++++++-------- t/t3400-rebase.sh | 19 +++++++++----- t/t4150-am.sh | 18 ++++++++++++++ 6 files changed, 97 insertions(+), 24 deletions(-) diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt index 6d92cbee64..32e689b2bf 100644 --- a/Documentation/git-am.txt +++ b/Documentation/git-am.txt @@ -13,7 +13,7 @@ SYNOPSIS [--3way] [--interactive] [--committer-date-is-author-date] [--ignore-date] [--whitespace=