* Howto update a 'dirty' entry in the cache from the object database
@ 2005-05-04 14:23 Thomas Glanzmann
2005-05-04 17:23 ` Linus Torvalds
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Glanzmann @ 2005-05-04 14:23 UTC (permalink / raw)
To: GIT
Hello,
I edited a bunch of files and notice that I want to revert back one of
the files to the original one (the one that comes with HEAD). But I
already updated the cache. Is there a way to 'patch' the cache with the
original file. Or do I need todo a read-tree into a temporary index
file. Check out the one file from this alternate index file and use
update-cache to update my original index file?
Thomas [ who want's a "git revert" ]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Howto update a 'dirty' entry in the cache from the object database
2005-05-04 14:23 Howto update a 'dirty' entry in the cache from the object database Thomas Glanzmann
@ 2005-05-04 17:23 ` Linus Torvalds
2005-05-04 17:37 ` Junio C Hamano
2005-05-04 19:20 ` Thomas Glanzmann
0 siblings, 2 replies; 4+ messages in thread
From: Linus Torvalds @ 2005-05-04 17:23 UTC (permalink / raw)
To: Thomas Glanzmann; +Cc: GIT
On Wed, 4 May 2005, Thomas Glanzmann wrote:
>
> I edited a bunch of files and notice that I want to revert back one of
> the files to the original one (the one that comes with HEAD). But I
> already updated the cache. Is there a way to 'patch' the cache with the
> original file.
Absolutely.
You can do it several ways. The easiest one is
git-read-tree -m HEAD
git-checkout-cache -f filename
but this means that you revert your entire index file to the old HEAD
information, so you'll need to do git-update-cache on the files that you
changed.
So:
> Or do I need todo a read-tree into a temporary index
> file. Check out the one file from this alternate index file and use
> update-cache to update my original index file?
Yes. If you want to touch just that one file, and you actually _want_ to
save all the other index information updates except for this one file. If
so, you can do
# read a new index file with the HEAD information
GIT_INDEX_FILE=tmp-index git-read-tree HEAD
# check out just the one file you want to have
GIT_INDEX_FILE=tmp-index git-checkout-cache -f filename
# remove the now useless temporary index
rm tmp-index
# update your _real_ index file with the file information
git-update-cache filename
and you're done - you've now updated only that _one_ file in your working
area, and you've re-set the index file for that entry.
And yes, scripting it so that you don't make stupid mistakes is probably a
good idea. For exmple, if you misspell GIT_INDEX_FILE (like I did when I
write that at first), you'd have reverted your real index file after all.
In other words, the git core certainly is very flexible and can easily do
what you want, but it's also certainly very very easy to screw up with.
Linus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Howto update a 'dirty' entry in the cache from the object database
2005-05-04 17:23 ` Linus Torvalds
@ 2005-05-04 17:37 ` Junio C Hamano
2005-05-04 19:20 ` Thomas Glanzmann
1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2005-05-04 17:37 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Thomas Glanzmann, GIT
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
LT> On Wed, 4 May 2005, Thomas Glanzmann wrote:
>>
>> I edited a bunch of files and notice that I want to revert back one of
>> the files to the original one (the one that comes with HEAD). But I
>> already updated the cache. Is there a way to 'patch' the cache with the
>> original file.
LT> Absolutely.
LT> You can do it several ways. The easiest one is
LT> git-read-tree -m HEAD
LT> git-checkout-cache -f filename
LT> but this means that you revert your entire index file to the old HEAD
LT> information, so you'll need to do git-update-cache on the files that you
LT> changed.
I think the easiest one that does not lose the cache for other
files is:
git-diff-cache -z HEAD |
GIT_EXTERNAL_DIFF=git-apply-patch-script \
git-diff-tree-helper -z -R filename
This means: find diff from HEAD to the cache, and apply the diff
in the reverse, only to the filename.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Howto update a 'dirty' entry in the cache from the object database
2005-05-04 17:23 ` Linus Torvalds
2005-05-04 17:37 ` Junio C Hamano
@ 2005-05-04 19:20 ` Thomas Glanzmann
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Glanzmann @ 2005-05-04 19:20 UTC (permalink / raw)
To: GIT
Hello,
> # read a new index file with the HEAD information
> GIT_INDEX_FILE=tmp-index git-read-tree HEAD
> # check out just the one file you want to have
> GIT_INDEX_FILE=tmp-index git-checkout-cache -f filename
> # remove the now useless temporary index
> rm tmp-index
> # update your _real_ index file with the file information
> git-update-cache filename
thanks. That is exactly what I was looking for.
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-05-04 19:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-04 14:23 Howto update a 'dirty' entry in the cache from the object database Thomas Glanzmann
2005-05-04 17:23 ` Linus Torvalds
2005-05-04 17:37 ` Junio C Hamano
2005-05-04 19:20 ` Thomas Glanzmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox