Closed jyn514 closed 2 years ago
ah, by reading the source I found that I can use --force
to ignore this error. It would be nice for absorb
to suggest that.
i'm not morally opposed to this but, as i discussed here https://github.com/tummychow/git-absorb/pull/49#issuecomment-939393646 the correct behavior is not obvious when head is detached. sometimes it makes sense to force, other times passing force will do nothing because your head is actually the same as some commit on a branch. happy to take suggestions on how the ux should be adjusted
it'll hide all ancestors of the master branch, which includes 3333, so there will be no commits in the stack, and you'll get the "No commits available to fix up" error.
you wouldn't be able to absorb earlier into, say, 2222 (unless you used the --base flag). my guess is, what you really want is for git absorb to pick the root of the rebase as the default base if there is one. that would be a bit harder to do; idk if libgit2 makes it easy to get that information.
this seems fine, though? absorb already requires you to specify --base
if you pass --force outside a branch, I think that behavior is fine.
I agree using merge-base
of HEAD and the target branch would be nice, but I don't think absorb should give a hard error if it can't determine the base; it should just require you to pass --base yourself.
by the way, I just wanted to say thank you so much for making git-absorb, it's saved me at least half an hour just today :)
hm, that's a good point. lemme see if amending the error message is the most sensible thing to do
yeah it seemed reasonable since we already have another warning that's similar
Jul 04 16:53:46.261 CRIT absorb failed, err: HEAD is not a branch, use --force to override, line: 109, module: git_absorb
Amazing, thank you!
My use case is that I want to do interactive rebasing to absorb a past commit into the tree. I ran:
git rebase -i origin/master
commit
toedit
git reset HEAD~ && git add -u && git absorb
That gives a hard error:
but I'm not sure why being on a branch should matter?