Skip to content

gitbutler-edit-mode: make edit mode commit have parent#12935

Open
jonathantanmy2 wants to merge 1 commit intomasterfrom
jt/parent
Open

gitbutler-edit-mode: make edit mode commit have parent#12935
jonathantanmy2 wants to merge 1 commit intomasterfrom
jt/parent

Conversation

@jonathantanmy2
Copy link
Collaborator

When entering edit mode, a temporary commit needs to be created if either the commit being edited (C) or the parent of the commit being edited (P) is conflicted, so that (among other things) git status shows something reasonable. Currently, this temporary commit is created with no parents and a commit message duplicated from P.

This is probably less user-friendly than it could be - the lack of parents means that the user cannot see C's place in the commit graph, and the duplicated commit message might make the user wonder if P was also changed. Therefore, when entering edit mode, if a temporary commit is needed, create it with parent P and a commit message that informs the user of what's going on.

@vercel
Copy link

vercel bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
gitbutler-web Ignored Ignored Preview Mar 19, 2026 7:19pm

Request Review

@github-actions github-actions bot added the rust Pull requests that update Rust code label Mar 19, 2026
When entering edit mode, a temporary commit needs to be created if
either the commit being edited (C) or the parent of the commit being
edited (P) is conflicted, so that (among other things) `git status`
shows something reasonable. Currently, this temporary commit is created
with no parents and a commit message duplicated from P.

This is probably less user-friendly than it could be - the lack of
parents means that the user cannot see C's place in the commit graph,
and the duplicated commit message might make the user wonder if P was
also changed. Therefore, when entering edit mode, if a temporary commit
is needed, create it with parent P and a commit message that informs the
user of what's going on.
@jonathantanmy2
Copy link
Collaborator Author

There are some e2e-playwright tests that are failing because I've changed the commit message of the temporary commit. If people think my change is a good idea, I'll go back and fix those.

Copy link
Collaborator

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much, I can't wait to land this to help with VBH removal!

Comment on lines +27 to +29
const SELF_CONFLICTED :&[u8]= b"(temporary commit)\n\nThis commit was created to serve as a temporary HEAD because a conflicted commit is being edited.\n";

const PARENT_CONFLICTED:&[u8] = b"(temporary commit)\n\nThis commit was created to serve as a temporary HEAD because the parent of the commit being edited is conflicted.\n";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something we have to point out?
My intuitive preference would be that everything looks 'normal', and that certainly includes the commit message.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's take the SELF_CONFLICTED case. The commit graph in question is something like:

C (conflicted)
|
P

and after entering edit mode editing C, it's (X is the temporary commit, which we apparently need because we want to use the "ours" tree as a base):

X [HEAD] + changes in index
|
P

So the question is what should the commit message of X be. Previously, it was the same as P but now I have switched it to what you see in the PR. I think what's in the PR makes more sense than duplicating the commit message of P (and thus seeing the same commit message twice), but maybe I'm overlooking something.

For reference, the PARENT_CONFLICTED case has the following commit graph:

C
|
P (conflicted)

and after entering edit mode:

X [HEAD] + changes in index
|
P (conflicted)

X is the autoresolution of P.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Maybe this is also something that can be more Git like by asking what Git does in similar situations.

So the question is what should the commit message of X be. Previously, it was the same as P [..]

Since we are at the desired commit and want to do something like amend on it, it seems the C should have the commit message of C, and not P (or something temporary).

In a way, the state is like we emptied the commit we want to edit, and the next commit (or the button press in GB) should amend to that commit, so the commit message I expect would always be the one of the commit I am editing, conflicted or not.

To me there is no other choice than that, so I wonder if I am missing something crucial here despite the excellent explanation of what's happening.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the question is what should the commit message of X be. Previously, it was the same as P [..]

Since we are at the desired commit and want to do something like amend on it, it seems the C should have the commit message of C, and not P (or something temporary).

The current behavior is as if we git checkout C and git reset --soft HEAD^ (typical commands to use when splitting a commit). But I do like your proposal that we are doing something like amend - it is very similar to what we do when doing git rebase -i (which I do think is the equivalent of "edit mode" in plain Git).

In a way, the state is like we emptied the commit we want to edit, and the next commit (or the button press in GB) should amend to that commit, so the commit message I expect would always be the one of the commit I am editing, conflicted or not.

I don't think the commit should necessarily be emptied, but I don't feel too strongly about that.

To me there is no other choice than that, so I wonder if I am missing something crucial here despite the excellent explanation of what's happening.

Of course there are other choices, but your choice does seem like the best one so far. Thanks for the brainstorming. I'll implement it early next week and see what other people think (my biggest concern is backwards compatibility with existing edit mode metadata stored on disk, but I'll think through it more closely when I implement it).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the commit should necessarily be emptied, but I don't feel too strongly about that.

Yes, let's scratch that. This was coming from StackedGit and is called "spill" there, which is something else.
When editing, I think it's fine to just make it easy to git amend, which does indeed seem like what edit-mode is in the non-conflicting case.

[..] (my biggest concern is backwards compatibility with existing edit mode metadata stored on disk, but I'll think through it more closely when I implement it).

Oh, I wasn't aware it has more than the gitbutler/edit reference, and I am definitely looking forward to learning more about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants