git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Fastest way to set files date and time to latest commit time of each one

From
Andreas Schwab <schwab@linux-m68k.org>
Date
Aug 29, 2020, 06:46 UTC
Message-ID
<87bliu9cfd.fsf@linux-m68k.org>
In-Reply-To
<CAEbcw=3mOoYuJo2mQgqB2aJgn-D2i_7ZRmhfPvYNVHD1Kp8wuA@mail.gmail.com>
I'm using this script:
#!/bin/sh
git log --name-only --format=format:%n%ct -- "$@" |
perl -e 'my $do_date = 0; chomp(my $cdup = `git rev-parse --show-cdup`);
    while (<>) {
	chomp;
	if ($do_date) {
	    next if ($_ eq "");
	    die "Unexpected $_\n" unless /^[0-9]+$/;
	    $d = $_;
	    $do_date = 0;
	} elsif ($_ eq "") {
	    $do_date = 1;
	} elsif (!defined($seen{$_})) {
	    $seen{$_} = 1;
 	    utime $d, $d, "$cdup$_";
 	}
    }'
Andreas.
-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Previous: Ivan Baldo
Message 6 of 6 in “Fastest way to set files date and time to latest commit time of each one”
  1. Ivan BaldoAug 29, 2020
  2. Junio C HamanoAug 29, 2020
  3. Raymond E. PascoAug 29, 2020
  4. Eric WongAug 29, 2020
  5. Ivan BaldoSep 2, 2020
  6. Andreas SchwabAug 29, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.