{"thread":{"id":"43129","subject":"Re: selective git-update-index per diff(1) chunks","startedAt":"2006-12-01T11:23:14Z","lastAt":"2006-12-04T22:35:03Z","messageCount":12,"participants":["Linus Torvalds","Jakub Narebski","Johannes Schindelin","Sam Vilain","Peter Baumann","Sven Verdoolaege","Alexey Dobriyan","Junio C Hamano","Anand Kumria"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"297107","messageId":"b6fcc0a0612010323x7554e47m5e6bdafe85fc8224@mail.gmail.com","threadId":"43129","inReplyTo":null,"subject":"selective git-update-index per diff(1) chunks","fromName":"Alexey Dobriyan","fromEmail":"adobriyan@gmail.com","sentAt":"2006-12-01T11:23:14Z","receivedAt":"2006-12-01T11:23:14Z","isPatch":false,"sender":{"key":"adobriyan@gmail.com","avatar":null},"body":"Pretty often I end up with a file with two simple orthogonal fixes in it.\ngit-diff shows me both, that's OK.\n\nNow I want to commit them as two separate commits. So far, it's\n* getting full diff\n* cp(1)\n* hand-edit both diffs\n* commit first\n* commit second\n\nHas anyone thought about aggregating this into git-update-index or\nsomewhere?\n\n    git-update-index -C1,3    #chunks 1, 3\n    git commit\n    git-update-index -C1,3    # chunks 2,5 in original numbering\n    git commit\n\n"},{"id":"295737","messageId":"slrnen04os.a5.Peter.B.Baumann@xp.machine.xx","threadId":"43129","inReplyTo":"b6fcc0a0612010323x7554e47m5e6bdafe85fc8224@mail.gmail.com","subject":"Re: selective git-update-index per diff(1) chunks","fromName":"Peter Baumann","fromEmail":"peter.b.baumann@stud.informatik.uni-erlangen.de","sentAt":"2006-12-01T11:33:48Z","receivedAt":"2006-12-01T11:33:48Z","isPatch":false,"sender":{"key":"waste.manager@gmx.de","avatar":null},"body":"On 2006-12-01, Alexey Dobriyan <adobriyan@gmail.com> wrote:\n> Pretty often I end up with a file with two simple orthogonal fixes in it.\n> git-diff shows me both, that's OK.\n>\n> Now I want to commit them as two separate commits. So far, it's\n> * getting full diff\n> * cp(1)\n> * hand-edit both diffs\n> * commit first\n> * commit second\n>\n> Has anyone thought about aggregating this into git-update-index or\n> somewhere?\n>\n>     git-update-index -C1,3    #chunks 1, 3\n>     git commit\n>     git-update-index -C1,3    # chunks 2,5 in original numbering\n>     git commit\n>\n> Relying on diff(1) definition of chunks is sorta hacky, though... I admit it.\n\nI don't think it belongs in the plumbing, the git-update-index but I\nthink something like this would be very usefull.\n\nAFAIR darcs has this functionality. It selectively ask for each hunk if\nit should be commited. This would be awfull to have in git.\n\n-Peter\n"},{"id":"297741","messageId":"7v3b7zalsq.fsf@assigned-by-dhcp.cox.net","threadId":"43129","inReplyTo":"slrnen04os.a5.Peter.B.Baumann@xp.machine.xx","subject":"Re: selective git-update-index per diff(1) chunks","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-01T11:38:13Z","receivedAt":"2006-12-01T11:38:13Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Baumann <Peter.B.Baumann@stud.informatik.uni-erlangen.de>\nwrites:\n\n> I don't think it belongs in the plumbing, the git-update-index but I\n> think something like this would be very usefull.\n>\n> AFAIR darcs has this functionality. It selectively ask for each hunk if\n> it should be commited. This would be awfull to have in git.\n\nI concur, on both counts.  My own now-defunct Porcelain had the\ndarcs style interactive hunk selection because it felt so\nuseful (and sometimes it was).\n\n"},{"id":"293887","messageId":"Pine.LNX.4.64.0612010740160.3695@woody.osdl.org","threadId":"43129","inReplyTo":"b6fcc0a0612010323x7554e47m5e6bdafe85fc8224@mail.gmail.com","subject":"Re: selective git-update-index per diff(1) chunks","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-12-01T16:06:32Z","receivedAt":"2006-12-01T16:06:32Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 1 Dec 2006, Alexey Dobriyan wrote:\n> \n> Has anyone thought about aggregating this into git-update-index or\n> somewhere?\n> \n>    git-update-index -C1,3    #chunks 1, 3\n>    git commit\n\nYou can already do it, but it's called something else.\n\nInstead of updating a certain hunk (which is fundamentally wrong, since it \ndepends on \"diff\" even working on that file), you can tell \ngit-update-index to update a certain _state_ for an arbitrary number of \nfiles. Namely:\n\n\tgit-update-index [--cacheinfo <mode> <object> <file>]*\n\nHowever, that obviously is very much a _plumbing_ command, and you need to \nhave some higher-level GUI on top of it to actually pick out the chunks \n(if that is what you want) and generate the object(s) associated with the \nfile(s) with only those chunks and then do the above \"install this state \ninto the index/staging area/whatever\".\n\nIn other words, git already supports this on a _technical_ level, but does \nnot have the high-level interfaces for it, and quite frankly \n\"git-update-index\" _shouldn't_ have the high-level interfaces for it. It's \ndesigned to be the low-level technology, not the actual interface.\n\nI think it's more appropriate for a GUI front-end, frankly, but you could \nscript it fairly easily with whatever your favourite patch editing tool:\n\n (a) Generate the \"result\" file you want in /tmp or something, using patch \n     editing tools to extract a partial patch and apply it to the original \n     file.\n\n (b) Use \"git-hash-object\" to create the backing store object, and get the \n     SHA1 for that file.\n\n (c) Use \"git-update-index --cacheinfo <mode> <sha1> <filename>\" to \n     populate that new entry of yours into the index.\n\n (d) Do (a)-(c) as many times as you like to handle all the files you \n     want to commit, and then just call \"git commit\"\n\niow, it's not hard, but no, git on its own is _not_ a patch-based system, \nand doesn't do things hunk-for-hunk. You need that \"hunk selector\" \ninterface on top of it.\n\n"},{"id":"298632","messageId":"ekpm6i$s35$1@sea.gmane.org","threadId":"43129","inReplyTo":"7v3b7zalsq.fsf@assigned-by-dhcp.cox.net","subject":"Re: selective git-update-index per diff(1) chunks","fromName":"Anand Kumria","fromEmail":"wildfire@progsoc.org","sentAt":"2006-12-01T16:45:06Z","receivedAt":"2006-12-01T16:45:06Z","isPatch":false,"sender":{"key":"wildfire@progsoc.org","avatar":null},"body":"On Fri, 01 Dec 2006 03:38:13 -0800, Junio C Hamano wrote:\n\n> Peter Baumann <Peter.B.Baumann@stud.informatik.uni-erlangen.de>\n> writes:\n> \n>> I don't think it belongs in the plumbing, the git-update-index but I\n>> think something like this would be very usefull.\n>>\n>> AFAIR darcs has this functionality. It selectively ask for each hunk if\n>> it should be commited. This would be awfull to have in git.\n> \n> I concur, on both counts.  My own now-defunct Porcelain had the\n> darcs style interactive hunk selection because it felt so\n> useful (and sometimes it was).\n\nIs there a good receipe on how to do this? Everytime I do it, I try a\ndifferent method; since I'm testing out my understanding of things.\n\nIt'd nice to have some of these \"advanced receipes\" that people often do\nnoted down somewhere.\n\nSometimes I feel git is kind of like the Emacs of VCS ... there is always\nmore to learn, even when you think you have a good handle on things.\n\nCheers,\nAnand\n"},{"id":"294592","messageId":"Pine.LNX.4.63.0612012039530.28348@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"43129","inReplyTo":"ekpm6i$s35$1@sea.gmane.org","subject":"Re: selective git-update-index per diff(1) chunks","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-01T19:42:50Z","receivedAt":"2006-12-01T19:42:50Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 1 Dec 2006, Anand Kumria wrote:\n\n> On Fri, 01 Dec 2006 03:38:13 -0800, Junio C Hamano wrote:\n> \n> > Peter Baumann <Peter.B.Baumann@stud.informatik.uni-erlangen.de>\n> > writes:\n> > \n> >> I don't think it belongs in the plumbing, the git-update-index but I\n> >> think something like this would be very usefull.\n> >>\n> >> AFAIR darcs has this functionality. It selectively ask for each hunk if\n> >> it should be commited. This would be awfull to have in git.\n> > \n> > I concur, on both counts.  My own now-defunct Porcelain had the\n> > darcs style interactive hunk selection because it felt so\n> > useful (and sometimes it was).\n> \n> Is there a good receipe on how to do this? Everytime I do it, I try a\n> different method; since I'm testing out my understanding of things.\n> \n> It'd nice to have some of these \"advanced receipes\" that people often do\n> noted down somewhere.\n\nCan't say anything about advanced recipes, but I use a poor-man's \nworkflow:\n\n$ git diff > a1.patch\n$ vi a1.patch\n  <edit out what I want to _keep_>\n$ git apply -R < a1.patch\n  <test & commit>\n$ git apply < a1.patch\n\nOf course, you could write a little wrapper around it, even one which asks \nyou which hunks you want to edit out. Should not be that hard...\n\nNote that this is independent of the SCM you are using.\n\nCiao,\nDscho\n"},{"id":"294798","messageId":"4571EB5F.7030300@vilain.net","threadId":"43129","inReplyTo":"slrnen04os.a5.Peter.B.Baumann@xp.machine.xx","subject":"Re: selective git-update-index per diff(1) chunks","fromName":"Sam Vilain","fromEmail":"sam@vilain.net","sentAt":"2006-12-02T21:08:47Z","receivedAt":"2006-12-02T21:08:47Z","isPatch":false,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Peter Baumann wrote:\n>> Now I want to commit them as two separate commits. So far, it's\n>> * getting full diff\n>> * cp(1)\n>> * hand-edit both diffs\n>> * commit first\n>> * commit second\n\nI made a patch to 'cg-commit -p' to do this, check the archives.\n\n>> Relying on diff(1) definition of chunks is sorta hacky, though... I admit it.\n> \n> I don't think it belongs in the plumbing, the git-update-index but I\n> think something like this would be very usefull.\n> \n> AFAIR darcs has this functionality. It selectively ask for each hunk if\n> it should be commited. This would be awfull to have in git.\n\ndarcs and SVK both have this \"interactive commit\".\n\ndarcs also does something very useful with this; what amounts to\nautomatically making topic branches.  Currently there is no easy way to\nmanage that, either.\n\nSam.\n"},{"id":"298334","messageId":"20061204173318.GG940MdfPADPa@greensroom.kotnet.org","threadId":"43129","inReplyTo":"b6fcc0a0612010323x7554e47m5e6bdafe85fc8224@mail.gmail.com","subject":"Re: selective git-update-index per diff(1) chunks","fromName":"Sven Verdoolaege","fromEmail":"skimo@kotnet.org","sentAt":"2006-12-04T17:33:18Z","receivedAt":"2006-12-04T17:33:18Z","isPatch":false,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"On Fri, Dec 01, 2006 at 02:23:14PM +0300, Alexey Dobriyan wrote:\n> Has anyone thought about aggregating this into git-update-index or\n> somewhere?\n> \n>    git-update-index -C1,3    #chunks 1, 3\n>    git commit\n>    git-update-index -C1,3    # chunks 2,5 in original numbering\n>    git commit\n> \n> Relying on diff(1) definition of chunks is sorta hacky, though... I admit \n> it.\n\nPaul Mackerras modified his dirdiff tool to do something like this.\nI have a couple of patches on top of his version from way back at\nhttp://www.liacs.nl/~sverdool/gitweb.cgi?p=dirdiff.git;a=summary\n\nI don't know if he has continued working on this.\n\n"},{"id":"294175","messageId":"el1nsi$vat$1@sea.gmane.org","threadId":"43129","inReplyTo":"20061204173318.GG940MdfPADPa@greensroom.kotnet.org","subject":"Re: selective git-update-index per diff(1) chunks","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-04T18:05:04Z","receivedAt":"2006-12-04T18:05:04Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Sven Verdoolaege wrote:\n\n> On Fri, Dec 01, 2006 at 02:23:14PM +0300, Alexey Dobriyan wrote:\n>> Has anyone thought about aggregating this into git-update-index or\n>> somewhere?\n>> \n>>    git-update-index -C1,3    #chunks 1, 3\n>>    git commit\n>>    git-update-index -C1,3    # chunks 2,5 in original numbering\n>>    git commit\n>> \n>> Relying on diff(1) definition of chunks is sorta hacky, though... I admit \n>> it.\n> \n> Paul Mackerras modified his dirdiff tool to do something like this.\n> I have a couple of patches on top of his version from way back at\n> http://www.liacs.nl/~sverdool/gitweb.cgi?p=dirdiff.git;a=summary\n> \n> I don't know if he has continued working on this.\n\nIf this has support for git, could you add it to GitWiki:\n  http://git.or.cz/gitwiki/InterfacesFrontendsAndTools\nAnd perhaps also update related page\n  http://git.or.cz/gitwiki/InterfacesFrontendsAndToolsWishlist\n\nThanks in advance.\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"},{"id":"298307","messageId":"200612042146.06419.jnareb@gmail.com","threadId":"43129","inReplyTo":"20061204202102.GH940MdfPADPa@greensroom.kotnet.org","subject":"Re: selective git-update-index per diff(1) chunks","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-04T20:46:06Z","receivedAt":"2006-12-04T20:46:06Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Sven Verdoolaege wrote:\n\n> On Mon, Dec 04, 2006 at 07:05:04PM +0100, Jakub Narebski wrote:\n>>\n>> If this [dirdiff] has support for git, could you add it to GitWiki:\n>>   http://git.or.cz/gitwiki/InterfacesFrontendsAndTools\n> \n> Well, it's not exactly user friendly at the moment.\n> Plus, it's not my tool.  I just made a couple of changes to get\n> it to work for me.\n> \n> I noticed Paul was working on a different tool lately, but I haven't\n> had time to check it out.  Maybe it does the same and more.\n\nIf it is GPL, you can post it anyway. As I understand from log\nyou have added git interface, isn't it? You are then perfectly\nin the right to post info at GitWiki about this tool.\n-- \nJakub Narebski\n"},{"id":"297082","messageId":"20061204215134.GJ940MdfPADPa@greensroom.kotnet.org","threadId":"43129","inReplyTo":"200612042146.06419.jnareb@gmail.com","subject":"Re: selective git-update-index per diff(1) chunks","fromName":"Sven Verdoolaege","fromEmail":"skimo@kotnet.org","sentAt":"2006-12-04T21:51:34Z","receivedAt":"2006-12-04T21:51:34Z","isPatch":false,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"On Mon, Dec 04, 2006 at 09:46:06PM +0100, Jakub Narebski wrote:\n> If it is GPL, you can post it anyway. As I understand from log\n> you have added git interface, isn't it?\n\nI think Paul added the ability to compare a git tree to a (set of)\ndirectory trees, while I add a primitive way of committing partial\nchanges to a git branch.  It's been over a year, though, so I may\nbe mistaken.\n\n> You are then perfectly\n> in the right to post info at GitWiki about this tool.\n\nI feel like I should check first that it hasn't been obsoleted by\nsome other tool already and I currently don't have the time to\ninvestigate.\n\n"},{"id":"296033","messageId":"200612042335.03802.jnareb@gmail.com","threadId":"43129","inReplyTo":"20061204215134.GJ940MdfPADPa@greensroom.kotnet.org","subject":"Re: selective git-update-index per diff(1) chunks","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-04T22:35:03Z","receivedAt":"2006-12-04T22:35:03Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Sven Verdoolaege wrote:\n> On Mon, Dec 04, 2006 at 09:46:06PM +0100, Jakub Narebski wrote:\n>>\n>> If it is GPL, you can post it anyway. As I understand from log\n>> you have added git interface, isn't it?\n> \n> I think Paul added the ability to compare a git tree to a (set of)\n> directory trees, while I add a primitive way of committing partial\n> changes to a git branch.  It's been over a year, though, so I may\n> be mistaken.\n\nLogs are there... ;-)\n \n>> You are then perfectly\n>> in the right to post info at GitWiki about this tool.\n> \n> I feel like I should check first that it hasn't been obsoleted by\n> some other tool already and I currently don't have the time to\n> investigate.\n\nIt doesn't look like this.\n-- \nJakub Narebski\n"}]}