Bruno Haible <br...@clisp.org> writes: > Simon Josefsson wrote: >> I'm not sure I follow what you actually plan to do wrt multiple files >> X1, X2, ... Xn. Can you give some code example? Maybe I understand >> that better... > > Roughly like this (untested).
Oh, that is neat! But is there any advantage compared to simply using a global mtime for all files in the tarball? Is there any useful use of mtime except for dependency tracking triggering 'make' rebuilds? Using the same mtime for all files in a tarball is a lot easier than curate another mapping of source-to-build dependency list, which seems needed to figure out what is the most "relevant" mtime for each individual generated file inside a tarball. /Simon > # func_file_vmtime returns the virtual modification time of a file, > # as a number of seconds since the epoch. (*) > func_file_vmtime () > { > if test -n "$(git ls-files "$1")" && git diff --quiet HEAD "$1"; then > # file is under version control and is unmodified. > git log -1 --format=%ct "$1" > else > # file has been created or modified by the user. > stat --format=%Y "$1" > fi > } > > for file in X1 ... Xn; do > func_file_vmtime "$file" > done | LC_ALL=C sort -n | tail -n 1 > > (*) To compensate for fractional seconds, 1 second may need to be added > at the end. > > > Examples: > - Y = po/hello.pot, {X1, ..., Xn} = { po/POTFILES.in, src/hello.c } > - Y = lib/parse-datetime.c, {X1, ..., Xn} = { lib/parse-datetime.y } > - Y = package.tar, {X1, ..., Xn} = $(find package -type f) > > Bruno > > >
signature.asc
Description: PGP signature