-
Notifications
You must be signed in to change notification settings - Fork 77
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
Characterize base search behaviour #154
Conversation
24018ff
to
9a2990f
Compare
I think this has hit me "in real life" and I didn't realize it at the time! I often create alternative branches for experimentation. Recently I found that git-absorb didn't find a commit to fixup. I added a Out of curiosity, why stop searching when you hit a branch? People's workflows differ, but I'd be content to fixup past branches in many (all?) cases. Assuming the behaviour stays (and I'm not suggesting you remove or change it), might it be useful to emit a warning (similar to the "end of stack reached" one) if a branch halts the search? Thanks for listening. |
could you rebase the pr over master to eliminate the other bits? i'll review after that as for why it works this way: git-absorb has to guess what commit you would counterfactually rebase over when choosing the base. git is not opinionated about how you specify this, and different workflows can differ drastically.
in the first place, how do you even know what the repo's "primary" branch is? master? main? trunk? what if you're in a project that has long-lived release maintenance branches? remember, HEAD's upstream might not be any of these. you have to exclude ancestors of some non-HEAD branches or otherwise you would be grabbing the entire history every time. the current behavior is essentially the most conservative possible thing - it only takes commits that are unique to your current branch, the rationale being you probably don't want to rebase into commits that are shared elsewhere. this is also why your logging idea doesn't make sense - for most users, the stack search stops because it reaches a commit that's an ancestor of master. the warning would get printed every time. (and remember, you don't know what "master" is called in whatever repo you're in.) there's no good balance between "principle of least surprise" and "don't make noise in normal operation". i would be open to config options to change how the default is inferred, except that most possible implementations are themselves nonobvious and ambiguous (eg: https://github.com/tummychow/git-scripts/blob/master/git-gpr-python). it's much easier to just make the user specify a base, as is also required by the actual rebase command |
Even with the force flag, absorbing changes that sit on top of a detached commit that is also pointed to by another branch means the staged changes are skipped and nothing is committed. Hiding commits pointed to by a branch other than HEAD was added in 17ec779, and a detached head doesn't have a branch name, so the commit is hidden.
Absorbing changes that sit on top of a commit that is also pointed to by another branch means the staged changes are skipped and nothing is committed. Hiding commits pointed to by a branch other than HEAD was added in 17ec779.
So long as the detached head isn't pointed to by another branch, the --force flag will cause staged changes to be committed.
9a2990f
to
11e47a8
Compare
Rebased. Thanks for the explanation of the search-stopping behaviour. I appreciate the time you put into it.
Ah, yes. Thanks. I see how it wouldn't work as I imagined it. Perhaps something not unlike the "WARN Could not find a commit to fix up, use --base to increase the search range." that's triggered _only when a commit can't be made for a given hunk. Just thinking out loud. I'll go away with my thoughts and either come back with something that's a little better-developed or will forget about it. |
Ah. Things are coming a little more clear. I think the words I added to the docs are insufficient. The hiding of heads also hides descendants of HEAD as well. In fact, if I read things correctly, that's the whole point of #9. Dropping this PR for now. I've given the commits that were worth keeping to #155. Thanks. |
While working on #145 I had trouble writing a test and ended up discovering what looked like undocumented behaviour: branches interrupt the search for a base commit (if not explicitly specified).
So I added some tests and updated the documentation.
Builds on my proposed refactoring around the configuration and logger objects, because it was convenient for me, but can be reworked.