summaryrefslogtreecommitdiff
path: root/builtin/checkout.c
diff options
context:
space:
mode:
authorRamkumar Ramachandra <artagnon@gmail.com>2013-06-16 08:45:16 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-06-17 17:05:40 (GMT)
commit3bed291a3b121408b4de83f4fa3cc0f1d98c676e (patch)
tree16f042d3e943d922e5c9b007783cb109740b941b /builtin/checkout.c
parentec5063106449aa8c6623abbdcca862dd1516c920 (diff)
downloadgit-3bed291a3b121408b4de83f4fa3cc0f1d98c676e.zip
git-3bed291a3b121408b4de83f4fa3cc0f1d98c676e.tar.gz
git-3bed291a3b121408b4de83f4fa3cc0f1d98c676e.tar.bz2
checkout: respect GIT_REFLOG_ACTION
GIT_REFLOG_ACTION is an environment variable specifying the reflog message to write after an action is completed. Several other commands including merge, reset, and commit respect it. Fix the failing tests in t/checkout-last by making checkout respect it too. You can now expect $ git checkout - to work as expected after any operation that internally uses "checkout" as its implementation detail, e.g. "rebase". Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r--builtin/checkout.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 81b4419..79f4495 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -587,7 +587,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
struct branch_info *new)
{
struct strbuf msg = STRBUF_INIT;
- const char *old_desc;
+ const char *old_desc, *reflog_msg;
if (opts->new_branch) {
if (opts->new_orphan_branch) {
if (opts->new_branch_log && !log_all_ref_updates) {
@@ -620,8 +620,13 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
old_desc = old->name;
if (!old_desc && old->commit)
old_desc = sha1_to_hex(old->commit->object.sha1);
- strbuf_addf(&msg, "checkout: moving from %s to %s",
- old_desc ? old_desc : "(invalid)", new->name);
+
+ reflog_msg = getenv("GIT_REFLOG_ACTION");
+ if (!reflog_msg)
+ strbuf_addf(&msg, "checkout: moving from %s to %s",
+ old_desc ? old_desc : "(invalid)", new->name);
+ else
+ strbuf_insert(&msg, 0, reflog_msg, strlen(reflog_msg));
if (!strcmp(new->name, "HEAD") && !new->path && !opts->force_detach) {
/* Nothing to do. */