diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2006-12-28 02:34:48 -0500 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-12-28 01:05:15 -0800 |
commit | f94741324e26af42093a89e955ff9a923abff951 (patch) | |
tree | 0beeca333111820b6af3705435ccb837f7793e20 | |
parent | b1f5f64fc831eb9f90bd07dc708279a921410bb2 (diff) | |
download | git-f94741324e26af42093a89e955ff9a923abff951.tar.gz git-f94741324e26af42093a89e955ff9a923abff951.tar.xz |
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>
-rw-r--r-- | Documentation/git-merge.txt | 6 | ||||
-rwxr-xr-x | git-am.sh | 7 | ||||
-rwxr-xr-x | git-fetch.sh | 21 | ||||
-rwxr-xr-x | git-merge.sh | 13 | ||||
-rwxr-xr-x | git-pull.sh | 6 | ||||
-rwxr-xr-x | git-rebase.sh | 10 | ||||
-rwxr-xr-x | git-sh-setup.sh | 8 |
7 files changed, 30 insertions, 41 deletions
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt index e2954aa76..0f79665ea 100644 --- a/Documentation/git-merge.txt +++ b/Documentation/git-merge.txt @@ -10,7 +10,6 @@ SYNOPSIS -------- [verse] 'git-merge' [-n] [--no-commit] [--squash] [-s <strategy>]... - [--reflog-action=<action>] -m=<msg> <remote> <remote>... DESCRIPTION @@ -37,11 +36,6 @@ include::merge-options.txt[] least one <remote>. Specifying more than one <remote> obviously means you are trying an Octopus. ---reflog-action=<action>:: - This is used internally when `git-pull` calls this command - to record that the merge was created by `pull` command - in the `ref-log` entry that results from the merge. - include::merge-strategies.txt[] @@ -6,6 +6,7 @@ USAGE='[--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] [--interactive] [--whitespace=<option>] <mbox>... or, when resuming [--skip | --resolved]' . git-sh-setup +set_reflog_action am git var GIT_COMMITTER_IDENT >/dev/null || exit @@ -101,7 +102,6 @@ It does not apply to blobs recorded in its index." } prec=4 -rloga=am dotest=.dotest sign= utf8= keep= skip= interactive= resolved= binary= ws= resolvemsg= while case "$#" in 0) break;; esac @@ -141,9 +141,6 @@ do --resolvemsg=*) resolvemsg=$(echo "$1" | sed -e "s/^--resolvemsg=//"); shift ;; - --reflog-action=*) - rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'`; shift ;; - --) shift; break ;; -*) @@ -452,7 +449,7 @@ do parent=$(git-rev-parse --verify HEAD) && commit=$(git-commit-tree $tree -p $parent <"$dotest/final-commit") && echo Committed: $commit && - git-update-ref -m "$rloga: $SUBJECT" HEAD $commit $parent || + git-update-ref -m "$GIT_REFLOG_ACTION: $SUBJECT" HEAD $commit $parent || stop_here $this if test -x "$GIT_DIR"/hooks/post-applypatch diff --git a/git-fetch.sh b/git-fetch.sh index ffbd44f0e..7fb47f69f 100755 --- a/git-fetch.sh +++ b/git-fetch.sh @@ -4,6 +4,8 @@ USAGE='<fetch-options> <repository> <refspec>...' SUBDIRECTORY_OK=Yes . git-sh-setup +set_reflog_action "fetch $*" + TOP=$(git-rev-parse --show-cdup) if test ! -z "$TOP" then @@ -17,7 +19,6 @@ LF=' ' IFS="$LF" -rloga=fetch no_tags= tags= append= @@ -59,9 +60,6 @@ do -k|--k|--ke|--kee|--keep) keep='-k -k' ;; - --reflog-action=*) - rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'` - ;; -*) usage ;; @@ -86,9 +84,6 @@ refs= rref= rsync_slurped_objects= -rloga="$rloga $remote_nick" -test "$remote_nick" = "$remote" || rloga="$rloga $remote" - if test "" = "$append" then : >"$GIT_DIR/FETCH_HEAD" @@ -172,12 +167,12 @@ update_local_ref () { else echo >&2 "* $1: updating with $3" echo >&2 " $label_: $newshort_" - git-update-ref -m "$rloga: updating tag" "$1" "$2" + git-update-ref -m "$GIT_REFLOG_ACTION: updating tag" "$1" "$2" fi else echo >&2 "* $1: storing $3" echo >&2 " $label_: $newshort_" - git-update-ref -m "$rloga: storing tag" "$1" "$2" + git-update-ref -m "$GIT_REFLOG_ACTION: storing tag" "$1" "$2" fi ;; @@ -200,7 +195,7 @@ update_local_ref () { *,$local) echo >&2 "* $1: fast forward to $3" echo >&2 " old..new: $oldshort_..$newshort_" - git-update-ref -m "$rloga: fast-forward" "$1" "$2" "$local" + git-update-ref -m "$GIT_REFLOG_ACTION: fast-forward" "$1" "$2" "$local" ;; *) false @@ -210,7 +205,7 @@ update_local_ref () { *,t,*) echo >&2 "* $1: forcing update to non-fast forward $3" echo >&2 " old...new: $oldshort_...$newshort_" - git-update-ref -m "$rloga: forced-update" "$1" "$2" "$local" + git-update-ref -m "$GIT_REFLOG_ACTION: forced-update" "$1" "$2" "$local" ;; *) echo >&2 "* $1: not updating to non-fast forward $3" @@ -222,7 +217,7 @@ update_local_ref () { else echo >&2 "* $1: storing $3" echo >&2 " $label_: $newshort_" - git-update-ref -m "$rloga: storing head" "$1" "$2" + git-update-ref -m "$GIT_REFLOG_ACTION: storing head" "$1" "$2" fi ;; esac @@ -465,7 +460,7 @@ case "$orig_head" in if test "$curr_head" != "$orig_head" then git-update-ref \ - -m "$rloga: Undoing incorrectly fetched HEAD." \ + -m "$GIT_REFLOG_ACTION: Undoing incorrectly fetched HEAD." \ HEAD "$orig_head" die "Cannot fetch into the current branch." fi diff --git a/git-merge.sh b/git-merge.sh index 7dd0a1123..e8db52725 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -3,9 +3,10 @@ # Copyright (c) 2005 Junio C Hamano # -USAGE='[-n] [--no-commit] [--squash] [-s <strategy>] [--reflog-action=<action>] [-m=<merge-message>] <commit>+' +USAGE='[-n] [--no-commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commit>+' . git-sh-setup +set_reflog_action "merge $*" LF=' ' @@ -57,10 +58,10 @@ squash_message () { finish () { if test '' = "$2" then - rlogm="$rloga" + rlogm="$GIT_REFLOG_ACTION" else echo "$2" - rlogm="$rloga: $2" + rlogm="$GIT_REFLOG_ACTION: $2" fi case "$squash" in t) @@ -109,7 +110,7 @@ merge_name () { case "$#" in 0) usage ;; esac -rloga= have_message= +have_message= while case "$#" in 0) break ;; esac do case "$1" in @@ -139,9 +140,6 @@ do die "available strategies are: $all_strategies" ;; esac ;; - --reflog-action=*) - rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'` - ;; -m=*|--m=*|--me=*|--mes=*|--mess=*|--messa=*|--messag=*|--message=*) merge_msg=`expr "z$1" : 'z-[^=]*=\(.*\)'` have_message=t @@ -213,7 +211,6 @@ head=$(git-rev-parse --verify "$head_arg"^0) || usage # All the rest are remote heads test "$#" = 0 && usage ;# we need at least one remote head. -test "$rloga" = '' && rloga="merge: $@" remoteheads= for remote diff --git a/git-pull.sh b/git-pull.sh index 1703091bb..fd4ffb858 100755 --- a/git-pull.sh +++ b/git-pull.sh @@ -7,6 +7,7 @@ USAGE='[-n | --no-summary] [--no-commit] [-s strategy]... [<fetch-options>] <repo> <head>...' LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEAD.' . git-sh-setup +set_reflog_action "pull $*" strategy_args= no_summary= no_commit= squash= while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac @@ -45,7 +46,7 @@ do done orig_head=$(git-rev-parse --verify HEAD 2>/dev/null) -git-fetch --update-head-ok --reflog-action=pull "$@" || exit 1 +git-fetch --update-head-ok "$@" || exit 1 curr_head=$(git-rev-parse --verify HEAD 2>/dev/null) if test "$curr_head" != "$orig_head" @@ -118,6 +119,5 @@ case "$strategy_args" in esac merge_name=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD") || exit -git-merge "--reflog-action=pull $*" \ - $no_summary $no_commit $squash $strategy_args \ +git-merge $no_summary $no_commit $squash $strategy_args \ "$merge_name" HEAD $merge_head diff --git a/git-rebase.sh b/git-rebase.sh index ece31425d..5c7c4a690 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -28,6 +28,7 @@ Example: git-rebase master~1 topic D---E---F---G master D---E---F---G master ' . git-sh-setup +set_reflog_action rebase RESOLVEMSG=" When you have resolved this problem run \"git rebase --continue\". @@ -132,8 +133,7 @@ do finish_rb_merge exit fi - git am --resolved --3way --resolvemsg="$RESOLVEMSG" \ - --reflog-action=rebase + git am --resolved --3way --resolvemsg="$RESOLVEMSG" exit ;; --skip) @@ -156,8 +156,7 @@ do finish_rb_merge exit fi - git am -3 --skip --resolvemsg="$RESOLVEMSG" \ - --reflog-action=rebase + git am -3 --skip --resolvemsg="$RESOLVEMSG" exit ;; --abort) @@ -306,8 +305,7 @@ fi if test -z "$do_merge" then git-format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD | - git am --binary -3 -k --resolvemsg="$RESOLVEMSG" \ - --reflog-action=rebase + git am --binary -3 -k --resolvemsg="$RESOLVEMSG" exit $? fi diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 42f9b1c12..87b939c0e 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -20,6 +20,14 @@ usage() { die "Usage: $0 $USAGE" } +set_reflog_action() { + if [ -z "${GIT_REFLOG_ACTION:+set}" ] + then + GIT_REFLOG_ACTION="$*" + export GIT_REFLOG_ACTION + fi +} + if [ -z "$LONG_USAGE" ] then LONG_USAGE="Usage: $0 $USAGE" |