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

How to reset selected lines?

From
Pratyush Yadav <me@yadavpratyush.com>
Date
Aug 13, 2019, 14:18 UTC
Message-ID
<20190813141816.yoer6pfjdnlgtj76@localhost.localdomain>
Hi,

To put things into context of why I am asking this, git-gui has a feature where you can select parts of a displayed diff, and can stage/unstage those parts. That feature is implemented in git-gui by just generating a diff from the selected lines, and then applying it. Check git-gui/lib/diff.tcl:643 for the implementation.

Now, I want to add a similar feature, but one that discards/resets the selected lines. And I'd like to avoid the hack that git-gui's apply_range_or_line is. So, is there a cleaner way to do this that does not involve generating a diff and then applying it?

Also, if there is a better way of staging and unstaging selected lines as well, do let me know, and I will try to fix git-gui's hacky way of doing it.

-- 
Regards,
Pratyush Yadav
Next: Jeff King
Message 1 of 7 in “How to reset selected lines?”
  1. Pratyush YadavAug 13, 2019
  2. Jeff KingAug 13, 2019
  3. Junio C HamanoAug 13, 2019
  4. Pratyush YadavAug 14, 2019
  5. Jeff KingAug 14, 2019
  6. Johannes SixtAug 13, 2019
  7. Pratyush YadavAug 14, 2019

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.