-
-
Notifications
You must be signed in to change notification settings - Fork 95
feat: add split
command
#1464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: add split
command
#1464
Conversation
4ea0c44
to
f94a071
Compare
d0966ba
to
a3f30c7
Compare
455e652
to
6498777
Compare
bbfce1b
to
6712829
Compare
77d3d29
to
5f1491f
Compare
I pushed a fix for an issue that I had noticed for a while but couldn't reproduce: using |
This will be used to circumvent the "autocheckout" setting in `git split` (in the next commit), so that we can preserve the current detached/attached state. FIXME is this really needed? Maybe we don't need to force-re-checkout?
This adds a
git split
command to extract changes from commits. This mostly addresses #180, except for the-i/--interactive
part. The split and rebase happens in-memory, so it should be fast. The command signature isgit [branchless] split <revset> <file> [<file>...]
<revset>
must resolve to a single commit (or just be a single commit, or@
, etc)<n> files
is used in the extracted commit message(+2/-5)
temp(split): lib.rs (+5)
ortemp(split): 3 files (+3/-3)
Implemented flags
These alter how the split/rebase happens:
A - B - C
→A - B' - b' - C
--detach
: similar to above, butA - B - C
→A - B' - C
andB' - b
b
andC
are now both children ofB'
--discard
: similar to--detach
, but after extracting the changes, they are simply discardedA - B - C
→A - B' - C
--before
: the extracted changes are inserted as a parent of the newly split target commitA - B - C
→A - b - B' - C
--detach
and--discard
, rebase conflicts are possible, and are intended to be resolved in the same way are forgit move
conflictsStatus
This is "works for me" and has been stable and useful over months of personal testing. That said, the code is mostly OK, but there are still a few FIXME/TODOs to resolve, and I'm certain that the code could be more idiomatic or branchless
in general. I have written a bunch of tests, but it's possible that I have overlooked some edges.
Any and all feedback is welcome. I'm happy with this as is, but I'm looking forward to some review helping me be really proud of it. =)
Specific areas needing feedback and review
extracted_commit
andremainder_commit
) feel good, but they actually mean the opposite if the--before
flag is passed. 🤷 I've commented this to explain, but I'm hoping someone else will have some suggestions.