Skip to content

Commit

Permalink
reflog: always use current time
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipwood committed Dec 19, 2024
1 parent 23aca82 commit b1cd608
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
5 changes: 4 additions & 1 deletion refs/files-backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,10 @@ static int files_log_ref_write(struct files_ref_store *refs,
if (logfd < 0)
return 0;
result = log_ref_write_fd(logfd, old_oid, new_oid,
git_committer_info(0), msg);
fmt_ident(getenv("GIT_COMMITTER_NAME"),
getenv("GIT_COMMITTER_EMAIL"),
WANT_COMMITTER_IDENT, NULL, 0),
msg);
if (result) {
struct strbuf sb = STRBUF_INIT;
int save_errno = errno;
Expand Down
28 changes: 14 additions & 14 deletions t/t1400-update-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,19 @@ test_expect_success "clean up reflog" '

test_expect_success "create $m (logged by touch)" '
test_config core.logAllRefUpdates false &&
GIT_COMMITTER_DATE="2005-05-26 23:30" \
GIT_TEST_DATE_NOW=1117150200 \
git update-ref --create-reflog HEAD $A -m "Initial Creation" &&
test $A = $(git show-ref -s --verify $m)
'
test_expect_success "update $m (logged by touch)" '
test_config core.logAllRefUpdates false &&
GIT_COMMITTER_DATE="2005-05-26 23:31" \
GIT_TEST_DATE_NOW=1117150260 \
git update-ref HEAD $B $A -m "Switch" &&
test $B = $(git show-ref -s --verify $m)
'
test_expect_success "set $m (logged by touch)" '
test_config core.logAllRefUpdates false &&
GIT_COMMITTER_DATE="2005-05-26 23:41" \
GIT_TEST_DATE_NOW=1117150860 \
git update-ref HEAD $A &&
test $A = $(git show-ref -s --verify $m)
'
Expand All @@ -302,19 +302,19 @@ test_expect_success "verifying $m's log (logged by touch)" '

test_expect_success "create $m (logged by config)" '
test_config core.logAllRefUpdates true &&
GIT_COMMITTER_DATE="2005-05-26 23:32" \
GIT_TEST_DATE_NOW=1117150320 \
git update-ref HEAD $A -m "Initial Creation" &&
test $A = $(git show-ref -s --verify $m)
'
test_expect_success "update $m (logged by config)" '
test_config core.logAllRefUpdates true &&
GIT_COMMITTER_DATE="2005-05-26 23:33" \
GIT_TEST_DATE_NOW=1117150380 \
git update-ref HEAD $B $A -m "Switch" &&
test $B = $(git show-ref -s --verify $m)
'
test_expect_success "set $m (logged by config)" '
test_config core.logAllRefUpdates true &&
GIT_COMMITTER_DATE="2005-05-26 23:43" \
GIT_TEST_DATE_NOW=1117150980 \
git update-ref HEAD $A &&
test $A = $(git show-ref -s --verify $m)
'
Expand Down Expand Up @@ -445,24 +445,24 @@ test_expect_success 'query reflog with gap' '

test_expect_success 'creating initial files' '
test_when_finished rm -f M &&
test_tick &&
echo TEST >F &&
git add F &&
GIT_AUTHOR_DATE="2005-05-26 23:30" \
GIT_COMMITTER_DATE="2005-05-26 23:30" git commit -m add -a &&
GIT_TEST_DATE_NOW=1117150200 git commit -m add -a &&
test_tick &&
h_TEST=$(git rev-parse --verify HEAD) &&
echo The other day this did not work. >M &&
echo And then Bob told me how to fix it. >>M &&
echo OTHER >F &&
GIT_AUTHOR_DATE="2005-05-26 23:41" \
GIT_COMMITTER_DATE="2005-05-26 23:41" git commit -F M -a &&
GIT_TEST_DATE_NOW=1117150860 git commit -F M -a &&
test_tick &&
h_OTHER=$(git rev-parse --verify HEAD) &&
GIT_AUTHOR_DATE="2005-05-26 23:44" \
GIT_COMMITTER_DATE="2005-05-26 23:44" git commit --amend &&
GIT_TEST_DATE_NOW=1117151040 git commit --amend &&
test_tick &&
h_FIXED=$(git rev-parse --verify HEAD) &&
echo Merged initial commit and a later commit. >M &&
echo $h_TEST >.git/MERGE_HEAD &&
GIT_AUTHOR_DATE="2005-05-26 23:45" \
GIT_COMMITTER_DATE="2005-05-26 23:45" git commit -F M &&
GIT_TEST_DATE_NOW=1117151100 git commit -F M &&
h_MERGED=$(git rev-parse --verify HEAD)
'

Expand Down
5 changes: 1 addition & 4 deletions t/t1411-reflog-show.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh

test_expect_success 'setup' '
echo content >file &&
git add file &&
test_tick &&
git commit -m one
test_commit one file content
'

commit=$(git rev-parse --short HEAD)
Expand Down
9 changes: 6 additions & 3 deletions t/test-lib-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -397,21 +397,24 @@ test_commit () {
then
test_tick
fi &&
git ${indir:+ -C "$indir"} commit \
GIT_TEST_DATE_NOW=$test_tick TZ=PDT+7 \
git ${indir:+ -C "$indir"} commit \
${author:+ --author "$author"} \
$signoff -m "$1" &&
case "$tag" in
none)
;;
light)
git ${indir:+ -C "$indir"} tag "${4:-$1}"
GIT_TEST_DATE_NOW=$test_tick TZ=PDT+7 \
git ${indir:+ -C "$indir"} tag "${4:-$1}"
;;
annotate)
if test -z "$notick"
then
test_tick
fi &&
git ${indir:+ -C "$indir"} tag -a -m "$1" "${4:-$1}"
GIT_TEST_DATE_NOW=$test_tick TZ=PDT+7 \
git ${indir:+ -C "$indir"} tag -a -m "$1" "${4:-$1}"
;;
esac
}
Expand Down

0 comments on commit b1cd608

Please sign in to comment.