From: Junio C Hamano <gitster@pobox.com>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Ramkumar Ramachandra <artagnon@gmail.com>,
Git List <git@vger.kernel.org>
Subject: Re: [PATCH v2 6/7] rebase: write better reflog messages
Date: Wed, 19 Jun 2013 10:53:22 -0700 [thread overview]
Message-ID: <7v8v260yy5.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7vy5a611hb.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Wed, 19 Jun 2013 09:58:40 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> Excellent question, and I think this illustrates why the recent
> reroll that uses an approach to use base_reflog_action is not
> complete and needs further work (to put it mildly).
> ...
> That essentially boils down to the very original suggestion I made
> before Ram introduced the base_reflog_action.
So how about doing something like this?
Incidentally, I noticed that GIT_LITERAL_PATHSPECS:: heading in the
enumeration of environment variables is marked-up differently from
others, which is a low-hanging fruit somebody may want to fix.
Documentation/git-sh-setup.txt | 8 +++++---
Documentation/git.txt | 10 ++++++++++
git-sh-setup.sh | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-sh-setup.txt b/Documentation/git-sh-setup.txt
index 5d709d0..4f67c4c 100644
--- a/Documentation/git-sh-setup.txt
+++ b/Documentation/git-sh-setup.txt
@@ -41,9 +41,11 @@ usage::
die with the usage message.
set_reflog_action::
- set the message that will be recorded to describe the
- end-user action in the reflog, when the script updates a
- ref.
+ Set GIT_REFLOG_ACTION environment to a given string (typically
+ the name of the program) unless it is already set. Whenever
+ the script runs a `git` command that updates refs, a reflog
+ entry is created using the value of this string to leave the
+ record of what command updated the ref.
git_editor::
runs an editor of user's choice (GIT_EDITOR, core.editor, VISUAL or
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 2e23cbb..e2bdcc9 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -846,6 +846,16 @@ GIT_LITERAL_PATHSPECS::
literal paths to Git (e.g., paths previously given to you by
`git ls-tree`, `--raw` diff output, etc).
+'GIT_REFLOG_ACTION'::
+ When a ref is updated, reflog entries are created to keep
+ track of the reason why the ref was updated (which is
+ typically the name of the high-level command that updated
+ the ref), in addition to the old and new values of the ref.
+ A scripted Porcelain command can use set_reflog_action
+ helper function in `git-sh-setup` to set its name to this
+ variable when it is invoked as the top level command by the
+ end user, to be recorded in the body of the reflog.
+
Discussion[[Discussion]]
------------------------
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 2f78359..e5379bc 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
next prev parent reply other threads:[~2013-06-19 17:53 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 18:55 [PATCH v2 0/7] Re-roll rr/rebase-checkout-reflog Ramkumar Ramachandra
2013-06-18 18:55 ` [PATCH v2 1/7] t/t7512-status-help: test "HEAD detached from" Ramkumar Ramachandra
2013-06-18 18:55 ` [PATCH v2 2/7] wt-status: remove unused field in grab_1st_switch_cbdata Ramkumar Ramachandra
2013-06-18 18:55 ` [PATCH v2 3/7] t/t2012-checkout-last: test "checkout -" after a rebase Ramkumar Ramachandra
2013-06-18 18:55 ` [PATCH v2 4/7] status: do not depend on rebase reflog messages Ramkumar Ramachandra
2013-06-18 18:55 ` [PATCH v2 5/7] checkout: respect GIT_REFLOG_ACTION Ramkumar Ramachandra
2013-06-18 18:55 ` [PATCH v2 6/7] rebase: write better reflog messages Ramkumar Ramachandra
2013-06-18 20:35 ` Junio C Hamano
2013-06-19 5:39 ` Johannes Sixt
2013-06-19 6:09 ` Ramkumar Ramachandra
2013-06-19 6:24 ` Johannes Sixt
2013-06-19 16:58 ` Junio C Hamano
2013-06-19 17:53 ` Junio C Hamano [this message]
2013-06-19 18:29 ` Junio C Hamano
2013-06-18 18:55 ` [PATCH v2 7/7] rebase -i: " Ramkumar Ramachandra
2013-06-18 20:36 ` Junio C Hamano
2013-06-18 20:38 ` Ramkumar Ramachandra
2013-06-18 20:55 ` Junio C Hamano
2013-06-19 4:07 ` Ramkumar Ramachandra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7v8v260yy5.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=j.sixt@viscovery.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).