Re: selective git-update-index per diff(1) chunks

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Alexey Dobriyan <adobriyan@...>
Cc: <git@...>
Date: Friday, December 1, 2006 - 12:06 pm

On Fri, 1 Dec 2006, Alexey Dobriyan wrote:

You can already do it, but it's called something else.

Instead of updating a certain hunk (which is fundamentally wrong, since it 
depends on "diff" even working on that file), you can tell 
git-update-index to update a certain _state_ for an arbitrary number of 
files. Namely:

	git-update-index [--cacheinfo <mode> <object> <file>]*

However, that obviously is very much a _plumbing_ command, and you need to 
have some higher-level GUI on top of it to actually pick out the chunks 
(if that is what you want) and generate the object(s) associated with the 
file(s) with only those chunks and then do the above "install this state 
into the index/staging area/whatever".

In other words, git already supports this on a _technical_ level, but does 
not have the high-level interfaces for it, and quite frankly 
"git-update-index" _shouldn't_ have the high-level interfaces for it. It's 
designed to be the low-level technology, not the actual interface.

I think it's more appropriate for a GUI front-end, frankly, but you could 
script it fairly easily with whatever your favourite patch editing tool:

 (a) Generate the "result" file you want in /tmp or something, using patch 
     editing tools to extract a partial patch and apply it to the original 
     file.

 (b) Use "git-hash-object" to create the backing store object, and get the 
     SHA1 for that file.

 (c) Use "git-update-index --cacheinfo <mode> <sha1> <filename>" to 
     populate that new entry of yours into the index.

 (d) Do (a)-(c) as many times as you like to handle all the files you 
     want to commit, and then just call "git commit"

iow, it's not hard, but no, git on its own is _not_ a patch-based system, 
and doesn't do things hunk-for-hunk. You need that "hunk selector" 
interface on top of it.

			Linus
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
selective git-update-index per diff(1) chunks, Alexey Dobriyan, (Fri Dec 1, 7:23 am)
Re: selective git-update-index per diff(1) chunks, Sven Verdoolaege, (Mon Dec 4, 1:33 pm)
Re: selective git-update-index per diff(1) chunks, Linus Torvalds, (Fri Dec 1, 12:06 pm)