Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Modify author date in JGit
Modify author date in JGit [message #1853287] Sun, 26 June 2022 15:44 Go to next message
Kirill Likhodedov is currently offline Kirill LikhodedovFriend
Messages: 3
Registered: June 2022
Junior Member
Is it possible in JGit to set the author-date to a custom value, just like the `--author-date` parameter in native Git allows to do? Thanks a lot.
Re: Modify author date in JGit [message #1853291 is a reply to message #1853287] Sun, 26 June 2022 19:56 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
Construct a PersonIdent with a custom date and set it on CommitCommand using its setAuthor/setCommitter methods
Re: Modify author date in JGit [message #1853293 is a reply to message #1853291] Sun, 26 June 2022 23:16 Go to previous messageGo to next message
Kirill Likhodedov is currently offline Kirill LikhodedovFriend
Messages: 3
Registered: June 2022
Junior Member
Thanks a lot, it worked.

I've also found that the timestamp is of 1-second granularity, which means that two commits made quickly one after another will have the same author/commit time. Is there a way to make it more granular, e.g. of 1 millisecond?
Re: Modify author date in JGit [message #1853346 is a reply to message #1853293] Tue, 28 June 2022 16:43 Go to previous message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
The git commit storage format stores timestamps in seconds since the Unix epoch.
Using a higher precision would be questionable since git is a distributed versioning system where
versions can be created on different computers in parallel and later end up in the same repository via git transport (push/fetch).
And clocks on different computers are not guaranteed to be perfectly in sync.
Previous Topic:Retrieve User Name and Email Address from the Git Repo
Next Topic:JGit Maintenance
Goto Forum:
  


Current Time: Fri Apr 19 19:44:04 GMT 2024

Powered by FUDForum. Page generated in 0.03852 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top