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. Signed-off-by: Stephen Robin <stephen.robin@xxxxxxxxx> Signed-off-by: Paul Tan <pyokagan@xxxxxxxxx> --- builtin/pull.c | 23 +++++++++++++++++++++++ t/t5520-pull.sh | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index ba2ff01..81e31a1 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -212,6 +212,26 @@ 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++) { + strbuf_addstr(&msg, argv[i]); + strbuf_addch(&msg, ' '); + } + + strbuf_rtrim(&msg); + + setenv("GIT_REFLOG_ACTION", msg.buf, 0); + + strbuf_release(&msg); +} + +/** * If pull.ff is "true", returns "--ff". If pull.ff is "false", returns * "--no-ff". If pull.ff is "only", returns "--ff-only". Otherwise, returns * NULL. @@ -492,6 +512,9 @@ int cmd_pull(int argc, const char **argv, const char *prefix) struct sha1_array merge_heads = SHA1_ARRAY_INIT; unsigned char orig_head[GIT_SHA1_RAWSZ], curr_head[GIT_SHA1_RAWSZ]; + 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); diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index 2131749..9414cc1 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -85,7 +85,7 @@ test_expect_success 'pulling into void must not create an octopus' ' ) ' -test_expect_failure 'test . as a remote' ' +test_expect_success 'test . as a remote' ' git branch copy master && git config branch.copy.remote . && git config branch.copy.merge refs/heads/master && @@ -101,7 +101,7 @@ test_expect_failure 'test . as a remote' ' test_cmp reflog.expected reflog.fuzzy ' -test_expect_failure 'the default remote . should not break explicit pull' ' +test_expect_success 'the default remote . should not break explicit pull' ' git checkout -b second master^ && echo modified >file && git commit -a -m modified && -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html