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
PWPhillip Wood <phillip.wood@talktalk.net>
Date
Dec 11, 2018, 14:48 UTC
Message-ID
<be3d2a6e-e960-6e43-17bf-9f67837f74e5@talktalk.net>
In-Reply-To
<nycvar.QRO.7.76.6.1812111049560.43@tvgsbejvaqbjf.bet>
Hi Dscho and Slavica
On 11/12/2018 09:56, Johannes Schindelin wrote:
Show 9 quoted lines
> 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:
> 
>> On 09/12/2018 20:31, Johannes Schindelin wrote:
>>>
<snip/>
Show 9 quoted lines
>>> (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.
Yes that's one of my main uses for selective staging as well
Show 13 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.

I was hoping for something simpler than editing patches just to stage a subset of lines that do not need to be edited.

Show 14 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.

But that involves editing the hunk or have I misunderstood? The aim of my series was that you'd select the '-' & '+' lines for the modification and it would stage them properly as a modification so given

1 -a 2 -b 3 +c

selecting 1,3 would stage
-a
+c
  b
not
-a
  b
+c

(see https://public-inbox.org/git/878ta8vyqe.fsf@evledraar.gmail.com/ for the background)

Show 6 quoted lines
>> 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/

Thanks for the link and hello Slavica! - I look forward to reading your patches when you post them here.

Best Wishes
Phillip
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 9 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.