{"thread":{"id":"17594","subject":"\"git revert\" feature suggestion: revert the last commit to a file","startedAt":"2009-02-05T20:21:04Z","lastAt":"2009-02-06T00:41:54Z","messageCount":10,"participants":["Ingo Molnar","Johannes Schindelin","Junio C Hamano","Randy Dunlap"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"103378","messageId":"20090205202104.GA11267@elte.hu","threadId":"17594","inReplyTo":null,"subject":"\"git revert\" feature suggestion: revert the last commit to a file","fromName":"Ingo Molnar","fromEmail":"mingo@elte.hu","sentAt":"2009-02-05T20:21:04Z","receivedAt":"2009-02-05T20:21:04Z","isPatch":false,"sender":{"key":"mingo@elte.hu","avatar":null},"body":"\nI frequently come across this workflow pattern: i queue up some new change \nin a topic brach, and there's a test failure within the next 60 minutes or \nso. I know which file causes the breakage - say kernel/softlockup.c - but i \ndont know the precise commit ID. I want to revert the change in the \nintegration branch as quickly as possible via a command - without having to \nwade through 'git log' info and cut&paste-ing commit IDs.\n\nI usually know the topic branch name where the breakage originates from, so \ni can do this in the integration branch:\n\n   git revert core/softlockup\n\nand it does the right thing and the tests can continue while i take more \ntime in the topic branch to repair the damage there. (at which point i can \nintegrate the fixed/updated commit on top of the reverted commit in the \nintegration branch.)\n\nBut often i have other changes queued up in that topic branch as well - and \nthe best, most finegrained information i have about the identity of the \ncommit is the filename it went into.\n\nSo i have to do something like:\n\n   git revert $(git log -1 --pretty=format:\"%h\" kernel/softlockup.c)\n\n(tucked away in a tip-revert-file helper script.)\n\nBut it would be so much nicer if i could do the intuitive:\n\n   git revert kernel/softlockup.c\n\nOr at least, to separate it from revision names cleanly, something like:\n\n   git revert -- kernel/softlockup.c\n\nWould something like this be possible in generic Git? It would sure be a \nnice little touch that i would make use of frequently.\n\nOr is it a bad idea perhaps? Or have i, out of sheer ignorance, failed to \ndiscover some nice little shortcut that can give me all of this already?\n\nThanks,\n\n\tIngo\n"},{"id":"103385","messageId":"alpine.DEB.1.00.0902052145470.7491@intel-tinevez-2-302","threadId":"17594","inReplyTo":"20090205202104.GA11267@elte.hu","subject":"Re: \"git revert\" feature suggestion: revert the last commit to a file","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-02-05T20:50:03Z","receivedAt":"2009-02-05T20:50:03Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 5 Feb 2009, Ingo Molnar wrote:\n\n> But it would be so much nicer if i could do the intuitive:\n> \n>    git revert kernel/softlockup.c\n\nFor some people I know, this would intuitively mean that the uncommitted \nchanges in kernel/softlockup.c should be reverted.\n\nSo I am not convinced that this is an intuitive syntax at all.\n\nInstead, I think that something like\n\n\tgit revert :/!file=kernel/softlockup.c\n\nwould be possible, as it\n\n- does not overload an already overloaded term, and\n\n- is useful for something else than revert, too.\n\nCiao,\nDscho\n"},{"id":"103386","messageId":"7vvdrobobc.fsf@gitster.siamese.dyndns.org","threadId":"17594","inReplyTo":"20090205202104.GA11267@elte.hu","subject":"Re: \"git revert\" feature suggestion: revert the last commit to a file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-05T20:50:47Z","receivedAt":"2009-02-05T20:50:47Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ingo Molnar <mingo@elte.hu> writes:\n\n> So i have to do something like:\n>\n>    git revert $(git log -1 --pretty=format:\"%h\" kernel/softlockup.c)\n>\n> (tucked away in a tip-revert-file helper script.)\n>\n> But it would be so much nicer if i could do the intuitive:\n>\n>    git revert kernel/softlockup.c\n>\n> Or at least, to separate it from revision names cleanly, something like:\n>\n>    git revert -- kernel/softlockup.c\n\nAll three shares one issue.  Does the syntax offer you a way to give\nenough information so that you can confidently say that it will find the\ncommit that touched the path most recently?  How is the \"most recently\"\ndefined?\n\nAt least you can restate the first one to:\n\n    git revert $(git log -1 --pretty=format:\"%h\" core/softlockup -- kernel/softlockup.c)\n\nto limit to \"the one that touched this file _on this topic_\".\n\n> Would something like this be possible in generic Git? It would sure be a \n> nice little touch that i would make use of frequently.\n>\n> Or is it a bad idea perhaps? Or have i, out of sheer ignorance, failed to \n> discover some nice little shortcut that can give me all of this already?\n\nThe closest I can think of is\n\n\tgit revert ':/the title of the commit'\n\nbut it shares the exact same issue of \"how would I limit the search space\nto make sure it finds the right commit\".\n"},{"id":"103388","messageId":"498B51E8.8030801@xenotime.net","threadId":"17594","inReplyTo":"7vvdrobobc.fsf@gitster.siamese.dyndns.org","subject":"Re: \"git revert\" feature suggestion: revert the last commit to a file","fromName":"Randy Dunlap","fromEmail":"rdunlap@xenotime.net","sentAt":"2009-02-05T20:54:00Z","receivedAt":"2009-02-05T20:54:00Z","isPatch":false,"sender":{"key":"rdunlap@xenotime.net","avatar":null},"body":"Junio C Hamano wrote:\n> Ingo Molnar <mingo@elte.hu> writes:\n> \n>> So i have to do something like:\n>>\n>>    git revert $(git log -1 --pretty=format:\"%h\" kernel/softlockup.c)\n>>\n>> (tucked away in a tip-revert-file helper script.)\n>>\n>> But it would be so much nicer if i could do the intuitive:\n>>\n>>    git revert kernel/softlockup.c\n>>\n>> Or at least, to separate it from revision names cleanly, something like:\n>>\n>>    git revert -- kernel/softlockup.c\n> \n> All three shares one issue.  Does the syntax offer you a way to give\n> enough information so that you can confidently say that it will find the\n> commit that touched the path most recently?  How is the \"most recently\"\n> defined?\n> \n> At least you can restate the first one to:\n> \n>     git revert $(git log -1 --pretty=format:\"%h\" core/softlockup -- kernel/softlockup.c)\n> \n> to limit to \"the one that touched this file _on this topic_\".\n> \n>> Would something like this be possible in generic Git? It would sure be a \n>> nice little touch that i would make use of frequently.\n>>\n>> Or is it a bad idea perhaps? Or have i, out of sheer ignorance, failed to \n>> discover some nice little shortcut that can give me all of this already?\n> \n> The closest I can think of is\n> \n> \tgit revert ':/the title of the commit'\n> \n> but it shares the exact same issue of \"how would I limit the search space\n> to make sure it finds the right commit\".\n\nAnd it should revert whatever commit is the last/most recent to the currently\nused file, i.e., not always revert the same commit.\n\nIMO.\n\n~Randy\n"},{"id":"103390","messageId":"20090205210018.GB21500@elte.hu","threadId":"17594","inReplyTo":"7vvdrobobc.fsf@gitster.siamese.dyndns.org","subject":"Re: \"git revert\" feature suggestion: revert the last commit to a file","fromName":"Ingo Molnar","fromEmail":"mingo@elte.hu","sentAt":"2009-02-05T21:00:18Z","receivedAt":"2009-02-05T21:00:18Z","isPatch":false,"sender":{"key":"mingo@elte.hu","avatar":null},"body":"\n* Junio C Hamano <gitster@pobox.com> wrote:\n\n> Ingo Molnar <mingo@elte.hu> writes:\n> \n> > So i have to do something like:\n> >\n> >    git revert $(git log -1 --pretty=format:\"%h\" kernel/softlockup.c)\n> >\n> > (tucked away in a tip-revert-file helper script.)\n> >\n> > But it would be so much nicer if i could do the intuitive:\n> >\n> >    git revert kernel/softlockup.c\n> >\n> > Or at least, to separate it from revision names cleanly, something like:\n> >\n> >    git revert -- kernel/softlockup.c\n> \n> All three shares one issue.  Does the syntax offer you a way to give\n> enough information so that you can confidently say that it will find the\n> commit that touched the path most recently?  How is the \"most recently\"\n> defined?\n> \n> At least you can restate the first one to:\n> \n>     git revert $(git log -1 --pretty=format:\"%h\" core/softlockup -- kernel/softlockup.c)\n> \n> to limit to \"the one that touched this file _on this topic_\".\n\nAll in the current scope of the integration branch, sure. I.e. the same \nscope of commits that \"git log kernel/softlockup.c\" uses.\n\n\tIngo\n"},{"id":"103392","messageId":"20090205210055.GC21500@elte.hu","threadId":"17594","inReplyTo":"498B51E8.8030801@xenotime.net","subject":"Re: \"git revert\" feature suggestion: revert the last commit to a file","fromName":"Ingo Molnar","fromEmail":"mingo@elte.hu","sentAt":"2009-02-05T21:00:55Z","receivedAt":"2009-02-05T21:00:55Z","isPatch":false,"sender":{"key":"mingo@elte.hu","avatar":null},"body":"\n* Randy Dunlap <rdunlap@xenotime.net> wrote:\n\n> Junio C Hamano wrote:\n> > Ingo Molnar <mingo@elte.hu> writes:\n> > \n> >> So i have to do something like:\n> >>\n> >>    git revert $(git log -1 --pretty=format:\"%h\" kernel/softlockup.c)\n> >>\n> >> (tucked away in a tip-revert-file helper script.)\n> >>\n> >> But it would be so much nicer if i could do the intuitive:\n> >>\n> >>    git revert kernel/softlockup.c\n> >>\n> >> Or at least, to separate it from revision names cleanly, something like:\n> >>\n> >>    git revert -- kernel/softlockup.c\n> > \n> > All three shares one issue.  Does the syntax offer you a way to give\n> > enough information so that you can confidently say that it will find the\n> > commit that touched the path most recently?  How is the \"most recently\"\n> > defined?\n> > \n> > At least you can restate the first one to:\n> > \n> >     git revert $(git log -1 --pretty=format:\"%h\" core/softlockup -- kernel/softlockup.c)\n> > \n> > to limit to \"the one that touched this file _on this topic_\".\n> > \n> >> Would something like this be possible in generic Git? It would sure be a \n> >> nice little touch that i would make use of frequently.\n> >>\n> >> Or is it a bad idea perhaps? Or have i, out of sheer ignorance, failed to \n> >> discover some nice little shortcut that can give me all of this already?\n> > \n> > The closest I can think of is\n> > \n> > \tgit revert ':/the title of the commit'\n> > \n> > but it shares the exact same issue of \"how would I limit the search space\n> > to make sure it finds the right commit\".\n> \n> And it should revert whatever commit is the last/most recent to the \n> currently used file, i.e., not always revert the same commit.\n\ni'm not sure i understand, what do you mean precisely?\n\n\tIngo\n"},{"id":"103394","messageId":"498B5418.4050103@xenotime.net","threadId":"17594","inReplyTo":"20090205210055.GC21500@elte.hu","subject":"Re: \"git revert\" feature suggestion: revert the last commit to a file","fromName":"Randy Dunlap","fromEmail":"rdunlap@xenotime.net","sentAt":"2009-02-05T21:03:20Z","receivedAt":"2009-02-05T21:03:20Z","isPatch":false,"sender":{"key":"rdunlap@xenotime.net","avatar":null},"body":"Ingo Molnar wrote:\n> * Randy Dunlap <rdunlap@xenotime.net> wrote:\n> \n>> Junio C Hamano wrote:\n>>> Ingo Molnar <mingo@elte.hu> writes:\n>>>\n>>>> So i have to do something like:\n>>>>\n>>>>    git revert $(git log -1 --pretty=format:\"%h\" kernel/softlockup.c)\n>>>>\n>>>> (tucked away in a tip-revert-file helper script.)\n>>>>\n>>>> But it would be so much nicer if i could do the intuitive:\n>>>>\n>>>>    git revert kernel/softlockup.c\n>>>>\n>>>> Or at least, to separate it from revision names cleanly, something like:\n>>>>\n>>>>    git revert -- kernel/softlockup.c\n>>> All three shares one issue.  Does the syntax offer you a way to give\n>>> enough information so that you can confidently say that it will find the\n>>> commit that touched the path most recently?  How is the \"most recently\"\n>>> defined?\n>>>\n>>> At least you can restate the first one to:\n>>>\n>>>     git revert $(git log -1 --pretty=format:\"%h\" core/softlockup -- kernel/softlockup.c)\n>>>\n>>> to limit to \"the one that touched this file _on this topic_\".\n>>>\n>>>> Would something like this be possible in generic Git? It would sure be a \n>>>> nice little touch that i would make use of frequently.\n>>>>\n>>>> Or is it a bad idea perhaps? Or have i, out of sheer ignorance, failed to \n>>>> discover some nice little shortcut that can give me all of this already?\n>>> The closest I can think of is\n>>>\n>>> \tgit revert ':/the title of the commit'\n>>>\n>>> but it shares the exact same issue of \"how would I limit the search space\n>>> to make sure it finds the right commit\".\n>> And it should revert whatever commit is the last/most recent to the \n>> currently used file, i.e., not always revert the same commit.\n> \n> i'm not sure i understand, what do you mean precisely?\n\nJust that someone should be able to use \"git revert <filename>\" on the\nsame file more than one time and git will revert <last> then <last-1> then\n<last-2> etc...\n\nOr it will always revert <last>, where <last> is relative to the currently\nused version of the file.\n\nDoes that help?\n\n~Randy\n"},{"id":"103398","messageId":"20090205214630.GA28097@elte.hu","threadId":"17594","inReplyTo":"498B5418.4050103@xenotime.net","subject":"Re: \"git revert\" feature suggestion: revert the last commit to a file","fromName":"Ingo Molnar","fromEmail":"mingo@elte.hu","sentAt":"2009-02-05T21:46:30Z","receivedAt":"2009-02-05T21:46:30Z","isPatch":false,"sender":{"key":"mingo@elte.hu","avatar":null},"body":"\n* Randy Dunlap <rdunlap@xenotime.net> wrote:\n\n> Ingo Molnar wrote:\n> > * Randy Dunlap <rdunlap@xenotime.net> wrote:\n> > \n> >> Junio C Hamano wrote:\n> >>> Ingo Molnar <mingo@elte.hu> writes:\n> >>>\n> >>>> So i have to do something like:\n> >>>>\n> >>>>    git revert $(git log -1 --pretty=format:\"%h\" kernel/softlockup.c)\n> >>>>\n> >>>> (tucked away in a tip-revert-file helper script.)\n> >>>>\n> >>>> But it would be so much nicer if i could do the intuitive:\n> >>>>\n> >>>>    git revert kernel/softlockup.c\n> >>>>\n> >>>> Or at least, to separate it from revision names cleanly, something like:\n> >>>>\n> >>>>    git revert -- kernel/softlockup.c\n> >>> All three shares one issue.  Does the syntax offer you a way to give\n> >>> enough information so that you can confidently say that it will find the\n> >>> commit that touched the path most recently?  How is the \"most recently\"\n> >>> defined?\n> >>>\n> >>> At least you can restate the first one to:\n> >>>\n> >>>     git revert $(git log -1 --pretty=format:\"%h\" core/softlockup -- kernel/softlockup.c)\n> >>>\n> >>> to limit to \"the one that touched this file _on this topic_\".\n> >>>\n> >>>> Would something like this be possible in generic Git? It would sure be a \n> >>>> nice little touch that i would make use of frequently.\n> >>>>\n> >>>> Or is it a bad idea perhaps? Or have i, out of sheer ignorance, failed to \n> >>>> discover some nice little shortcut that can give me all of this already?\n> >>> The closest I can think of is\n> >>>\n> >>> \tgit revert ':/the title of the commit'\n> >>>\n> >>> but it shares the exact same issue of \"how would I limit the search space\n> >>> to make sure it finds the right commit\".\n> >> And it should revert whatever commit is the last/most recent to the \n> >> currently used file, i.e., not always revert the same commit.\n> > \n> > i'm not sure i understand, what do you mean precisely?\n> \n> Just that someone should be able to use \"git revert <filename>\" on the\n> same file more than one time and git will revert <last> then <last-1> then\n> <last-2> etc...\n> \n> Or it will always revert <last>, where <last> is relative to the currently\n> used version of the file.\n> \n> Does that help?\n\nah, i understand. No, the second time it should revert the revert.\n\nLast commit means last commit - and a revert is just a normal commit. (it \njust happens to be generated as an inverse of an existing commit - but that \nrelationship is not actually relied on and a revert can be edited, amended, \netc.)\n\n\tIngo\n"},{"id":"103408","messageId":"7vhc38a09m.fsf@gitster.siamese.dyndns.org","threadId":"17594","inReplyTo":"20090205210018.GB21500@elte.hu","subject":"Re: \"git revert\" feature suggestion: revert the last commit to a file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-06T00:15:33Z","receivedAt":"2009-02-06T00:15:33Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ingo Molnar <mingo@elte.hu> writes:\n\n> * Junio C Hamano <gitster@pobox.com> wrote:\n>\n>> Ingo Molnar <mingo@elte.hu> writes:\n>> \n>> > So i have to do something like:\n>> >\n>> >    git revert $(git log -1 --pretty=format:\"%h\" kernel/softlockup.c)\n>> >\n>> > (tucked away in a tip-revert-file helper script.)\n>> >\n>> > But it would be so much nicer if i could do the intuitive:\n>> >\n>> >    git revert kernel/softlockup.c\n>> >\n>> > Or at least, to separate it from revision names cleanly, something like:\n>> >\n>> >    git revert -- kernel/softlockup.c\n>> \n>> All three shares one issue.  Does the syntax offer you a way to give\n>> enough information so that you can confidently say that it will find the\n>> commit that touched the path most recently?  How is the \"most recently\"\n>> defined?\n>> \n>> At least you can restate the first one to:\n>> \n>>     git revert $(git log -1 --pretty=format:\"%h\" core/softlockup -- kernel/softlockup.c)\n>> \n>> to limit to \"the one that touched this file _on this topic_\".\n>\n> All in the current scope of the integration branch, sure. I.e. the same \n> scope of commits that \"git log kernel/softlockup.c\" uses.\n\nBut that is not how \":/syntax\" works, at least right now.  It traverses\nfrom tips of all refs and finds the newest one.  It might make sense to\nmake the discovery start from the current branch not from all tips.\n"},{"id":"103411","messageId":"alpine.DEB.1.00.0902060140170.10279@pacific.mpi-cbg.de","threadId":"17594","inReplyTo":"7vhc38a09m.fsf@gitster.siamese.dyndns.org","subject":"Re: \"git revert\" feature suggestion: revert the last commit to a file","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-02-06T00:41:54Z","receivedAt":"2009-02-06T00:41:54Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 5 Feb 2009, Junio C Hamano wrote:\n\n> Ingo Molnar <mingo@elte.hu> writes:\n> \n> > * Junio C Hamano <gitster@pobox.com> wrote:\n> >\n> >> Ingo Molnar <mingo@elte.hu> writes:\n> >> \n> >> > So i have to do something like:\n> >> >\n> >> >    git revert $(git log -1 --pretty=format:\"%h\" kernel/softlockup.c)\n> >> >\n> >> > (tucked away in a tip-revert-file helper script.)\n> >> >\n> >> > But it would be so much nicer if i could do the intuitive:\n> >> >\n> >> >    git revert kernel/softlockup.c\n> >> >\n> >> > Or at least, to separate it from revision names cleanly, something like:\n> >> >\n> >> >    git revert -- kernel/softlockup.c\n> >> \n> >> All three shares one issue.  Does the syntax offer you a way to give\n> >> enough information so that you can confidently say that it will find the\n> >> commit that touched the path most recently?  How is the \"most recently\"\n> >> defined?\n> >> \n> >> At least you can restate the first one to:\n> >> \n> >>     git revert $(git log -1 --pretty=format:\"%h\" core/softlockup -- kernel/softlockup.c)\n> >> \n> >> to limit to \"the one that touched this file _on this topic_\".\n> >\n> > All in the current scope of the integration branch, sure. I.e. the same \n> > scope of commits that \"git log kernel/softlockup.c\" uses.\n> \n> But that is not how \":/syntax\" works, at least right now.  It traverses\n> from tips of all refs and finds the newest one.  It might make sense to\n> make the discovery start from the current branch not from all tips.\n\nYeah, it was a bad design, probably.\n\nAs it is, the syntax is not really useful to me, as my patch to make this \na regular expression was not accepted.\n\nMaybe it is time to rethink that syntax; I am pretty sure that there is no \nuser out there.\n\nCiao,\nDscho\n"}]}