MestreLion / git-tools

Assorted git tools, including git-restore-mtime
GNU General Public License v3.0
295 stars 74 forks source link

restore-mtime - git-commit-by-mtime - export of untracked code by mtime #62

Closed vic123 closed 11 months ago

vic123 commented 1 year ago

Hello, I've coded (very roughly) reverse operation for restore-mtime using your code as a template. Do not have any time for its further improvement. If you are interested I will create PR. Current code snapshot is attached. Thank you very much for an idea and implementation of mtime logic with regular git data.

git-commit-by-mtime.zip

MestreLion commented 11 months ago

And what exactly would be a "reverse operation"? You somehow store the current timestamps and then provide git-restore-mtime the ability to undo the timestamp modifications? Care to explain how exactly would this work?

vic123 commented 11 months ago

Commit files from work tree with --date={file modification time}. This way preserving {file modification time} as "author date" allowing it to be used by restore-mtime for restoring of {file modification time} to its original value.

Script:

In other words script just preserves {file modification time} as "author date" during commit, but as long as this requires separate commit for each {file modification time}, these commits are created on "helper" branch which then merged into "real" working branch.

MestreLion commented 11 months ago

I'm not sure how useful an "undo" feature would be, specially considering that the original timestamp is usually a bogus or meaningless one, such as the clone time.

Besides, an important feature of git-restore-mtime is to perform all operations in the working tree only, without changing or saving any data in the repository itself. Preserving the original timestamp, as required for an undo, is out of the scope for git-restore-mtime.

That said, there are tools that do exactly what you want: Metastore for example, saves all metadata in the git repository, including the timestamp. It can be used as an "undo" independently of git-restore-mtime.