Skip to content

Commit

Permalink
pull: set reflog message
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Paul Tan <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
pyokagan authored and gitster committed Jun 18, 2015
1 parent 49ec402 commit 41fca09
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions builtin/pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,25 @@ static void argv_push_force(struct argv_array *arr)
argv_array_push(arr, "-f");
}

/**
* 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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 41fca09

Please sign in to comment.