From: Phillip Wood <phillip.wood@xxxxxxxxxxxxx> Unfortuantely v4 had test failures due to a suprious brace from a last minute edit to a comment that I forgot to test. This version fixes that, my applogies for the patch churn. I've updated this series based on Ævar's feedback on v3 (to paraphrase stop using '$_' so much and fix staging modified lines.). The first patch is functionally equivalent to the previous version but with a reworked implementation. Patch 2 is new, it implements correctly staging modified lines with a couple of limitations - see the commit message for more details, I'm keen to get some feedback on it. Patches 3 and 4 are essentially rebased and tweaked versions of patches 2 and 3 from the previous version. This series is based on pw/add-p-recount (f4d35a6b49 "add -p: fix counting empty context lines in edited patches") The motivation for this series is summed up in the first commit message: "When I end up editing hunks it is almost always because I want to stage a subset of the lines in the hunk. Doing this by editing the hunk is inconvenient and error prone (especially so if the patch is going to be reversed before being applied). Instead offer an option for add -p to stage individual lines. When the user presses 'l' the hunk is redrawn with labels by the insertions and deletions and they are prompted to enter a list of the lines they wish to stage. Ranges of lines may be specified using 'a-b' where either 'a' or 'b' may be omitted to mean all lines from 'a' to the end of the hunk or all lines from 1 upto and including 'b'." Phillip Wood (4): add -p: select individual hunk lines add -p: select modified lines correctly add -p: allow line selection to be inverted add -p: optimize line selection for short hunks Documentation/git-add.txt | 10 ++ git-add--interactive.perl | 349 +++++++++++++++++++++++++++++++++++++ t/t3701-add-interactive.sh | 209 ++++++++++++++++++++++ 3 files changed, 568 insertions(+) -- 2.18.0