All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Carr <jcarr@linuxmachines.com>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: git-ls-new-files & make patch, pull, etc.
Date: Thu, 08 Sep 2005 15:19:03 -0700	[thread overview]
Message-ID: <4320B8D7.7070004@linuxmachines.com> (raw)
In-Reply-To: <7virxdj45i.fsf@assigned-by-dhcp.cox.net>

[-- Attachment #1: Type: text/plain, Size: 1538 bytes --]

On 09/06/2005 02:08 PM, Junio C Hamano wrote:
> 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

[-- Attachment #2: git_restore_mtime --]
[-- Type: text/plain, Size: 1206 bytes --]

#!/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;
	}
}


  reply	other threads:[~2005-09-08 22:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-23  2:07 git-ls-new-files & make patch, pull, etc Jeff Carr
2005-08-23  5:15 ` Junio C Hamano
2005-09-06 20:42   ` Jeff Carr
2005-09-06 21:08     ` Junio C Hamano
2005-09-08 22:19       ` Jeff Carr [this message]
2005-09-09  3:19         ` Junio C Hamano
2005-08-23  6:48 ` Johannes Schindelin
2005-09-06 19:06   ` Jeff Carr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4320B8D7.7070004@linuxmachines.com \
    --to=jcarr@linuxmachines.com \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.