tig icon indicating copy to clipboard operation
tig copied to clipboard

Reset single diff line

Open edi9999 opened this issue 9 years ago • 9 comments

I'm searching for a key binding that would revert a single line:

The keybinding 1 stages a single line The keybinding ! : Checkout file with unstaged changes. This will reset the file to contain the content it had at last commit.

Is they a way to reset only one line of a file which has many changes?

It would make sense to me to map this keybinding with the key 2

edi9999 avatar Apr 29 '15 07:04 edi9999

After looking inside the code:

    case REQ_STATUS_REVERT:
        if (!stage_revert(view, line))
            return REQ_NONE;
        break;

    case REQ_STAGE_UPDATE_LINE:
        if (stage_line_type == LINE_STAT_UNTRACKED ||
            stage_status.status == 'A') {
            report("Staging single lines is not supported for new files");
            return REQ_NONE;
        }
        if (line->type != LINE_DIFF_DEL && line->type != LINE_DIFF_ADD) {
            report("Please select a change to stage");
            return REQ_NONE;
        }
        if (!stage_update(view, line, TRUE))
            return REQ_NONE;
        break;

in src/stage.c , I would say it's not possible yet to add a keybinding for this.

edi9999 avatar Apr 29 '15 07:04 edi9999

That's true. There's no way to undo or revert a single line.

jonas avatar Apr 29 '15 10:04 jonas

SourceTree can do this and it's a great feature. Cleaning up files out off debug lines at the same completing changes to commit. Any chances for implementation of this?

psprint avatar Feb 02 '16 11:02 psprint

I have this in my .tigrc , maybe that could help you :

bind status r !git checkout --patch -- %(file)

When pressing r over a file name, it will open the patch interface of git to reset the changes you want

netei avatar Feb 02 '16 11:02 netei

i second @psprint's motion

lrascao avatar Feb 02 '17 22:02 lrascao

I usually just have to revert a single line with a TODO or something like that. I find myself reverting a single line more often than using the single line stage option (unless I am working around the inability to revert that line).

hakunin avatar Feb 14 '18 12:02 hakunin

+1 for this feature

ssgromov avatar Jun 04 '20 15:06 ssgromov

+1 for this

cibinmathew avatar Mar 15 '21 18:03 cibinmathew

I need this feature too.

And I found an solution which needs two steps:

  1. \ to split the current chunk which splits a chunk into multiple tiny chunks,
  2. then status-revert (by default it is !) this chunk

Not sure if this works for all this kind of demand.

c02y avatar Jul 29 '21 20:07 c02y