Skip to main content



      Home
Home » Eclipse Projects » EGit / JGit » Difficulty understanding Merge states and behavior
Difficulty understanding Merge states and behavior [message #1861340] Fri, 06 October 2023 13:46 Go to next message
Eclipse UserFriend
Fig A shows the initial state of the repo. Only the main branch is on the remote and the Git Staging view correctly shows the local is 3 commits ahead. The contents of the Notes.txt file for the debug-01 branch is also shown (left sideways).

In Fig B, I Merged the debug-01 branch into the test-01 branch. Step 4 correctly shows the resulting conflict in the Notes.txt file.

In Fig C, the Git Staging view correctly shows the test-01 branch state is "Conflicts". In this state I can't activate a different branch so I can't verify the state of the other branches. As an experiment, I attempt to undo this merge by replacing Notes.txt with the HEAD version (last commit) in the test-01 branch. This was done by right-clicking Notest.txt in "Unstaged Changes" then selecting "Replace with HEAD Revision".

The upper left in Fig D shows Notes.txt was restored. Also note that all commits on all branches are now the same as Fig A. The Git Staging view says that branch is still "Merged" even though I "undid" the merge. The other 2 branches also show "Merged". I'm especially puzzled why it says main was merged even though no commits on that branch were ever affected.

It seems the branch states for "Merged" and "Conflicts" get stuck or misapplied to other branches then don't automatically update to show the current state.
Fig E is an attempt to "fix" the state of the branches by using Reset->Hard to the HEAD of the debug-01 branch. This shouldn't change anything but the Git Staging view eventually shows the branches with the correct (original) state.

index.php/fa/43557/0/
Re: Difficulty understanding Merge states and behavior [message #1861346 is a reply to message #1861340] Fri, 06 October 2023 14:49 Go to previous messageGo to next message
Eclipse UserFriend
"Merged" is not the state of a branch but the repository state.
It's defined here:
https://git.eclipse.org/r/plugins/gitiles/jgit/jgit/+/refs/heads/master/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryState.java#93

A branch has not much state, it's just a named pointer to some commit.
And HEAD points to the current branch (the one which was checked out).
Re: Difficulty understanding Merge states and behavior [message #1861560 is a reply to message #1861346] Wed, 18 October 2023 16:58 Go to previous message
Eclipse UserFriend
Thanks for the info. This behavior does fit with this being the repo state. To an EGit novice, the present implementation gives a convincing illusion branches are separate objects (see Fig F). I predict this illusion will one day get extended to include the "Merged" and "Conflicts" states but I admit it would be tricky to implement.

In the present EGit, what I've been doing to clear the "Merged" state (Fig D to Fig E) is a Reset->Hard at the HEAD of that branch then checking out a different branch in that repo.

index.php/fa/43598/0/
Previous Topic:QUARANTINE ENVIRONMENT in JGit
Next Topic:Git worktree support in egit
Goto Forum:
  


Current Time: Thu May 22 18:24:49 EDT 2025

Powered by FUDForum. Page generated in 0.03008 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top