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

Re: [PATCH] git-gui: Implement "Stage/Unstage Line"

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jul 2, 2008, 05:23 UTC
Message-ID
<20080702052342.GN11793@spearce.org>
In-Reply-To
<48649519.1010307@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> wrote:
> From: Johannes Sixt <johannes.sixt@telecom.at>
> 
> This adds a context menu entry below "Stage/Unstage Hunk" that stages or
> unstages just the line under the mouse pointer.
Thanks!  After some brief testing this is in now my tree on repo.or.cz.
 
> 	Disclaimer: I'm Tcl/Tk illiterate. Feel free to munge the patch
> 	to your taste.
I wouldn't say illiterate, given this contribution.  :)
 
> 	The 'do_rescan' is probably a bit heavy-weight. But editing the
> 	diff window like we do in "Stage Hunk" would be a bit complex, and
> 	just redisplaying the diff is easier.

Yea, I see why you are doing a do_rescan at the end. I was going to suggest just calling reshow_diff but that doesn't get the lists updated properly when a file is being initially staged as a result of the current line being added.

Editing the Tk widget is possible, but it can be a pain.
Show 5 quoted lines
> 	Furthermore, I don't know why I have to do the loop until
> 	"end - 1 chars". If it goes until "end", then the hunk contains
> 	an extra line, so that the patch in general does not apply.
> 	Is there an extra newline in the diff view that is not in the
> 	git diff output?
Yup.  Tk text widgets have an extra "\n" at the end of the content
that was inserted into it.  Thus an empty text widget has a single
LF as its content.  Weird, I know.
 
-- 
Shawn.
Previous: Johannes Sixt
Message 2 of 2 in “git-gui: Implement "Stage/Unstage Line"”
  1. git-gui: Implement "Stage/Unstage Line"Johannes Sixt, Jun 27, 2008
  2. Shawn O. PearceJul 2, 2008

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.