Hi Paul, Here is a tentative implementation of the proposed --set-mtime-command option: [1].
Two new options are implemented: --set-mtime-command=COMMAND, which defines the shell command which outputs mtime for the archive member being added, and --set-mtime-format=FMT, which defines the format of its output, in the sense of strptime(3). If the latter is not specified, parse_gettime will be used to parse it. Here is the modified version of your Makefile that uses this feature: https://github.com/graygnuorg/tz/blob/main/Makefile I've taken care to make the new feature optional, so it continues to work with older tar versions as well. Produced archives are equivalent in both cases. Notice several problems with this approach: 1. When COMMAND returns empty output (e.g. when given a file that is not in the repository), tar issues a warning message. Perhaps a correspondig --warning control will be needed to disable it. 2. The command [2] implies additional complication, because it is executed in subdirectory. Two additional variables are defined because of this: TARMTIMEFLAGS, which defines the --set-mtime-command option to use when calling tar from the git local tree, and TARUPDIRMTIMEFLAGS, defining the option to use when running tar in a subdirectory. A better solution would be possible if instead of of simply passing the file name to the command, --set-mtime-command used some kind of variable expansion, e.g. --set-mtime-command="git log -1 --format='tformat:%cI' ../$file" 3. Command execution timeout should be implemented, perhaps. Opinions? Regards, Sergey [1] http://git.savannah.gnu.org/cgit/tar.git/commit/?id=9a30bb267430eb1b69151f947cf4613803182c61 [2] https://github.com/graygnuorg/tz/blob/e1e0f321af3b5e2cf7134455ca7a4151cbfb5d70/Makefile#L1177