Shut "git rebase -i" up when no --verbose was given
Up to now, git rebase -i was quite chatty, showing through all the nice core programs it called. Now it only shows a progress meter by default. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Jul 23, 2007 at 23:45 UTC
dfa49f33489dbb142bcc796a4e932863f9dcce1f
1 file changed
+34
-16
git-rebase--interactive.sh
+34
-16
@@ -33,6 +33,20 @@ warn () {
33
echo "$*" >&2
34
}
35
36
+output () {
37
+ case "$VERBOSE" in
38
+ '')
39
+ "$@" > "$DOTEST"/output 2>&1
40
+ status=$?
41
+ test $status != 0 &&
42
+ cat "$DOTEST"/output
43
+ return $status
44
+ ;;
45
+ *)
46
+ "$@"
47
+ esac
48
+}
49
+
50
require_clean_work_tree () {
51
# test if working tree is dirty
52
git rev-parse --verify HEAD > /dev/null &&
@@ -56,6 +70,10 @@ mark_action_done () {
70
sed -e 1q < "$TODO" >> "$DONE"
71
sed -e 1d < "$TODO" >> "$TODO".new
72
mv -f "$TODO".new "$TODO"
73
+ count=$(($(wc -l < "$DONE")))
74
+ total=$(($count+$(wc -l < "$TODO")))
75
+ printf "Rebasing (%d/%d)\r" $count $total
76
+ test -z "$VERBOSE" || echo
77
}
78
79
make_patch () {
@@ -79,18 +97,18 @@ die_abort () {
97
98
pick_one () {
99
case "$1" in -n) sha1=$2 ;; *) sha1=$1 ;; esac
82
- git rev-parse --verify $sha1 || die "Invalid commit name: $sha1"
100
+ output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1"
101
test -d "$REWRITTEN" &&
102
pick_one_preserving_merges "$@" && return
103
parent_sha1=$(git rev-parse --verify $sha1^ 2>/dev/null)
104
current_sha1=$(git rev-parse --verify HEAD)
105
if [ $current_sha1 = $parent_sha1 ]; then
88
- git reset --hard $sha1
89
- test "a$1" = a-n && git reset --soft $current_sha1
106
+ output git reset --hard $sha1
107
+ test "a$1" = a-n && output git reset --soft $current_sha1
108
sha1=$(git rev-parse --short $sha1)
91
- warn Fast forward to $sha1
109
+ output warn Fast forward to $sha1
110
else
93
- git cherry-pick $STRATEGY "$@"
111
+ output git cherry-pick $STRATEGY "$@"
112
fi
113
}
114
@@ -127,7 +145,7 @@ pick_one_preserving_merges () {
145
done
146
case $fast_forward in
147
t)
130
- echo "Fast forward to $sha1"
148
+ output warn "Fast forward to $sha1"
149
test $preserve=f && echo $sha1 > "$REWRITTEN"/$sha1
150
;;
151
f)
@@ -135,7 +153,7 @@ pick_one_preserving_merges () {
153
154
first_parent=$(expr "$new_parents" : " \([^ ]*\)")
155
# detach HEAD to current parent
138
- git checkout $first_parent 2> /dev/null ||
156
+ output git checkout $first_parent 2> /dev/null ||
157
die "Cannot move HEAD to $first_parent"
158
159
echo $sha1 > "$DOTEST"/current-commit
@@ -147,14 +165,14 @@ pick_one_preserving_merges () {
165
msg="$(git cat-file commit $sha1 | \
166
sed -e '1,/^$/d' -e "s/[\"\\]/\\\\&/g")"
167
# NEEDSWORK: give rerere a chance
150
- if ! git merge $STRATEGY -m "$msg" $new_parents
168
+ if ! output git merge $STRATEGY -m "$msg" $new_parents
169
then
170
echo "$msg" > "$GIT_DIR"/MERGE_MSG
171
die Error redoing merge $sha1
172
fi
173
;;
174
*)
157
- git cherry-pick $STRATEGY "$@" ||
175
+ output git cherry-pick $STRATEGY "$@" ||
176
die_with_patch $sha1 "Could not pick $sha1"
177
esac
178
esac
@@ -241,7 +259,7 @@ do_next () {
259
260
failed=f
261
pick_one -n $sha1 || failed=t
244
- git reset --soft HEAD^
262
+ output git reset --soft HEAD^
263
author_script=$(get_author_ident_from_commit $sha1)
264
echo "$author_script" > "$DOTEST"/author-script
265
case $failed in
@@ -249,7 +267,7 @@ do_next () {
267
# This is like --amend, but with a different message
268
eval "$author_script"
269
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE
252
- git commit -F "$MSG" $EDIT_COMMIT
270
+ output git commit -F "$MSG" $EDIT_COMMIT
271
;;
272
t)
273
cp "$MSG" "$GIT_DIR"/MERGE_MSG
@@ -324,7 +342,7 @@ do
342
HEADNAME=$(cat "$DOTEST"/head-name)
343
HEAD=$(cat "$DOTEST"/head)
344
git symbolic-ref HEAD $HEADNAME &&
327
- git reset --hard $HEAD &&
345
+ output git reset --hard $HEAD &&
346
rm -rf "$DOTEST"
347
exit
348
;;
@@ -333,7 +351,7 @@ do
351
352
test -d "$DOTEST" || die "No interactive rebase running"
353
336
- git reset --hard && do_rest
354
+ output git reset --hard && do_rest
355
;;
356
-s|--strategy)
357
shift
@@ -387,9 +405,9 @@ do
405
406
if [ ! -z "$2"]
407
then
390
- git show-ref --verify --quiet "refs/heads/$2" ||
408
+ output git show-ref --verify --quiet "refs/heads/$2" ||
409
die "Invalid branchname: $2"
392
- git checkout "$2" ||
410
+ output git checkout "$2" ||
411
die "Could not checkout $2"
412
fi
413
@@ -456,7 +474,7 @@ EOF
474
test -z "$(grep -ve '^$' -e '^#' < $TODO)" &&
475
die_abort "Nothing to do"
476
459
- git checkout $ONTO && do_rest
477
+ output git checkout $ONTO && do_rest
478
esac
479
shift
480
done