-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
feat(reword): Add --fixup
flag to git branchless reword
#538
Conversation
0fee4f6
to
8fb4c60
Compare
if commits.iter().any(|commit| { | ||
!dag.query() | ||
.is_ancestor(commit_to_fixup.get_oid().into(), commit.get_oid().into()) | ||
.expect("Failed checking ancestry of commit.") | ||
}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that instead of iter().any(...)
I could instead just use a single dag query; perhaps like
commits.intersection(
dag.query.descendents(
commit_to_fixup.get_oid().into()
)
) == commits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind this; I thought that NameSet
allowed for ==/!=
but it doesn't. I'll leave it as is unless you have a suggestion for a more intuitive way to check this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could write this as dag.query().common_ancestors(CommitSet::from(commits))?.contains(commit_to_fixup)?
or something like that. I don't know why there isn't a .equals()
method or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with merging this as-is for now, but maybe we should invent a more straightforward method to fixup commits? For example, it would be more direct if you could write git amend <target> --from <revs>
or something like that. Now that we can move exact commits, it should be possible to move all of the <revs>
right on top of <target>
, and then create a RebaseCommand::Fixup
to handle the fixing up. The implementation for in-memory rebases doesn't seem too bad: you would basically do a pick
but call amend_commit
instead of cherry_pick_fast
.
if commits.iter().any(|commit| { | ||
!dag.query() | ||
.is_ancestor(commit_to_fixup.get_oid().into(), commit.get_oid().into()) | ||
.expect("Failed checking ancestry of commit.") | ||
}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could write this as dag.query().common_ancestors(CommitSet::from(commits))?.contains(commit_to_fixup)?
or something like that. I don't know why there isn't a .equals()
method or similar.
I guess a theoretical fixup command should be part of |
8fb4c60
to
2182a43
Compare
Thanks for the review, @arxanas!
Oh, I'm all over that idea. This just seemed like an easier place to start. 😄 I had been thinking about a separate |
This adds a
--fixup
option togit reword
, providing a convenient way to turn existing commits intofixup!
commit. With this, instead of doing something likegit reword <commits to reword> -m 'fixup! <paste title of commit to fixup>'
, you can now dogit reword <commits to reword> --fixup <commit to fixup>
andreword
will handle the rest, including some error checking.I've been using this for a few weeks and it's been working well. My only remaining concern about this is that the CLI option docs and error messages feel a little clunky because it's hard to talk to about "the commit being fixed up" vs "the commits that will become
fixup!
commits". As usual, suggestions are welcome!