git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Forcing rewrite of files in working tree
@ 2007-08-03 12:45 Andy Parkins
  2007-08-03 12:58 ` Rogan Dawes
  2007-08-03 19:55 ` Linus Torvalds
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Parkins @ 2007-08-03 12:45 UTC (permalink / raw)
  To: git

Hello,

I want to write a little recipe in a Makefile that ensures the $Id$ field in a 
series of text files is correct.  In case it's relevant, I'm including a load 
of asciidoc files as subsections into one master file; each file has a $Id$ 
field in the header, which very nicely prints out at the start of each 
section.  However, the $Id$ field is only written on checkout (not on checkin 
for fairly obvious reasons).  That means that for any files I've changed, the 
$Id$ is wrong.  Before I generate output using ASCIIdoc I'd like to ensure 
the $Id$ is correct.

How do I do it?

The only method I've found is to delete the file in the work tree then do 
git-checkout again.  Even with -f, if the file is not changed git doesn't 
perform a checkout again, so git-checkout -f is not sufficient.  I assume I 
can do what I want with some clever plumbing, but I don't know any 
plumbing. :-)



Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com

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

* Re: Forcing rewrite of files in working tree
  2007-08-03 12:45 Forcing rewrite of files in working tree Andy Parkins
@ 2007-08-03 12:58 ` Rogan Dawes
  2007-08-03 13:39   ` Andy Parkins
  2007-08-03 19:55 ` Linus Torvalds
  1 sibling, 1 reply; 4+ messages in thread
From: Rogan Dawes @ 2007-08-03 12:58 UTC (permalink / raw)
  To: Andy Parkins; +Cc: git

Andy Parkins wrote:
> Hello,
> 
> I want to write a little recipe in a Makefile that ensures the $Id$ field in a 
> series of text files is correct.  In case it's relevant, I'm including a load 
> of asciidoc files as subsections into one master file; each file has a $Id$ 
> field in the header, which very nicely prints out at the start of each 
> section.  However, the $Id$ field is only written on checkout (not on checkin 
> for fairly obvious reasons).  That means that for any files I've changed, the 
> $Id$ is wrong.  Before I generate output using ASCIIdoc I'd like to ensure 
> the $Id$ is correct.
> 
> How do I do it?
> 
> The only method I've found is to delete the file in the work tree then do 
> git-checkout again.  Even with -f, if the file is not changed git doesn't 
> perform a checkout again, so git-checkout -f is not sufficient.  I assume I 
> can do what I want with some clever plumbing, but I don't know any 
> plumbing. :-)
> 
> Andy

$ git reset --hard

?

Rogan

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

* Re: Forcing rewrite of files in working tree
  2007-08-03 12:58 ` Rogan Dawes
@ 2007-08-03 13:39   ` Andy Parkins
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Parkins @ 2007-08-03 13:39 UTC (permalink / raw)
  To: git; +Cc: Rogan Dawes

On Friday 2007 August 03, Rogan Dawes wrote:

> > The only method I've found is to delete the file in the work tree then do
> > git-checkout again.  Even with -f, if the file is not changed git doesn't
> > perform a checkout again, so git-checkout -f is not sufficient.  I assume
> > I can do what I want with some clever plumbing, but I don't know any
> > plumbing. :-)
>
> $ git reset --hard

I think that that suffers the same as "git-checkout -f"; if it doesn't see 
changes then it doesn't reread.  Also, it's not possible to do per-file:

$ git reset --hard HEAD somefile.txt
Cannot do partial --hard reset.

Which is a necessity really; I don't want to accidentally overwrite work 
that's not yet checked in in the rest of the tree.

Is git-checkout-index the thing I'm looking for?  I'm wondering if the "-n" 
switch is the trick?


Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com

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

* Re: Forcing rewrite of files in working tree
  2007-08-03 12:45 Forcing rewrite of files in working tree Andy Parkins
  2007-08-03 12:58 ` Rogan Dawes
@ 2007-08-03 19:55 ` Linus Torvalds
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Torvalds @ 2007-08-03 19:55 UTC (permalink / raw)
  To: Andy Parkins; +Cc: git



On Fri, 3 Aug 2007, Andy Parkins wrote:
> 
> I want to write a little recipe in a Makefile that ensures the $Id$ field in a 
> series of text files is correct.  In case it's relevant, I'm including a load 
> of asciidoc files as subsections into one master file; each file has a $Id$ 
> field in the header, which very nicely prints out at the start of each 
> section.  However, the $Id$ field is only written on checkout (not on checkin 
> for fairly obvious reasons).  That means that for any files I've changed, the 
> $Id$ is wrong.  Before I generate output using ASCIIdoc I'd like to ensure 
> the $Id$ is correct.
> 
> How do I do it?

Something like

	git read-tree HEAD
	git checkout -f

should do it.

The read-tree basically invalidated the index, by forcing it to the HEAD 
tree (and *without* doing a merge with the old index, so it doesn't get 
any of the size/date/inode fields right). And at that point, git thinks 
that all files are stale, so "git checkout -f" will force the checkout for 
all of them.

I'm sure you can do it other ways too, but that's the "obvious" one.

			Linus

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

end of thread, other threads:[~2007-08-03 19:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-03 12:45 Forcing rewrite of files in working tree Andy Parkins
2007-08-03 12:58 ` Rogan Dawes
2007-08-03 13:39   ` Andy Parkins
2007-08-03 19:55 ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).