Thread (1 message) 1 message, 1 author, 2016-06-15

Re: Howto update a 'dirty' entry in the cache from the object database

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:41:56

quoted
quoted
quoted
quoted
"LT" == Linus Torvalds [off-list ref] writes:
LT> On Wed, 4 May 2005, Thomas Glanzmann wrote:
quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help