git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: "git revert" feature suggestion: revert the last commit to a file

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 6, 2009, 00:15 UTC
Message-ID
<7vhc38a09m.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20090205210018.GB21500@elte.hu>
Ingo Molnar <mingo@elte.hu> writes:
Show 31 quoted lines
> * Junio C Hamano <gitster@pobox.com> wrote:
>
>> Ingo Molnar <mingo@elte.hu> writes:
>> 
>> > So i have to do something like:
>> >
>> >    git revert $(git log -1 --pretty=format:"%h" kernel/softlockup.c)
>> >
>> > (tucked away in a tip-revert-file helper script.)
>> >
>> > But it would be so much nicer if i could do the intuitive:
>> >
>> >    git revert kernel/softlockup.c
>> >
>> > Or at least, to separate it from revision names cleanly, something like:
>> >
>> >    git revert -- kernel/softlockup.c
>> 
>> All three shares one issue.  Does the syntax offer you a way to give
>> enough information so that you can confidently say that it will find the
>> commit that touched the path most recently?  How is the "most recently"
>> defined?
>> 
>> At least you can restate the first one to:
>> 
>>     git revert $(git log -1 --pretty=format:"%h" core/softlockup -- kernel/softlockup.c)
>> 
>> to limit to "the one that touched this file _on this topic_".
>
> All in the current scope of the integration branch, sure. I.e. the same 
> scope of commits that "git log kernel/softlockup.c" uses.

But that is not how ":/syntax" works, at least right now. It traverses from tips of all refs and finds the newest one. It might make sense to make the discovery start from the current branch not from all tips.

Previous: Ingo MolnarNext: Johannes Schindelin
Message 9 of 10 in “"git revert" feature suggestion: revert the last commit to a file”
  1. Ingo MolnarFeb 5, 2009
  2. Johannes SchindelinFeb 5, 2009
  3. Junio C HamanoFeb 5, 2009
  4. Randy DunlapFeb 5, 2009
  5. Ingo MolnarFeb 5, 2009
  6. Randy DunlapFeb 5, 2009
  7. Ingo MolnarFeb 5, 2009
  8. Ingo MolnarFeb 5, 2009
  9. Junio C HamanoFeb 6, 2009
  10. Johannes SchindelinFeb 6, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.