Error "Could not get next commit. libgit returns: -4" in Log Messages dialog on commit with author date 1970-01-01T00:00:00Z
Summary
After updating TortoiseGit from 2.15.0 to 2.16.0 the "Log Messages" dialog shows an error "Could not get next commit. libgit returns: -4" if the current branch contains a commit with author date "1970-01-01T00:00:00Z" (Unix epoch).
What steps will reproduce the problem?
- In a non-empty git repository, create a git commit with author date timestamp 0 via
git commit --date "1970-01-01T00:00:00Z"
- Open the "Log Messages" dialog via
TortoiseGitProc.exe -command log
What is the expected output? What do you see instead?
I'd expect to see the commit history including and beyond the commit with that specific author date.
Instead, the history stops before that specific commit and an error dialog with the message mentioned above is shown.
What version of TortoiseGit and Git are you using? On what operating system?
2.16.0, Windows 11
Please provide any additional information below, e.g. possible fixes.
The new behavior seems to have been introduced in 3dbae2a3, more specifically with the check !author->Date
in git_parse_commit_author
.
author->Date
is set by calling parse_timestamp
(defined as strtoumax
), which returns 0 both on parsing errors, but also on parsing a valid "0".
As a fix, removing the check !author->Date
should be okay, as according to https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/strtoumax-strtoumax-l-wcstoumax-wcstoumax-l#return-value, if no conversion can be performed, in addition to the return value being 0, the end pointer should always be set to the start of the string, which is already checked in the code (end == pbuff
).
We are impacted by this issue as, somehow, unintentionally, a commit with this author date was pushed into our repo and fixing the author date via rebase is no viable option.