Skip to content

Commit 41fca09

Browse files
pyokagangitster
authored andcommitted
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 <[email protected]> Signed-off-by: Paul Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 49ec402 commit 41fca09

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

builtin/pull.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,25 @@ static void argv_push_force(struct argv_array *arr)
168168
argv_array_push(arr, "-f");
169169
}
170170

171+
/**
172+
* Sets the GIT_REFLOG_ACTION environment variable to the concatenation of argv
173+
*/
174+
static void set_reflog_message(int argc, const char **argv)
175+
{
176+
int i;
177+
struct strbuf msg = STRBUF_INIT;
178+
179+
for (i = 0; i < argc; i++) {
180+
if (i)
181+
strbuf_addch(&msg, ' ');
182+
strbuf_addstr(&msg, argv[i]);
183+
}
184+
185+
setenv("GIT_REFLOG_ACTION", msg.buf, 0);
186+
187+
strbuf_release(&msg);
188+
}
189+
171190
/**
172191
* If pull.ff is unset, returns NULL. If pull.ff is "true", returns "--ff". If
173192
* pull.ff is "false", returns "--no-ff". If pull.ff is "only", returns
@@ -443,6 +462,9 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
443462
die_errno("could not exec %s", path);
444463
}
445464

465+
if (!getenv("GIT_REFLOG_ACTION"))
466+
set_reflog_message(argc, argv);
467+
446468
argc = parse_options(argc, argv, prefix, pull_options, pull_usage, 0);
447469

448470
parse_repo_refspecs(argc, argv, &repo, &refspecs);

0 commit comments

Comments
 (0)