Git development
 help / color / mirror / Atom feed
* Implementing $Date$ substitution - problem with git status
@ 2009-08-09 19:37 Peter Krefting
  2009-08-09 20:52 ` Johannes Sixt
  2009-08-13  6:47 ` Implementing $Date$ substitution - solution using pre-commit Peter Krefting
  0 siblings, 2 replies; 8+ messages in thread
From: Peter Krefting @ 2009-08-09 19:37 UTC (permalink / raw)
  To: Git List

Hi!

I finally got around to moving my web site repository over from CVS to Git, 
and to not have to redo everything about how it is set up, I set up a filter 
that fakes CVS' handling of "$Date$" keywords. Since I cannot access any 
information about the file from the "smudge" filter, I set up a "clean" 
filter that edits the $Date$ token on "git add":

   #!/usr/bin/perl -wTp -i.bak
   if (/\$Date:?[^\$]*\$/)
   {
     my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
     my $now = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $year + 1900,
                       $mon + 1, $mday, $hour, $min, $sec);
     s/\$Date:?[^\$]*\$/\$Date: ${now} \$/;
   }

In .gitattributes I have lines like:

   *.html filter=date crlf=true ident

and filter.date.clean is set to point to the script above in .git/config.

This works fine, except that I have some problems with files that I cannot 
get to be "clean" in git status. "git diff" shows only a difference in the 
"$Date$" token, which is different each time I run "git diff" (the "+" line 
shows the current time):

   diff --git a/.htaccess b/.htaccess
   index 2dfbc32..d8ac343 100644
   --- a/.htaccess
   +++ b/.htaccess
   @@ -2,7 +2,7 @@
    # -----------------------------------------------------

    # $Id$
   -# $Date: 2009-08-09 19:52:30 $
   +# $Date: 2009-08-09 20:31:56 $
   [...]

Strangely, the $Id$ line above (which is handled by me adding the "ident" 
attribute to all text files), does not exhibit the same problem.

Doing "git reset --hard" or "git checkout master filename" does not help, 
the file is still believed to be modified by git.


Does anyone know if there is a way to get this to work, or am I screwed for 
trying to do things I'm not supposed to? :-)

-- 
\\// Peter - http://www.softwolves.pp.se/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-08-13  6:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-09 19:37 Implementing $Date$ substitution - problem with git status Peter Krefting
2009-08-09 20:52 ` Johannes Sixt
2009-08-10  4:41   ` Peter Krefting
2009-08-12  6:54   ` Peter Krefting
2009-08-12  8:36     ` Problems with filters and git status - reproduction steps Peter Krefting
2009-08-12  8:55       ` Michael J Gruber
2009-08-12  9:25         ` Peter Krefting
2009-08-13  6:47 ` Implementing $Date$ substitution - solution using pre-commit Peter Krefting

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox