summaryrefslogtreecommitdiff
path: root/git-am.sh
diff options
context:
space:
mode:
authorStephen Boyd <bebarino@gmail.com>2009-06-16 15:33:01 -0700
committerJunio C Hamano <gitster@pobox.com>2009-06-18 11:54:48 -0700
commit0e987a12fc1d481d81ad9c56f4714efb08667213 (patch)
tree3558298ec717c32ddac1204e6c9f751ab0da4d38 /git-am.sh
parent2e6a30ef8fbaedc5f2ee199d36f7256bb0cfdf1e (diff)
downloadgit-0e987a12fc1d481d81ad9c56f4714efb08667213.tar.gz
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 <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-am.sh')
-rwxr-xr-xgit-am.sh26
1 files changed, 19 insertions, 7 deletions
diff --git a/git-am.sh b/git-am.sh
index e26c54a3e2..58d4eb6d2d 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -11,6 +11,7 @@ git am [options] (--resolved | --skip | --abort)
i,interactive run interactively
b,binary* (historical option -- no-op)
3,3way allow fall back on 3way merging if needed
+q,quiet be quiet
s,signoff add a Signed-off-by line to the commit message
u,utf8 recode into utf8 (default)
k,keep pass -k flag to git-mailinfo
@@ -99,7 +100,7 @@ fall_back_3way () {
git write-tree >"$dotest/patch-merge-base+" ||
cannot_fallback "Repository lacks necessary blobs to fall back on 3-way merge."
- echo Using index info to reconstruct a base tree...
+ say Using index info to reconstruct a base tree...
if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
git apply --cached <"$dotest/patch"
then
@@ -115,7 +116,7 @@ It does not apply to blobs recorded in its index."
orig_tree=$(cat "$dotest/patch-merge-base") &&
rm -fr "$dotest"/patch-merge-* || exit 1
- echo Falling back to patching base and 3-way merge...
+ say Falling back to patching base and 3-way merge...
# This is not so wrong. Depending on which base we picked,
# orig_tree may be wildly different from ours, but his_tree
@@ -125,6 +126,10 @@ It does not apply to blobs recorded in its index."
eval GITHEAD_$his_tree='"$FIRSTLINE"'
export GITHEAD_$his_tree
+ if test -n "$GIT_QUIET"
+ then
+ export GIT_MERGE_VERBOSITY=0
+ fi
git-merge-recursive $orig_tree -- HEAD $his_tree || {
git rerere
echo Failed to merge in the changes.
@@ -181,6 +186,8 @@ do
committer_date_is_author_date=t ;;
--ignore-date)
ignore_date=t ;;
+ -q|--quiet)
+ GIT_QUIET=t ;;
--)
shift; break ;;
*)
@@ -279,7 +286,7 @@ else
exit 1
}
- # -s, -u, -k, --whitespace, -3, -C and -p flags are kept
+ # -s, -u, -k, --whitespace, -3, -C, -q and -p flags are kept
# for the resuming session after a patch failure.
# -i can and must be given when resuming.
echo " $git_apply_opt" >"$dotest/apply-opt"
@@ -287,6 +294,7 @@ else
echo "$sign" >"$dotest/sign"
echo "$utf8" >"$dotest/utf8"
echo "$keep" >"$dotest/keep"
+ echo "$GIT_QUIET" >"$dotest/quiet"
echo 1 >"$dotest/next"
if test -n "$rebasing"
then
@@ -327,6 +335,10 @@ if test "$(cat "$dotest/keep")" = t
then
keep=-k
fi
+if test "$(cat "$dotest/quiet")" = t
+then
+ GIT_QUIET=t
+fi
if test "$(cat "$dotest/threeway")" = t
then
threeway=t
@@ -352,7 +364,7 @@ fi
if test "$this" -gt "$last"
then
- echo Nothing to do.
+ say Nothing to do.
rm -fr "$dotest"
exit
fi
@@ -498,7 +510,7 @@ do
stop_here $this
fi
- printf 'Applying: %s\n' "$FIRSTLINE"
+ say "Applying: $FIRSTLINE"
case "$resolved" in
'')
@@ -541,7 +553,7 @@ do
# Applying the patch to an earlier tree and merging the
# result may have produced the same tree as ours.
git diff-index --quiet --cached HEAD -- && {
- echo No changes -- Patch already applied.
+ say No changes -- Patch already applied.
go_next
continue
}
@@ -567,7 +579,7 @@ do
GIT_AUTHOR_DATE=
fi
parent=$(git rev-parse --verify -q HEAD) ||
- echo >&2 "applying to an empty history"
+ say >&2 "applying to an empty history"
if test -n "$committer_date_is_author_date"
then