-
Notifications
You must be signed in to change notification settings - Fork 343
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
Drop commits that were made empty by rebase #229
Comments
For a concrete example: If you have to drop to Git for some reason (e.g. require use of a helper for authentication), this happens:
The only solution here is to abandon the earlier commit which is kind of a bummer of an extra step. A bigger issue is I have also managed to get myself into serious trouble when I pull a commit down while I am working on a new descendant commit, such that I'll follow up here if I manage to do it again. |
It's probably surprising at first, but you should be able to rebase the commits with conflicts onto the updated main branch and the conflicts should go away (IIUC what your situation was). To avoid this confusing-until-you-get-used-to-it state, you could probably have done
Another option might have been to restore the repo to an earlier state. Use |
Curious do we already have something planned for this? I've seen some alias in #1415 (comment) but it doesn't seem to be as reliable as it could be. So wondering if we plan to add this feature or if it would best to do it with scripting / alias? |
I would like to see this implemented. Do you have some time you could spend on it? |
I'm a little worried about losing the commit description for the commit being dropped. It might be hard to recover. I'm not sure what the best solution to this is. Some possibilities (some could be used together):
|
I was reading the Darcs page on using commands and saw this line under the
|
I think I've said this somewhere on Discord, but my vote would be for |
Not too familiar with Rust but if I got sometime I will see if I can look into this. I also agree it might be better if it's in a separate command. In sapling after pull the smartlog will mark the merged commit and the user can decide where to rebase from and the merged commit will automatically be hidden. But for now, I scrambled some scripting into a cli tool here to deal with the simplest case (git fetch + rebase + drop empty), https://github.com/lazywei/fj/, just in case anyone find it also useful. |
@lazywei, if you're interested, I think it should be pretty simple to implement a |
The tracking issue for |
Continuing discussions from #2588, I'm trying to implement this feature. We were discussing the name of the flag, and @martinvonz said the following:
I think the answer to all these questions depends on where jj wants to be on the scale of familiarity to git users vs trying something new, so you can better answer that than me. IMO, I'm unsure about whether to drop already empty commits. It's pretty trivial to do one way or the other, so I can just implement whatever you decide on. |
I agree. I also considered the risk that users will run
I think it's probably best to not drop commits that were already empty. Since they didn't change as part of the rebase, it doesn't seem that there's a reason for rebase to drop them. Note that the working copy is often empty. Sometimes the user has still added a description. If they then run
Are you doing that by adding an option to |
I like the idea of I still have some concerns about losing the descriptions, since it's quite hard to notice whether you lost something important in there, but it seems tough to check whether the descriptions of the commits being rebased are redundant or not. Losing the descriptions seems mostly OK if it's a command-line option. I think it's better to drop already-empty commits. Then, we're dropping all the commits that are empty after the rebase, which seems simpler to reason about. Losing the descriptions feels more problematic in this case, but it feels the alternative is that accidentally making a commit not completely empty can caused the rebase to lose information (in the description) that you expected to be preserved. Update: I didn't see @martinvonz comment above as I was writing this. Martin seems much less concerned about losing descriptions, which is I think the main reason our conclusions differ. Perhaps it's fine not to worry about the descriptions. |
If we're dropping already empty commits, then |
In #3143, I changed the default behavior to keep commits that were already empty. Unrelated to that, is there anything left to do on this bug, or can we close this? |
Vote to close.
…On Sun, Mar 3, 2024 at 9:43 PM Martin von Zweigbergk < ***@***.***> wrote:
In #3143 <#3143>, I changed the
default behavior to keep commits that were already empty.
Unrelated to that, is there anything left to do on this bug, or can we
close this?
—
Reply to this email directly, view it on GitHub
<#229 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAKVPEH4FOGIO7DFFKAXWTYWQCXHAVCNFSM5UCWYR32U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJXGU3TOMZXHE4Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
It can be closed yes, I did notice this. Thanks!
…On Mon, Mar 4, 2024, 07:01 Chris Lewis ***@***.***> wrote:
Vote to close.
On Sun, Mar 3, 2024 at 9:43 PM Martin von Zweigbergk <
***@***.***> wrote:
> In #3143 <#3143>, I changed the
> default behavior to keep commits that were already empty.
>
> Unrelated to that, is there anything left to do on this bug, or can we
> close this?
>
> —
> Reply to this email directly, view it on GitHub
> <#229 (comment)>,
or
> unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/AAAKVPEH4FOGIO7DFFKAXWTYWQCXHAVCNFSM5UCWYR32U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJXGU3TOMZXHE4Q>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
—
Reply to this email directly, view it on GitHub
<#229 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACP25BIPLDBWZAAGW3HQITYWSEF7AVCNFSM5UCWYR32U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJXGY3TQMRVGQ3A>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Description
When a commit becomes empty when it was rebased, we should drop it. We should probably not drop commits that were already empty before the rebase. However, probably should drop merge commits that became non-merge commits. I think the condition should be both of:
By De Morgan's law, the second bullet is "not (empty and not a merge)", which is the negation of the first bullet. So I guess another way of saying it is that if it's now "empty and linear" and wasn't before, then we drop it.
Specifications
The text was updated successfully, but these errors were encountered: