Skip to content

Commit 47f870c

Browse files
committed
Merge branch 'ml/reflog-write-committer-info-fix'
"git reflog write" did not honor the configured user.name/email which has been corrected. * ml/reflog-write-committer-info-fix: builtin/reflog: respect user config in "write" subcommand
2 parents 79cf913 + 4a72736 commit 47f870c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

builtin/reflog.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@ static int cmd_reflog_write(int argc, const char **argv, const char *prefix,
418418
const char *ref, *message;
419419
int ret;
420420

421+
repo_config(repo, git_ident_config, NULL);
422+
421423
argc = parse_options(argc, argv, prefix, options, reflog_write_usage, 0);
422424
if (argc != 4)
423425
usage_with_options(reflog_write_usage, options);

t/t1421-reflog-write.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,42 @@ test_expect_success 'simple writes' '
108108
)
109109
'
110110

111+
test_expect_success 'uses user.name and user.email config' '
112+
test_when_finished "rm -rf repo" &&
113+
git init repo &&
114+
(
115+
cd repo &&
116+
test_commit initial &&
117+
COMMIT_OID=$(git rev-parse HEAD) &&
118+
119+
sane_unset GIT_COMMITTER_NAME &&
120+
sane_unset GIT_COMMITTER_EMAIL &&
121+
git config --local user.name "Author" &&
122+
git config --local user.email "[email protected]" &&
123+
git reflog write refs/heads/something $ZERO_OID $COMMIT_OID first &&
124+
test_reflog_matches . refs/heads/something <<-EOF
125+
$ZERO_OID $COMMIT_OID Author <[email protected]> $GIT_COMMITTER_DATE first
126+
EOF
127+
)
128+
'
129+
130+
test_expect_success 'environment variables take precedence over config' '
131+
test_when_finished "rm -rf repo" &&
132+
git init repo &&
133+
(
134+
cd repo &&
135+
test_commit initial &&
136+
COMMIT_OID=$(git rev-parse HEAD) &&
137+
138+
git config --local user.name "Author" &&
139+
git config --local user.email "[email protected]" &&
140+
git reflog write refs/heads/something $ZERO_OID $COMMIT_OID first &&
141+
test_reflog_matches . refs/heads/something <<-EOF
142+
$ZERO_OID $COMMIT_OID $SIGNATURE first
143+
EOF
144+
)
145+
'
146+
111147
test_expect_success 'can write to root ref' '
112148
test_when_finished "rm -rf repo" &&
113149
git init repo &&

0 commit comments

Comments
 (0)