git-store-meta icon indicating copy to clipboard operation
git-store-meta copied to clipboard

--timezone parameter

Open aaferrari opened this issue 4 years ago • 1 comments

It occurred to me to add the --timezone/-z parameter because of this issue, although the idea is to use it in cases like the following:

  1. Let's say that someone from Italy downloads a compressed archive from someone from Ukraine and creates a git repository with its content.
  2. After the first commit, he want to save the modification date of the original files and execute git-store-meta.pl before starting to work with them.
  3. When check the content of .git_store_meta he realize that the times on the dates do not correspond to those of Ukraine.

To make it clearer, download this archive, unzip it, run the command perl .git/hooks/git-store-meta.pl --store -n and compare the output with the saved .git_store_meta, you will probably see something like test.txt f 2020-04-02T19:23:50Z. This mismatch occurs because when unpacking a compressed archive the system usually assumes that the dates on the files correspond to the local time because the compressed archives do not retain the original time zone. Since Perl doesn't have a transparent way to change the time zones in the timestamps (or if there is one then I haven't figured it out yet) I had to add the time_compensator function that does the corresponding adjustment. I was testing it with the repository of this script and with another one I'm working on and it seems to work fine (even so I don't rule out that there might be undiscovered errors). Something I noticed is that when using --timezone together with --update, the adjustment in the dates is not maintained, any idea why this is? It should be noted that --timezone does not take into account unusual time zones nor summer/winter time, but should be sufficient for most cases.

aaferrari avatar Apr 03 '20 07:04 aaferrari