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

Re: pw/add-p-select, was Re: What's cooking in git.git (Dec 2018, #01; Sun, 9)

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 11, 2018, 09:56 UTC
Message-ID
<nycvar.QRO.7.76.6.1812111049560.43@tvgsbejvaqbjf.bet>
In-Reply-To
<d69259ce-bc45-9201-693b-3902a6379265@talktalk.net>
Hi Phillip,

[Cc:ing Slavica, the Outreachy intern working on converting `add -i` to a built-in]

On Mon, 10 Dec 2018, Phillip Wood wrote:
Show 20 quoted lines
> On 09/12/2018 20:31, Johannes Schindelin wrote:
> > 
> > On Sun, 9 Dec 2018, Junio C Hamano wrote:
> > 
> > > * pw/add-p-select (2018-07-26) 4 commits
> > >   - add -p: optimize line selection for short hunks
> > >   - add -p: allow line selection to be inverted
> > >   - add -p: select modified lines correctly
> > >   - add -p: select individual hunk lines
> > >
> > >   "git add -p" interactive interface learned to let users choose
> > >   individual added/removed lines to be used in the operation, instead
> > >   of accepting or rejecting a whole hunk.
> > >
> > >   Will discard.
> > >   No further feedbacks on the topic for quite some time.
> > 
> > That is not quite true. I did comment that this feature
> 
> Sorry I meant to reply to that comment but never got round to it.
No worries. We're all busy down here.
> > (which I take as being inspired by Git GUI's "Stage Selected Line"),
> 
> not particularly, I don't use git gui I just wanted a way to easily
> stage a subset of lines without editing the hunk.

Okay. I used to use Git GUI quite a bit to stage individual lines, but recently I tried to stay more in the terminal and used the `split` and `edit` commands of `add -p` quite extensively. Wishing for an quicker way to stage individual lines between all of my debug print statements.

Show 8 quoted lines
> > and thought that it would be useful.
> > 
> > I could imagine, however, that it would make sense for `git add -p` to
> > imitate that feature more closely: by allowing to stage a single line
> > and then presenting the current hunk (re-computed) again.
> 
> that sounds like it would be quite tedious to stage more than a couple
> of lines,

It would be. But then, if you want to do anything slightly more complicated than staging a hunk or a line, I personally prefer the `edit` command *a lot*, as it lets me even split unrelated changes in the same line into two commits.

Show 5 quoted lines
> and it could be awkward to get it to stage modified lines correctly
> (While I was writing the feature I tried git gui, I think it is supposed
> to be able to stage modified lines correctly but I never persuaded it to
> do it for me. I also tried gitg, tig and hg commit -i but I couldn't get
> them to do modified lines either)

Git GUI works very reliably for me, but then, I have Git for Windows' patched Git GUI at my finger tips (oh how I wish we had a Git GUI maintainer again).

It should not be awkward to stage a single modified line at all. Essentially, you take the hunk, strip out all `-` and `+` lines except the one you want to stage, then stage that with `git apply --cached --recount`, and then you simply re-generate that hunk.

> I'll try and re-roll in the New Year, when does the outreachy project
> for converting add -i start? - it would be good to try and get this
> pinned down before then.

Too late. Slavica started on December 4th, and you can even read about it on their blog: https://slavicadj.github.io/blog/

Ciao, Dscho

Previous: Phillip WoodNext: Phillip Wood
Message 8 of 20 in “What's cooking in git.git (Dec 2018, #01; Sun, 9)”
  1. Junio C HamanoDec 9, 2018
  2. Denton LiuDec 9, 2018
  3. Junio C HamanoDec 10, 2018
  4. Denton LiuDec 10, 2018
  5. Junio C HamanoDec 10, 2018
  6. pw/add-p-select, was Re: What's cooking in git.git (Dec 2018, #01; Sun, 9)Johannes Schindelin, Dec 9, 2018
  7. Phillip WoodDec 10, 2018
  8. Johannes SchindelinDec 11, 2018
  9. Phillip WoodDec 11, 2018
  10. Johannes SchindelinJan 21, 2019
  11. Phillip WoodJan 22, 2019
  12. Josh SteadmonDec 10, 2018
  13. Junio C HamanoDec 11, 2018
  14. Elijah NewrenDec 10, 2018
  15. Ævar Arnfjörð BjarmasonDec 10, 2018
  16. Junio C HamanoDec 11, 2018
  17. Junio C HamanoDec 11, 2018
  18. Stefan BellerDec 11, 2018
  19. Junio C HamanoDec 11, 2018
  20. Alban GruinDec 16, 2018

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.