summaryrefslogtreecommitdiff
path: root/git-sh-setup.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-10-18 13:50:12 -0700
committerJunio C Hamano <gitster@pobox.com>2013-10-18 13:50:12 -0700
commit6c2bec96a8215bad7745d559c631e45332c5a9ee (patch)
tree23cf1f401779b2052407e42644853beb8f676cc3 /git-sh-setup.sh
parentdec034a34e3887beaea9a7a390fd950346806c1e (diff)
parentc3e2d18996e4ef92f37bf56b2fefe2124d26659e (diff)
downloadgit-6c2bec96a8215bad7745d559c631e45332c5a9ee.tar.gz
Merge branch 'jc/reflog-doc'
Document rules to use GIT_REFLOG_ACTION variable in the scripted Porcelain. git-rebase--interactive locally violates them, but it is a leaf user that does not call out to or dot-source other scripts, so it does not urgently need to be fixed. * jc/reflog-doc: setup_reflog_action: document the rules for using GIT_REFLOG_ACTION
Diffstat (limited to 'git-sh-setup.sh')
-rw-r--r--git-sh-setup.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index e15be51636..ebfe8f7a4d 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -103,6 +103,40 @@ $LONG_USAGE"
esac
fi
+# Set the name of the end-user facing command in the reflog when the
+# script may update refs. When GIT_REFLOG_ACTION is already set, this
+# will not overwrite it, so that a scripted Porcelain (e.g. "git
+# rebase") can set it to its own name (e.g. "rebase") and then call
+# another scripted Porcelain (e.g. "git am") and a call to this
+# function in the latter will keep the name of the end-user facing
+# program (e.g. "rebase") in GIT_REFLOG_ACTION, ensuring whatever it
+# does will be record as actions done as part of the end-user facing
+# operation (e.g. "rebase").
+#
+# NOTE NOTE NOTE: consequently, after assigning a specific message to
+# GIT_REFLOG_ACTION when calling a "git" command to record a custom
+# reflog message, do not leave that custom value in GIT_REFLOG_ACTION,
+# after you are done. Other callers of "git" commands that rely on
+# writing the default "program name" in reflog expect the variable to
+# contain the value set by this function.
+#
+# To use a custom reflog message, do either one of these three:
+#
+# (a) use a single-shot export form:
+# GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: preparing frotz" \
+# git command-that-updates-a-ref
+#
+# (b) save the original away and restore:
+# SAVED_ACTION=$GIT_REFLOG_ACTION
+# GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: preparing frotz"
+# git command-that-updates-a-ref
+# GIT_REFLOG_ACITON=$SAVED_ACTION
+#
+# (c) assign the variable in a subshell:
+# (
+# GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: preparing frotz"
+# git command-that-updates-a-ref
+# )
set_reflog_action() {
if [ -z "${GIT_REFLOG_ACTION:+set}" ]
then