git-machete icon indicating copy to clipboard operation
git-machete copied to clipboard

`git machete slide-in` or `git machete split` ?

Open aredridel opened this issue 3 years ago • 6 comments

What's the best way to break a tree of branches into smaller pieces? Either adding a new branch as a basis for an existing tree (the inverse of slide-out), or dividing a changeset up into smaller pieces (maybe call it "split")?

aredridel avatar Oct 11 '22 17:10 aredridel

Okay let's lay out a sample initial branch layout (in the notation as seen in git machete status --color=never, with o- style junction for green edge):

main
|
| Foo commit 1
| Foo commit 2
o-foo
  |
  | Bar commit 1
  | Bar commit 2
  o-bar

I assume that your aim is to transform the tree to sth like:

main
|
| Foo commit 1
| Foo commit 2
o-foo
  |
  | Bar commit 1
  o-qux
    |
    | Bar commit 2
    o-bar

amirite?

As for now, I'd just create qux branch out of the proper commit:

git checkout -b qux bar~

and then edit branch layout manually to slide in qux.

We can think of some ready command for that purpose 🤔 (although we need to be wary of bloating the command-line interface, it's already pretty massive for a git plugin 😅)

PawelLipski avatar Oct 12 '22 11:10 PawelLipski

That's exactly it, and what I've been doing, but it feels awkward to have slide-out be so handy and in and split be so manual!

It's such a lovely tool. Really transformative for the rebase-heavy workflow we have at work.

aredridel avatar Oct 13 '22 03:10 aredridel

It's such a lovely tool. Really transformative for the rebase-heavy workflow we have at work.

Thanks 😍 out of curiosity, how did you get to know of this tool... was it via Ben Congdon's blog?

That's exactly it, and what I've been doing, but it feels awkward to have slide-out be so handy and in and split be so manual!

Okay... as you're probably facing this scenario even more than I do myself... do you have a specific idea how a command-line interface for that could specifically look like? 🤔 maybe git machete add could be refined with some extra options?

PawelLipski avatar Oct 13 '22 16:10 PawelLipski

add would work delightfully to point a branch to a new parent — git machete discover in fact has roughly the right behavior, but re-does too much. Just updating the specified or current branch with a new parent (and moving the child tree with it) would be delightfully sensible.

git machete split commitish newname would be pretty decent for the split operation. It's common that I'll end up with some easily-shipped basis commits, and then something that needs refinement or controversial, and so needs to be held for more discussion or updates. That's my use case for split: let me ship the dependency updates, or bug fix built in the process of building something new.

aredridel avatar Oct 13 '22 16:10 aredridel

Just updating the specified or current branch with a new parent

Okay! sounds reasonable indeed... we've even got that implemented (under the name of Slide In) in git-machete-intellij-plugin, actually 😅

git machete split

+1 as well... might take a while before we get to that as we've got a queue of feature requests and limited manpower 🚧 in the meantime, if yourself or any of your colleagues got some spare time... we'd happily accept a contribution ;)

PawelLipski avatar Oct 13 '22 18:10 PawelLipski

I might just do that if I can squeeze some time and attention out! But in any case, thank you for a delightful tool!

aredridel avatar Oct 14 '22 14:10 aredridel