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

Re: git-ls-new-files & make patch, pull, etc.

From
JCJeff Carr <jcarr@linuxmachines.com>
Date
Sep 8, 2005, 22:19 UTC
Message-ID
<4320B8D7.7070004@linuxmachines.com>
In-Reply-To
<7virxdj45i.fsf@assigned-by-dhcp.cox.net>
On 09/06/2005 02:08 PM, Junio C Hamano wrote:
Show 24 quoted lines
> Jeff Carr <jcarr@linuxmachines.com> writes:
> 
> 
>>... If I remember
>>correctly, there was some threads at the beginning of git about how
>>datestamps were not accurate so there was no point in setting them(?) Or
>>maybe I mis-understood.
> 
> 
> The point of those thread was that clocks on machines tend to be
> not so accurate and we should not take the timestamps *too*
> seriously.  We do record the time as accurately as the clock is
> maintained on the machine the commit is made, provided if the
> user does not override it with the GIT_COMMIT_DATE environment
> variable with a bogus value.
> 
> The way you use it to show changes made in a certain timeperiod
> is a good example that the information is useful.  The argument
> against relying on timestamp too much in that thread you are
> remembering was that it should not be used to see which commit
> came before which other commit when there is no parent-child
> ancestry between them.  It is still a useful hint, and we do use
> it as such, but as the recent merge-base fixes show it is just a
> hint and relying on it too much tends to screw things up.

OK, I understand better now. I was just setting the mtime via the last time the file showed up in the git-whatchanged output. When I check out a repository I do:

git-read-tree -m HEAD && git-checkout-cache -q -f -u -a git-restore-mtime

This is probably also a really bad reimplementation of something. :)

All and all, really enjoying using git. It's better. Jeff

#!/usr/bin/perl # parses git-whatchanged output and then # sets the mtime for all the files # copyleft GPL

use strict; use HTTP::Date;

# my $string = time2str($time); # Format as GMT ASCII time # my $now = str2time($string); # convert ASCII date to machine time

my $oldest = localtime(); my %allfiles; my $time;

# make a hash of all the files 
foreach my $file ( split "\n", `git-ls-files` ) {
	chomp $file;
	$allfiles{ $file } = 0;
}
# get the newest mtime for each one
foreach my $line ( `git-whatchanged` ) {
	chomp $line;
	my @parts = split " ", $line;
	if( $parts[0] eq "Date:" ) {
		shift @parts;
		pop @parts;
		$time = str2time( join " ", @parts );
		next;
	}
	if( $line =~ /^:/ ) {
		my $name = pop @parts;
		if( $allfiles{ $name } lt $time ) {
			# print "$name was $allfiles{ $name } now: $time\n";
			$allfiles{ $name } = $time;
		}
		if( $time lt $oldest ) {
			$oldest = $time;
		}
	}
}
# set the mtime for each one
foreach my $name ( sort keys %allfiles ) {
	if ( $allfiles{$name} eq 0 ) {
		# print "$name mtime $allfiles{$name}\n";
		utime $oldest, $oldest, $name;
	} else {
		# print "$name mtime $allfiles{$name}\n";
		utime $allfiles{$name}, $allfiles{$name}, $name;
	}
}
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 8 in “git-ls-new-files & make patch, pull, etc.”
  1. Jeff CarrAug 23, 2005
  2. Junio C HamanoAug 23, 2005
  3. Jeff CarrSep 6, 2005
  4. Junio C HamanoSep 6, 2005
  5. Jeff CarrSep 8, 2005
  6. Junio C HamanoSep 9, 2005
  7. Johannes SchindelinAug 23, 2005
  8. Jeff CarrSep 6, 2005

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.