summaryrefslogtreecommitdiff
path: root/builtin/pull.c
diff options
context:
space:
mode:
authorPaul Tan <pyokagan@gmail.com>2015-06-18 18:54:07 +0800
committerJunio C Hamano <gitster@pobox.com>2015-06-18 13:17:39 -0700
commit41fca0989e7ebf3e809e08840c89f44021aa1f2c (patch)
treed2d751630211913629f8a11c688eeb747ffe4f6e /builtin/pull.c
parent49ec402d52dc8f8e55e62537c95766b623e63d6b (diff)
downloadgit-41fca0989e7ebf3e809e08840c89f44021aa1f2c.tar.gz
pull: set reflog message
f947413 (Use GIT_REFLOG_ACTION environment variable instead., 2006-12-28) established git-pull's method for setting the reflog message, which is to set the environment variable GIT_REFLOG_ACTION to the evaluation of "pull${1+ $*}" if it has not already been set. Re-implement this behavior. Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Paul Tan <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/pull.c')
-rw-r--r--builtin/pull.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/builtin/pull.c b/builtin/pull.c
index 492bb0e28c..98caffee3f 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -169,6 +169,25 @@ static void argv_push_force(struct argv_array *arr)
}
/**
+ * Sets the GIT_REFLOG_ACTION environment variable to the concatenation of argv
+ */
+static void set_reflog_message(int argc, const char **argv)
+{
+ int i;
+ struct strbuf msg = STRBUF_INIT;
+
+ for (i = 0; i < argc; i++) {
+ if (i)
+ strbuf_addch(&msg, ' ');
+ strbuf_addstr(&msg, argv[i]);
+ }
+
+ setenv("GIT_REFLOG_ACTION", msg.buf, 0);
+
+ strbuf_release(&msg);
+}
+
+/**
* If pull.ff is unset, returns NULL. If pull.ff is "true", returns "--ff". If
* pull.ff is "false", returns "--no-ff". If pull.ff is "only", returns
* "--ff-only". Otherwise, if pull.ff is set to an invalid value, die with an
@@ -443,6 +462,9 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
die_errno("could not exec %s", path);
}
+ if (!getenv("GIT_REFLOG_ACTION"))
+ set_reflog_message(argc, argv);
+
argc = parse_options(argc, argv, prefix, pull_options, pull_usage, 0);
parse_repo_refspecs(argc, argv, &repo, &refspecs);