Skip to content

Commit

Permalink
Merge branch 'sb/quiet-porcelains'
Browse files Browse the repository at this point in the history
* sb/quiet-porcelains:
  stash: teach quiet option
  am, rebase: teach quiet option
  submodule, repack: migrate to git-sh-setup's say()
  git-sh-setup: introduce say() for quiet options
  am: suppress apply errors when using 3-way
  t4150: test applying with a newline in subject
  • Loading branch information
gitster committed Jul 2, 2009
2 parents 4197195 + fcdd0e9 commit e6c7c2c
Show file tree
Hide file tree
Showing 12 changed files with 225 additions and 74 deletions.
6 changes: 5 additions & 1 deletion Documentation/git-am.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SYNOPSIS
[--3way] [--interactive] [--committer-date-is-author-date]
[--ignore-date]
[--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
[--reject]
[--reject] [-q | --quiet]
[<mbox> | <Maildir>...]
'git am' (--skip | --resolved | --abort)

Expand All @@ -39,6 +39,10 @@ OPTIONS
--keep::
Pass `-k` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).

-q::
--quiet::
Be quiet. Only print error messages.

-u::
--utf8::
Pass `-u` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).
Expand Down
4 changes: 4 additions & 0 deletions Documentation/git-rebase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ OPTIONS
is used instead ('git-merge-recursive' when merging a single
head, 'git-merge-octopus' otherwise). This implies --merge.

-q::
--quiet::
Be quiet. Implies --no-stat.

-v::
--verbose::
Be verbose. Implies --stat.
Expand Down
15 changes: 8 additions & 7 deletions Documentation/git-stash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ SYNOPSIS
--------
[verse]
'git stash' list [<options>]
'git stash' ( show | drop ) [<stash>]
'git stash' ( pop | apply ) [--index] [<stash>]
'git stash' show [<stash>]
'git stash' drop [-q|--quiet] [<stash>]
'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>]
'git stash' branch <branchname> [<stash>]
'git stash' [save [--keep-index] [<message>]]
'git stash' [save [--keep-index] [-q|--quiet] [<message>]]
'git stash' clear
'git stash' create

Expand Down Expand Up @@ -41,7 +42,7 @@ is also possible).
OPTIONS
-------

save [--keep-index] [<message>]::
save [--keep-index] [-q|--quiet] [<message>]::

Save your local modifications to a new 'stash', and run `git reset
--hard` to revert them. This is the default action when no
Expand Down Expand Up @@ -75,7 +76,7 @@ show [<stash>]::
it will accept any format known to 'git-diff' (e.g., `git stash show
-p stash@\{1}` to view the second most recent stash in patch form).

pop [<stash>]::
pop [--index] [-q|--quiet] [<stash>]::

Remove a single stashed state from the stash list and apply it
on top of the current working tree state, i.e., do the inverse
Expand All @@ -93,7 +94,7 @@ longer apply the changes as they were originally).
+
When no `<stash>` is given, `stash@\{0}` is assumed.

apply [--index] [<stash>]::
apply [--index] [-q|--quiet] [<stash>]::

Like `pop`, but do not remove the state from the stash list.

Expand All @@ -115,7 +116,7 @@ clear::
Remove all the stashed states. Note that those states will then
be subject to pruning, and may be difficult or impossible to recover.

drop [<stash>]::
drop [-q|--quiet] [<stash>]::

Remove a single stashed state from the stash list. When no `<stash>`
is given, it removes the latest one. i.e. `stash@\{0}`
Expand Down
35 changes: 27 additions & 8 deletions git-am.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -181,6 +186,8 @@ do
committer_date_is_author_date=t ;;
--ignore-date)
ignore_date=t ;;
-q|--quiet)
GIT_QUIET=t ;;
--)
shift; break ;;
*)
Expand Down Expand Up @@ -279,14 +286,15 @@ 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"
echo "$threeway" >"$dotest/threeway"
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
Expand Down Expand Up @@ -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
Expand All @@ -352,7 +364,7 @@ fi

if test "$this" -gt "$last"
then
echo Nothing to do.
say Nothing to do.
rm -fr "$dotest"
exit
fi
Expand Down Expand Up @@ -498,11 +510,18 @@ do
stop_here $this
fi

printf 'Applying: %s\n' "$FIRSTLINE"
say "Applying: $FIRSTLINE"

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)
Expand Down Expand Up @@ -534,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
}
Expand All @@ -560,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
Expand Down
48 changes: 38 additions & 10 deletions git-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano.
#

USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>]'
USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'
LONG_USAGE='git-rebase replaces <branch> with a new branch of the
same name. When the --onto option is provided the new branch starts
out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>
Expand Down Expand Up @@ -72,11 +72,20 @@ continue_merge () {
echo "directly, but instead do one of the following: "
die "$RESOLVEMSG"
fi
printf "Committed: %0${prec}d " $msgnum
if test -z "$GIT_QUIET"
then
printf "Committed: %0${prec}d " $msgnum
fi
else
printf "Already applied: %0${prec}d " $msgnum
if test -z "$GIT_QUIET"
then
printf "Already applied: %0${prec}d " $msgnum
fi
fi
if test -z "$GIT_QUIET"
then
git rev-list --pretty=oneline -1 "$cmt" | sed -e 's/^[^ ]* //'
fi
git rev-list --pretty=oneline -1 "$cmt" | sed -e 's/^[^ ]* //'

prev_head=`git rev-parse HEAD^0`
# save the resulting commit so we can read-tree on it later
Expand All @@ -97,6 +106,10 @@ call_merge () {
eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
eval GITHEAD_$hd='$(cat "$dotest/onto_name")'
export GITHEAD_$cmt GITHEAD_$hd
if test -n "$GIT_QUIET"
then
export GIT_MERGE_VERBOSITY=1
fi
git-merge-$strategy "$cmt^" -- "$hd" "$cmt"
rv=$?
case "$rv" in
Expand Down Expand Up @@ -138,7 +151,7 @@ move_to_original_branch () {
finish_rb_merge () {
move_to_original_branch
rm -r "$dotest"
echo "All done."
say All done.
}

is_interactive () {
Expand Down Expand Up @@ -207,6 +220,7 @@ do
end=$(cat "$dotest/end")
msgnum=$(cat "$dotest/msgnum")
onto=$(cat "$dotest/onto")
GIT_QUIET=$(cat "$dotest/quiet")
continue_merge
while test "$msgnum" -le "$end"
do
Expand All @@ -219,6 +233,7 @@ do
head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
GIT_QUIET=$(cat "$GIT_DIR"/rebase-apply/quiet)
git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
Expand All @@ -236,6 +251,7 @@ do
msgnum=$(cat "$dotest/msgnum")
msgnum=$(($msgnum + 1))
onto=$(cat "$dotest/onto")
GIT_QUIET=$(cat "$dotest/quiet")
while test "$msgnum" -le "$end"
do
call_merge "$msgnum"
Expand All @@ -247,6 +263,7 @@ do
head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
GIT_QUIET=$(cat "$GIT_DIR"/rebase-apply/quiet)
git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
Expand All @@ -258,9 +275,11 @@ do
git rerere clear
if test -d "$dotest"
then
GIT_QUIET=$(cat "$dotest/quiet")
move_to_original_branch
else
dotest="$GIT_DIR"/rebase-apply
GIT_QUIET=$(cat "$dotest/quiet")
move_to_original_branch
fi
git reset --hard $(cat "$dotest/orig-head")
Expand Down Expand Up @@ -298,6 +317,13 @@ do
-v|--verbose)
verbose=t
diffstat=t
GIT_QUIET=
;;
-q|--quiet)
GIT_QUIET=t
git_am_opt="$git_am_opt -q"
verbose=
diffstat=
;;
--whitespace=*)
git_am_opt="$git_am_opt $1"
Expand Down Expand Up @@ -442,15 +468,15 @@ then
then
# Lazily switch to the target branch if needed...
test -z "$switch_to" || git checkout "$switch_to"
echo >&2 "Current branch $branch_name is up to date."
say "Current branch $branch_name is up to date."
exit 0
else
echo "Current branch $branch_name is up to date, rebase forced."
say "Current branch $branch_name is up to date, rebase forced."
fi
fi

# Detach HEAD and reset the tree
echo "First, rewinding head to replay your work on top of it..."
say "First, rewinding head to replay your work on top of it..."
git checkout -q "$onto^0" || die "could not detach HEAD"
git update-ref ORIG_HEAD $branch

Expand All @@ -468,7 +494,7 @@ fi
# we just fast forwarded.
if test "$mb" = "$branch"
then
echo >&2 "Fast-forwarded $branch_name to $onto_name."
say "Fast-forwarded $branch_name to $onto_name."
move_to_original_branch
exit 0
fi
Expand All @@ -490,7 +516,8 @@ then
test 0 != $ret -a -d "$GIT_DIR"/rebase-apply &&
echo $head_name > "$GIT_DIR"/rebase-apply/head-name &&
echo $onto > "$GIT_DIR"/rebase-apply/onto &&
echo $orig_head > "$GIT_DIR"/rebase-apply/orig-head
echo $orig_head > "$GIT_DIR"/rebase-apply/orig-head &&
echo "$GIT_QUIET" > "$GIT_DIR"/rebase-apply/quiet
exit $ret
fi

Expand All @@ -504,6 +531,7 @@ prev_head=$orig_head
echo "$prev_head" > "$dotest/prev_head"
echo "$orig_head" > "$dotest/orig-head"
echo "$head_name" > "$dotest/head-name"
echo "$GIT_QUIET" > "$dotest/quiet"

msgnum=0
for cmt in `git rev-list --reverse --no-merges "$revisions"`
Expand Down
Loading

0 comments on commit e6c7c2c

Please sign in to comment.