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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Fri, 1 Dec 2006, Alexey Dobriyan wrote:
> 
> Has anyone thought about aggregating this into git-update-index or
> somewhere?
> 
>    git-update-index -C1,3    #chunks 1, 3
>    git commit

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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]