Use GIT_REFLOG_ACTION environment variable instead.
Junio rightly pointed out that the --reflog-action parameter was starting to get out of control, as most porcelain code needed to hand it to other porcelain and plumbing alike to ensure the reflog contained the top-level user action and not the lower-level actions it invoked. At Junio's suggestion we are introducing the new set_reflog_action function to all shell scripts, allowing them to declare early on what their default reflog name should be, but this setting only takes effect if the caller has not already set the GIT_REFLOG_ACTION environment variable. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Shawn O. Pearce committed
Dec 28, 2006 at 02:34 UTC
f94741324e26af42093a89e955ff9a923abff951
7 files changed
+30
-41
Documentation/git-merge.txt
-6
@@ -10,7 +10,6 @@ SYNOPSIS
10
--------
11
[verse]
12
'git-merge' [-n] [--no-commit] [--squash] [-s <strategy>]...
13
- [--reflog-action=<action>]
13
-m=<msg> <remote> <remote>...
14
15
DESCRIPTION
@@ -37,11 +36,6 @@ include::merge-options.txt[]
36
least one <remote>. Specifying more than one <remote>
37
obviously means you are trying an Octopus.
38
40
---reflog-action=<action>::
41
- This is used internally when `git-pull` calls this command
42
- to record that the merge was created by `pull` command
43
- in the `ref-log` entry that results from the merge.
44
-
39
include::merge-strategies.txt[]
40
41
git-am.sh
+2
-5
@@ -6,6 +6,7 @@ USAGE='[--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way]
6
[--interactive] [--whitespace=<option>] <mbox>...
7
or, when resuming [--skip | --resolved]'
8
. git-sh-setup
9
+set_reflog_action am
10
11
git var GIT_COMMITTER_IDENT >/dev/null || exit
12
@@ -101,7 +102,6 @@ It does not apply to blobs recorded in its index."
102
}
103
104
prec=4
104
-rloga=am
105
dotest=.dotest sign= utf8= keep= skip= interactive= resolved= binary= ws= resolvemsg=
106
107
while case "$#" in 0) break;; esac
@@ -141,9 +141,6 @@ do
141
--resolvemsg=*)
142
resolvemsg=$(echo "$1" | sed -e "s/^--resolvemsg=//"); shift ;;
143
144
- --reflog-action=*)
145
- rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'`; shift ;;
146
-
144
--)
145
shift; break ;;
146
-*)
@@ -452,7 +449,7 @@ do
449
parent=$(git-rev-parse --verify HEAD) &&
450
commit=$(git-commit-tree $tree -p $parent <"$dotest/final-commit") &&
451
echo Committed: $commit &&
455
- git-update-ref -m "$rloga: $SUBJECT" HEAD $commit $parent ||
452
+ git-update-ref -m "$GIT_REFLOG_ACTION: $SUBJECT" HEAD $commit $parent ||
453
stop_here $this
454
455
if test -x "$GIT_DIR"/hooks/post-applypatch
git-fetch.sh
+8
-13
@@ -4,6 +4,8 @@
4
USAGE='<fetch-options> <repository> <refspec>...'
5
SUBDIRECTORY_OK=Yes
6
. git-sh-setup
7
+set_reflog_action "fetch $*"
8
+
9
TOP=$(git-rev-parse --show-cdup)
10
if test ! -z "$TOP"
11
then
@@ -17,7 +19,6 @@ LF='
19
'
20
IFS="$LF"
21
20
-rloga=fetch
22
no_tags=
23
tags=
24
append=
@@ -59,9 +60,6 @@ do
60
-k|--k|--ke|--kee|--keep)
61
keep='-k -k'
62
;;
62
- --reflog-action=*)
63
- rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'`
64
- ;;
63
-*)
64
usage
65
;;
@@ -86,9 +84,6 @@ refs=
84
rref=
85
rsync_slurped_objects=
86
89
-rloga="$rloga $remote_nick"
90
-test "$remote_nick" = "$remote" || rloga="$rloga $remote"
91
-
87
if test "" = "$append"
88
then
89
: >"$GIT_DIR/FETCH_HEAD"
@@ -172,12 +167,12 @@ update_local_ref () {
167
else
168
echo >&2 "* $1: updating with $3"
169
echo >&2 " $label_: $newshort_"
175
- git-update-ref -m "$rloga: updating tag" "$1" "$2"
170
+ git-update-ref -m "$GIT_REFLOG_ACTION: updating tag" "$1" "$2"
171
fi
172
else
173
echo >&2 "* $1: storing $3"
174
echo >&2 " $label_: $newshort_"
180
- git-update-ref -m "$rloga: storing tag" "$1" "$2"
175
+ git-update-ref -m "$GIT_REFLOG_ACTION: storing tag" "$1" "$2"
176
fi
177
;;
178
@@ -200,7 +195,7 @@ update_local_ref () {
195
*,$local)
196
echo >&2 "* $1: fast forward to $3"
197
echo >&2 " old..new: $oldshort_..$newshort_"
203
- git-update-ref -m "$rloga: fast-forward" "$1" "$2" "$local"
198
+ git-update-ref -m "$GIT_REFLOG_ACTION: fast-forward" "$1" "$2" "$local"
199
;;
200
*)
201
false
@@ -210,7 +205,7 @@ update_local_ref () {
205
*,t,*)
206
echo >&2 "* $1: forcing update to non-fast forward $3"
207
echo >&2 " old...new: $oldshort_...$newshort_"
213
- git-update-ref -m "$rloga: forced-update" "$1" "$2" "$local"
208
+ git-update-ref -m "$GIT_REFLOG_ACTION: forced-update" "$1" "$2" "$local"
209
;;
210
*)
211
echo >&2 "* $1: not updating to non-fast forward $3"
@@ -222,7 +217,7 @@ update_local_ref () {
217
else
218
echo >&2 "* $1: storing $3"
219
echo >&2 " $label_: $newshort_"
225
- git-update-ref -m "$rloga: storing head" "$1" "$2"
220
+ git-update-ref -m "$GIT_REFLOG_ACTION: storing head" "$1" "$2"
221
fi
222
;;
223
esac
@@ -465,7 +460,7 @@ case "$orig_head" in
460
if test "$curr_head" != "$orig_head"
461
then
462
git-update-ref \
468
- -m "$rloga: Undoing incorrectly fetched HEAD." \
463
+ -m "$GIT_REFLOG_ACTION: Undoing incorrectly fetched HEAD." \
464
HEAD "$orig_head"
465
die "Cannot fetch into the current branch."
466
fi
git-merge.sh
+5
-8
@@ -3,9 +3,10 @@
3
# Copyright (c) 2005 Junio C Hamano
4
#
5
6
-USAGE='[-n] [--no-commit] [--squash] [-s <strategy>] [--reflog-action=<action>] [-m=<merge-message>] <commit>+'
6
+USAGE='[-n] [--no-commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commit>+'
7
8
. git-sh-setup
9
+set_reflog_action "merge $*"
10
11
LF='
12
'
@@ -57,10 +58,10 @@ squash_message () {
58
finish () {
59
if test '' = "$2"
60
then
60
- rlogm="$rloga"
61
+ rlogm="$GIT_REFLOG_ACTION"
62
else
63
echo "$2"
63
- rlogm="$rloga: $2"
64
+ rlogm="$GIT_REFLOG_ACTION: $2"
65
fi
66
case "$squash" in
67
t)
@@ -109,7 +110,7 @@ merge_name () {
110
111
case "$#" in 0) usage ;; esac
112
112
-rloga= have_message=
113
+have_message=
114
while case "$#" in 0) break ;; esac
115
do
116
case "$1" in
@@ -139,9 +140,6 @@ do
140
die "available strategies are: $all_strategies" ;;
141
esac
142
;;
142
- --reflog-action=*)
143
- rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'`
144
- ;;
143
-m=*|--m=*|--me=*|--mes=*|--mess=*|--messa=*|--messag=*|--message=*)
144
merge_msg=`expr "z$1" : 'z-[^=]*=\(.*\)'`
145
have_message=t
@@ -213,7 +211,6 @@ head=$(git-rev-parse --verify "$head_arg"^0) || usage
211
212
# All the rest are remote heads
213
test "$#" = 0 && usage ;# we need at least one remote head.
216
-test "$rloga" = '' && rloga="merge: $@"
214
215
remoteheads=
216
for remote
git-pull.sh
+3
-3
@@ -7,6 +7,7 @@
7
USAGE='[-n | --no-summary] [--no-commit] [-s strategy]... [<fetch-options>] <repo> <head>...'
8
LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEAD.'
9
. git-sh-setup
10
+set_reflog_action "pull $*"
11
12
strategy_args= no_summary= no_commit= squash=
13
while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac
@@ -45,7 +46,7 @@ do
46
done
47
48
orig_head=$(git-rev-parse --verify HEAD 2>/dev/null)
48
-git-fetch --update-head-ok --reflog-action=pull "$@" || exit 1
49
+git-fetch --update-head-ok "$@" || exit 1
50
51
curr_head=$(git-rev-parse --verify HEAD 2>/dev/null)
52
if test "$curr_head" != "$orig_head"
@@ -118,6 +119,5 @@ case "$strategy_args" in
119
esac
120
121
merge_name=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD") || exit
121
-git-merge "--reflog-action=pull $*" \
122
- $no_summary $no_commit $squash $strategy_args \
122
+git-merge $no_summary $no_commit $squash $strategy_args \
123
"$merge_name" HEAD $merge_head
git-rebase.sh
+4
-6
@@ -28,6 +28,7 @@ Example: git-rebase master~1 topic
28
D---E---F---G master D---E---F---G master
29
'
30
. git-sh-setup
31
+set_reflog_action rebase
32
33
RESOLVEMSG="
34
When you have resolved this problem run \"git rebase --continue\".
@@ -132,8 +133,7 @@ do
133
finish_rb_merge
134
exit
135
fi
135
- git am --resolved --3way --resolvemsg="$RESOLVEMSG" \
136
- --reflog-action=rebase
136
+ git am --resolved --3way --resolvemsg="$RESOLVEMSG"
137
exit
138
;;
139
--skip)
@@ -156,8 +156,7 @@ do
156
finish_rb_merge
157
exit
158
fi
159
- git am -3 --skip --resolvemsg="$RESOLVEMSG" \
160
- --reflog-action=rebase
159
+ git am -3 --skip --resolvemsg="$RESOLVEMSG"
160
exit
161
;;
162
--abort)
@@ -306,8 +305,7 @@ fi
305
if test -z "$do_merge"
306
then
307
git-format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD |
309
- git am --binary -3 -k --resolvemsg="$RESOLVEMSG" \
310
- --reflog-action=rebase
308
+ git am --binary -3 -k --resolvemsg="$RESOLVEMSG"
309
exit $?
310
fi
311
git-sh-setup.sh
+8
@@ -20,6 +20,14 @@ usage() {
20
die "Usage: $0 $USAGE"
21
}
22
23
+set_reflog_action() {
24
+ if [ -z "${GIT_REFLOG_ACTION:+set}" ]
25
+ then
26
+ GIT_REFLOG_ACTION="$*"
27
+ export GIT_REFLOG_ACTION
28
+ fi
29
+}
30
+
31
if [ -z "$LONG_USAGE" ]
32
then
33
LONG_USAGE="Usage: $0 $USAGE"