-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit sorting is wrong when commits are from different timezones #4496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the report! Can you please confirm what is the value of your commit sort order currently? This is accessed via control + l The default behavior is to sort by Assuming you have selected Separately, on your point here:
I would not expect that to be the case. I would expect that the patch window would display the time in terms of the timezone that the author committed it in. This view is generated by a
which is produced here lazygit/pkg/commands/git_commands/commit.go Lines 261 to 276 in 3916549
which which without any configuration settings for a |
Okay, I've done some more digging. I wasn't even aware of the difference between commit timestamp and author timestamp prior to this. https://git-scm.com/docs/git-log#_commit_ordering for those similarly unaware. The LazyGit default of The order of commits comes from lazygit/pkg/commands/git_commands/commit_loader.go Lines 508 to 522 in 3916549
and I created this little bash script to set up a repo with some interesting properties. MUST RUN IN NEW DIRECTORY. WE NUKE .git
If I'm thinking straight, the literal timeline of events is commits 1 through 5 in number order. The LazyGit default of providing If we reset back to git's default by going into the Can you try out switching to the git default explicitly and tell us if the sort order still looks weird? I found no evidence of LazyGit code that does any sorting based on date, or timezone math, so fingers crossed it shouldn't be possible for us to screw up git's presumably correct algorithm. |
OK, so I tried all the options. |
Thanks for trying them out! I think your definition of correct and wrong might be misaligned with how git defines
In that attempt to "avoid showing commits on multiple lines of history intermixed", it is allowed (and even required) to show commits from different branches not in time order. Do you see LazyGit ordering any commits differently in the commit graph than a raw |
As commits are displayed one per line, I expect that they are displayed in chronological order, regardless of options. For me it is wrong when an older commit is listed above a newer commit. The repo I am looking at is hosted on GitLab. On its Repository Graph - the display is sorted chronologically. I also checked in several other clients and it is the same. It was only on lazygit that those two commits appeared switched. I tested Finally, I do not remember what was the sort option originally when I installed lazygit (as I switched it so many times already) but I would expect the default to be as it is in other clients - anything but "topo-order". |
Glad it's not a bug on our end! @stefanhaller @jesseduffield Do either of you have some context you can share about why |
I can't answer your first question, because this was done before I joined the project. As for the second question, yes, I definitely would keep topo-order as the default, I think this is the most reasonable default for most people. I think it should also be the default in command-line git, and I can only speculate why it isn't; maybe because of performance concerns (topo-order can be a lot slower in very large repositories). Honestly, I don't understand the OP's complaint about the order being "wrong" with topo-order; it's very deliberate to regroup the commits so that commits on a given branch are grouped together, and I think it makes a lot of sense. |
Describe the bug
Sorting the commits is based on date and time, but the timezones are not unified to the local one.
Therefore older commits appear higher in the list.
To Reproduce
Find a repo where people from different timezones have committed.
Expected behavior
I expect all commits of the repo to have CommitDate in the local timezone
Screenshots
not applicable - it's my company's data
Version info:
commit=5f809809dda06c98e51743ac8c19af6a26a5984b, build date=2025-04-14T08:30:35Z, build source=binaryRelease, version=0.49.0, os=darwin, arch=arm64, git version=2.49.0
git version 2.49.0
The text was updated successfully, but these errors were encountered: