{"thread":{"id":"6139","subject":"[PATCH 1/11] Use GIT_REFLOG_ACTION environment variable instead.","startedAt":"2006-12-28T07:34:48Z","lastAt":"2006-12-28T07:34:48Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":11},"messages":[{"id":"30405","messageId":"20061228073448.GA17867@spearce.org","threadId":"6139","inReplyTo":null,"subject":"[PATCH 1/11] Use GIT_REFLOG_ACTION environment variable instead.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-12-28T07:34:48Z","receivedAt":"2006-12-28T07:34:48Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio rightly pointed out that the --reflog-action parameter\nwas starting to get out of control, as most porcelain code\nneeded to hand it to other porcelain and plumbing alike to\nensure the reflog contained the top-level user action and\nnot the lower-level actions it invoked.\n\nAt Junio's suggestion we are introducing the new set_reflog_action\nfunction to all shell scripts, allowing them to declare early on\nwhat their default reflog name should be, but this setting only\ntakes effect if the caller has not already set the GIT_REFLOG_ACTION\nenvironment variable.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n Documentation/git-merge.txt |    6 ------\n git-am.sh                   |    7 ++-----\n git-fetch.sh                |   21 ++++++++-------------\n git-merge.sh                |   13 +++++--------\n git-pull.sh                 |    6 +++---\n git-rebase.sh               |   10 ++++------\n git-sh-setup.sh             |    8 ++++++++\n 7 files changed, 30 insertions(+), 41 deletions(-)\n\ndiff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt\nindex e2954aa..0f79665 100644\n--- a/Documentation/git-merge.txt\n+++ b/Documentation/git-merge.txt\n@@ -10,7 +10,6 @@ SYNOPSIS\n --------\n [verse]\n 'git-merge' [-n] [--no-commit] [--squash] [-s <strategy>]...\n-\t[--reflog-action=<action>]\n \t-m=<msg> <remote> <remote>...\n \n DESCRIPTION\n@@ -37,11 +36,6 @@ include::merge-options.txt[]\n \tleast one <remote>.  Specifying more than one <remote>\n \tobviously means you are trying an Octopus.\n \n---reflog-action=<action>::\n-\tThis is used internally when `git-pull` calls this command\n-\tto record that the merge was created by `pull` command\n-\tin the `ref-log` entry that results from the merge.\n-\n include::merge-strategies.txt[]\n \n \ndiff --git a/git-am.sh b/git-am.sh\nindex 0126a77..c3bbd78 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -6,6 +6,7 @@ USAGE='[--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way]\n   [--interactive] [--whitespace=<option>] <mbox>...\n   or, when resuming [--skip | --resolved]'\n . git-sh-setup\n+set_reflog_action am\n \n git var GIT_COMMITTER_IDENT >/dev/null || exit\n \n@@ -101,7 +102,6 @@ It does not apply to blobs recorded in its index.\"\n }\n \n prec=4\n-rloga=am\n dotest=.dotest sign= utf8= keep= skip= interactive= resolved= binary= ws= resolvemsg=\n \n while case \"$#\" in 0) break;; esac\n@@ -141,9 +141,6 @@ do\n \t--resolvemsg=*)\n \tresolvemsg=$(echo \"$1\" | sed -e \"s/^--resolvemsg=//\"); shift ;;\n \n-\t--reflog-action=*)\n-\trloga=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`; shift ;;\n-\n \t--)\n \tshift; break ;;\n \t-*)\n@@ -452,7 +449,7 @@ do\n \tparent=$(git-rev-parse --verify HEAD) &&\n \tcommit=$(git-commit-tree $tree -p $parent <\"$dotest/final-commit\") &&\n \techo Committed: $commit &&\n-\tgit-update-ref -m \"$rloga: $SUBJECT\" HEAD $commit $parent ||\n+\tgit-update-ref -m \"$GIT_REFLOG_ACTION: $SUBJECT\" HEAD $commit $parent ||\n \tstop_here $this\n \n \tif test -x \"$GIT_DIR\"/hooks/post-applypatch\ndiff --git a/git-fetch.sh b/git-fetch.sh\nindex 5f31605..8bd11f8 100755\n--- a/git-fetch.sh\n+++ b/git-fetch.sh\n@@ -4,6 +4,8 @@\n USAGE='<fetch-options> <repository> <refspec>...'\n SUBDIRECTORY_OK=Yes\n . git-sh-setup\n+set_reflog_action \"fetch $*\"\n+\n TOP=$(git-rev-parse --show-cdup)\n if test ! -z \"$TOP\"\n then\n@@ -17,7 +19,6 @@ LF='\n '\n IFS=\"$LF\"\n \n-rloga=fetch\n no_tags=\n tags=\n append=\n@@ -60,9 +61,6 @@ do\n \t-k|--k|--ke|--kee|--keep)\n \t\tkeep='-k -k'\n \t\t;;\n-\t--reflog-action=*)\n-\t\trloga=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n-\t\t;;\n \t--depth=*)\n \t\tshallow_depth=\"--depth=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\"\n \t\t;;\n@@ -94,9 +92,6 @@ refs=\n rref=\n rsync_slurped_objects=\n \n-rloga=\"$rloga $remote_nick\"\n-test \"$remote_nick\" = \"$remote\" || rloga=\"$rloga $remote\"\n-\n if test \"\" = \"$append\"\n then\n \t: >\"$GIT_DIR/FETCH_HEAD\"\n@@ -180,12 +175,12 @@ update_local_ref () {\n \t\telse\n \t\t\techo >&2 \"* $1: updating with $3\"\n \t\t\techo >&2 \"  $label_: $newshort_\"\n-\t\t\tgit-update-ref -m \"$rloga: updating tag\" \"$1\" \"$2\"\n+\t\t\tgit-update-ref -m \"$GIT_REFLOG_ACTION: updating tag\" \"$1\" \"$2\"\n \t\tfi\n \telse\n \t\techo >&2 \"* $1: storing $3\"\n \t\techo >&2 \"  $label_: $newshort_\"\n-\t\tgit-update-ref -m \"$rloga: storing tag\" \"$1\" \"$2\"\n+\t\tgit-update-ref -m \"$GIT_REFLOG_ACTION: storing tag\" \"$1\" \"$2\"\n \tfi\n \t;;\n \n@@ -208,7 +203,7 @@ update_local_ref () {\n \t    *,$local)\n \t\techo >&2 \"* $1: fast forward to $3\"\n \t\techo >&2 \"  old..new: $oldshort_..$newshort_\"\n-\t\tgit-update-ref -m \"$rloga: fast-forward\" \"$1\" \"$2\" \"$local\"\n+\t\tgit-update-ref -m \"$GIT_REFLOG_ACTION: fast-forward\" \"$1\" \"$2\" \"$local\"\n \t\t;;\n \t    *)\n \t\tfalse\n@@ -218,7 +213,7 @@ update_local_ref () {\n \t\t*,t,*)\n \t\t\techo >&2 \"* $1: forcing update to non-fast forward $3\"\n \t\t\techo >&2 \"  old...new: $oldshort_...$newshort_\"\n-\t\t\tgit-update-ref -m \"$rloga: forced-update\" \"$1\" \"$2\" \"$local\"\n+\t\t\tgit-update-ref -m \"$GIT_REFLOG_ACTION: forced-update\" \"$1\" \"$2\" \"$local\"\n \t\t\t;;\n \t\t*)\n \t\t\techo >&2 \"* $1: not updating to non-fast forward $3\"\n@@ -230,7 +225,7 @@ update_local_ref () {\n \telse\n \t    echo >&2 \"* $1: storing $3\"\n \t    echo >&2 \"  $label_: $newshort_\"\n-\t    git-update-ref -m \"$rloga: storing head\" \"$1\" \"$2\"\n+\t    git-update-ref -m \"$GIT_REFLOG_ACTION: storing head\" \"$1\" \"$2\"\n \tfi\n \t;;\n     esac\n@@ -479,7 +474,7 @@ case \"$orig_head\" in\n \tif test \"$curr_head\" != \"$orig_head\"\n \tthen\n \t    git-update-ref \\\n-\t\t\t-m \"$rloga: Undoing incorrectly fetched HEAD.\" \\\n+\t\t\t-m \"$GIT_REFLOG_ACTION: Undoing incorrectly fetched HEAD.\" \\\n \t\t\tHEAD \"$orig_head\"\n \t\tdie \"Cannot fetch into the current branch.\"\n \tfi\ndiff --git a/git-merge.sh b/git-merge.sh\nindex 022d01e..c7e033c 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -3,9 +3,10 @@\n # Copyright (c) 2005 Junio C Hamano\n #\n \n-USAGE='[-n] [--no-commit] [--squash] [-s <strategy>] [--reflog-action=<action>] [-m=<merge-message>] <commit>+'\n+USAGE='[-n] [--no-commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commit>+'\n \n . git-sh-setup\n+set_reflog_action \"merge $*\"\n \n LF='\n '\n@@ -57,10 +58,10 @@ squash_message () {\n finish () {\n \tif test '' = \"$2\"\n \tthen\n-\t\trlogm=\"$rloga\"\n+\t\trlogm=\"$GIT_REFLOG_ACTION\"\n \telse\n \t\techo \"$2\"\n-\t\trlogm=\"$rloga: $2\"\n+\t\trlogm=\"$GIT_REFLOG_ACTION: $2\"\n \tfi\n \tcase \"$squash\" in\n \tt)\n@@ -154,7 +155,7 @@ merge_name () {\n \n case \"$#\" in 0) usage ;; esac\n \n-rloga= have_message=\n+have_message=\n while case \"$#\" in 0) break ;; esac\n do\n \tcase \"$1\" in\n@@ -184,9 +185,6 @@ do\n \t\t\tdie \"available strategies are: $all_strategies\" ;;\n \t\tesac\n \t\t;;\n-\t--reflog-action=*)\n-\t\trloga=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n-\t\t;;\n \t-m=*|--m=*|--me=*|--mes=*|--mess=*|--messa=*|--messag=*|--message=*)\n \t\tmerge_msg=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n \t\thave_message=t\n@@ -258,7 +256,6 @@ head=$(git-rev-parse --verify \"$head_arg\"^0) || usage\n \n # All the rest are remote heads\n test \"$#\" = 0 && usage ;# we need at least one remote head.\n-test \"$rloga\" = '' && rloga=\"merge: $@\"\n \n remoteheads=\n for remote\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 1703091..fd4ffb8 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -7,6 +7,7 @@\n USAGE='[-n | --no-summary] [--no-commit] [-s strategy]... [<fetch-options>] <repo> <head>...'\n LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEAD.'\n . git-sh-setup\n+set_reflog_action \"pull $*\"\n \n strategy_args= no_summary= no_commit= squash=\n while case \"$#,$1\" in 0) break ;; *,-*) ;; *) break ;; esac\n@@ -45,7 +46,7 @@ do\n done\n \n orig_head=$(git-rev-parse --verify HEAD 2>/dev/null)\n-git-fetch --update-head-ok --reflog-action=pull \"$@\" || exit 1\n+git-fetch --update-head-ok \"$@\" || exit 1\n \n curr_head=$(git-rev-parse --verify HEAD 2>/dev/null)\n if test \"$curr_head\" != \"$orig_head\"\n@@ -118,6 +119,5 @@ case \"$strategy_args\" in\n esac\n \n merge_name=$(git-fmt-merge-msg <\"$GIT_DIR/FETCH_HEAD\") || exit\n-git-merge \"--reflog-action=pull $*\" \\\n-\t$no_summary $no_commit $squash $strategy_args \\\n+git-merge $no_summary $no_commit $squash $strategy_args \\\n \t\"$merge_name\" HEAD $merge_head\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex ece3142..5c7c4a6 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -28,6 +28,7 @@ Example:       git-rebase master~1 topic\n   D---E---F---G master          D---E---F---G master\n '\n . git-sh-setup\n+set_reflog_action rebase\n \n RESOLVEMSG=\"\n When you have resolved this problem run \\\"git rebase --continue\\\".\n@@ -132,8 +133,7 @@ do\n \t\t\tfinish_rb_merge\n \t\t\texit\n \t\tfi\n-\t\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" \\\n-\t\t\t--reflog-action=rebase\n+\t\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\"\n \t\texit\n \t\t;;\n \t--skip)\n@@ -156,8 +156,7 @@ do\n \t\t\tfinish_rb_merge\n \t\t\texit\n \t\tfi\n-\t\tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\" \\\n-\t\t\t--reflog-action=rebase\n+\t\tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\"\n \t\texit\n \t\t;;\n \t--abort)\n@@ -306,8 +305,7 @@ fi\n if test -z \"$do_merge\"\n then\n \tgit-format-patch -k --stdout --full-index --ignore-if-in-upstream \"$upstream\"..ORIG_HEAD |\n-\tgit am --binary -3 -k --resolvemsg=\"$RESOLVEMSG\" \\\n-\t\t--reflog-action=rebase\n+\tgit am --binary -3 -k --resolvemsg=\"$RESOLVEMSG\"\n \texit $?\n fi\n \ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 42f9b1c..87b939c 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -20,6 +20,14 @@ usage() {\n \tdie \"Usage: $0 $USAGE\"\n }\n \n+set_reflog_action() {\n+\tif [ -z \"${GIT_REFLOG_ACTION:+set}\" ]\n+\tthen\n+\t\tGIT_REFLOG_ACTION=\"$*\"\n+\t\texport GIT_REFLOG_ACTION\n+\tfi\n+}\n+\n if [ -z \"$LONG_USAGE\" ]\n then\n \tLONG_USAGE=\"Usage: $0 $USAGE\"\n-- \n1.4.4.3.gd2e4\n"}]}