arxanas / git-branchless

High-velocity, monorepo-scale workflow for Git

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add git amend -i for a TUI

waylon-brown opened this issue · comments

Description of the bug

For git amend the docs state that if I want to amend only some changes, I should add those to the staging area first.

I then expected there to be git amend -i - similar to git record -i - where I can choose with the TUI which changes to stage. This would be great so that I don't need to create a new commit each time I want to use the TUI to add only some changes.

Expected behavior

No response

Actual behavior

No response

Version of rustc

No response

Automated bug report

No response

Version of git-branchless

No response

Version of git

No response

I agree that this would be useful, but I don't have any plans to work on it. You could try https://github.com/martinvonz/jj which does have a jj amend -i command.

Out of curiosity, why is it this isn't something that's planned? Is it too much work to integrate the existing TUI with amend? The TUI is really great - I think it'd make branchless a bit more intuitive to be able to use the TUI in other places since it's working with record.

Unfortunately jj is incompatible with my repo.

For ex. I can accomplish it w/ a couple commands, so I'm wondering if much of the internals could be reused here.

# git stage interactive
# Select changes in working directory to stage.
function gsi {
	# Using && \ to abort if exiting TUI.
	# Commit changes to keep
	git record -i -m "Temp." && \
	# Move changes back into working directory, which has prev-commited changes staged.
	git reset --soft HEAD~
}

# git amend interactive
alias gai="gsi && git amend"

Out of curiosity, why is it this isn't something that's planned? Is it too much work to integrate the existing TUI with amend? The TUI is really great - I think it'd make branchless a bit more intuitive to be able to use the TUI in other places since it's working with record.

I just haven't had time to work on it. It should be reasonably straightforward if you want to work on it (but not trivial, because you have to synthesize the partial commit — you can see how it's done here:

let (selected, _unselected) = file.get_selected_contents();

).

For ex. I can accomplish it w/ a couple commands, so I'm wondering if much of the internals could be reused here.

You would also want to support the --merge and --reparent options that already exist for git amend.

Thanks for the update - makes sense!