All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Hudec <bulb@ucw.cz>
To: Peter Karlsson <peter@softwolves.pp.se>
Cc: git@vger.kernel.org, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: RCS keyword expansion
Date: Fri, 12 Oct 2007 14:57:51 +0200	[thread overview]
Message-ID: <20071012125751.GB7865@efreet.light.src> (raw)
In-Reply-To: <Pine.LNX.4.64.0710121144001.3682@ds9.cixit.se>

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

On Fri, Oct 12, 2007 at 11:50:51 +0100, Peter Karlsson wrote:
> > But don't you see?  When switching branches, this totally breaks down.
> 
> Why would it? If the file is the same on both branches, nothing would
> happen (it is still the same version), and if the file is different, it
> gets changed anyway, and a new keyword expansion would take place.

It does not -- the blob ID is the same. And you can indeed get $Id$ expanded
to that (see gitattributes(5)). However, that's the ONLY thing that is the
same. The date of last modification or ID of commit that last touched that
file might not.

Why? Because git tracks content, not history. The trees and blobs (files) are
identified by SHA1 hashes of their content. Only commit objects add the
notion of history. Thus if two commits contain file with the same text, it's
the same file. Even if the file is the same in those commit purely by
accident.

> > No, really, IMHO it is enough to show either the commit name or the
> > blob name of the file. After all, you are not interested in the date
> > that this file was last committed, but in the _contents_.
> 
> Yes, but I want it on the lowest addressable unit size, i.e on the file
> level (I could possibly want to have the last commit for a set of files
> when I have something that get generated from several sources, but that
> is rare for a regular website, unless since javascripts and stylesheets
> etc. are delivered separately).
> 
> Already today when you do "git log" on a file, you get the log filtered
> for only changes to that file. So the mechanisms seem already to be
> there, I just need to figure out how to apply them to what I want.

Yes. But you need the (current) commit for that. Now if a file foo is the
same on branches A and B, switching between them will not touch that file,
but git log foo may well give you completely different results. That's why
there's no date or commit that last touched a file.

> > So why not go for the contents?  With CVS/SVN you only have the
> > chance to do that by date or version number. With git, we have a more
> > powerful way: we do it by a hash of the contents.
> 
> Yes, but the hash if of "everything". I'm not interested in
> "everything" in this context, and I don't want to have a separate git
> repository for each file...
> 
> > If it's not what you want, I suggest rethinking what you want ;-)
> > Otherwise it is scripting time for you.  It's easy enough with git.
> 
> That's what I'm trying to figure out. I assume it would be possible to
> do with some kind of hook that is run on checkout. But I can't figure
> out how to do that.

If you read the (already mentioned) gitattributes(5) manpage, you'll find
description of smudge and clean filters. They will be applied to each file
written out to the tree and read back respectively. But be sure to understand
why you can't -- for principial, not techical reasons -- have the date or
commit ID expanded correctly in all cases.

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2007-10-12 12:58 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-11 14:47 RCS keyword expansion Peter Karlsson
2007-10-11 15:02 ` Johannes Sixt
2007-10-11 15:09 ` Randal L. Schwartz
2007-10-11 15:59   ` Oliver Kullmann
2007-10-11 18:09     ` Alex Riesen
2007-10-11 20:47     ` Johannes Schindelin
2007-10-11 21:35       ` Sam Vilain
2007-10-12  5:26       ` Peter Karlsson
2007-10-12 10:02         ` Johannes Schindelin
2007-10-12 10:50           ` Peter Karlsson
2007-10-12 11:05             ` Johannes Sixt
2007-10-12 11:21             ` Lars Hjemli
2007-10-12 11:34             ` Johannes Schindelin
2007-10-15 14:03               ` Peter Karlsson
2007-10-15 14:28                 ` Johannes Schindelin
2007-10-12 12:57             ` Jan Hudec [this message]
2007-10-12 19:08         ` Salikh Zakirov
2007-10-12 22:42           ` Johannes Schindelin
2007-10-12 23:52             ` Zakirov Salikh
2007-10-11 17:55   ` Peter Karlsson
2007-10-11 19:21     ` Alex Riesen
2007-10-12  5:27       ` Peter Karlsson
2007-10-12 17:05         ` Barry Fishman
2007-10-12 17:44           ` Linus Torvalds
2007-10-12 17:51           ` Florian Weimer
2007-10-11 21:20     ` Sam Vilain
2007-10-11 19:16 ` Lars Hjemli

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=20071012125751.GB7865@efreet.light.src \
    --to=bulb@ucw.cz \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=peter@softwolves.pp.se \
    /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.