Skip to content
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

orgzly keeps syncing to a conflict branch even after the branch has been merged #237

Open
1 task done
wilderjds opened this issue Apr 30, 2024 · 12 comments
Open
1 task done
Labels
bug Something isn't working Git repos Related to Git syncing

Comments

@wilderjds
Copy link

  • I have searched for existing issues that may be the same as or related to mine.

Please complete the following information:

Device: Pixel 7
Android Version: 14 
Orgzly Revived Version: 
Repository type(s) used: git 

On a git repository, orgzly keep syncing to a merge-conflict branch even if the branch has been merged to master. No conflicts are present; I even removed the branch from the remote, but orgzly keeps creating it.
This has worked OK for some time but with the last conflict it is not resetting to master.

@wilderjds wilderjds added the bug Something isn't working label Apr 30, 2024
@amberin amberin added the Git repos Related to Git syncing label May 1, 2024
@amberin
Copy link
Member

amberin commented May 1, 2024

I am currently testing a completely new git sync logic, so my memory of how the current logic works may be wrong, but I believe there is a bug which means that this will happen if you delete the conflict branch on the remote side before Orgzly has returned to the main branch. I think you need to resolve the conflict on the temp branch (i.e. merge main into it), leave it like that on the remote side, and trigger sync in Orgzly. Otherwise, Orgzly will simply push its view of the temp branch, and not attempt to return to the main branch. Once you're back on main, you can then safely delete the temp branch on the remote.

This is of course confusing and bad, but it is solved in my ongoing overhaul of the git sync logic.

Please try this and let me know if it works.

@wilderjds
Copy link
Author

wilderjds commented May 1, 2024

Thanks for your reply. It does not work as it should; here is what happens

I merge the conflict branch to master on my laptop, then push to the remote
After that, I sync on Android
Then I push some changes from the laptop to master
After that, I sync on Android; changes are picked up, but the notebook is still on the same conflict branch
If I make some changes from Android, they go to the same conflict branch, and not to master
Even if the branch is deleted on the remote, changes pushed to master are picked up from Android, and then the branch is re-created upon sync'ing

@amberin
Copy link
Member

amberin commented May 1, 2024

Sounds very strange indeed... If you look at the repo settings, is the main branch name correct? (See #29.)

@amberin
Copy link
Member

amberin commented May 1, 2024

FYI, this is where you should end up in the code, but for some reason don't (or attemptReturnToMainBrach fails): https://github.com/orgzly-revived/orgzly-android-revived/blob/master/app/src/main/java/com/orgzly/android/git/GitFileSynchronizer.java#L318

But, as I was trying to express earlier, one known issue is that, if the current branch does not exist on the remote (because you have deleted the temp branch), you will end up here, and no attempt is done to return to the main branch: https://github.com/orgzly-revived/orgzly-android-revived/blob/master/app/src/main/java/com/orgzly/android/git/GitFileSynchronizer.java#L327

When you say you are receiving new changes on master, does the book status say "loaded from branch master"? Because that message means that the repo is on that branch. Any subsequent push of a temp branch should be a new one.

@wilderjds
Copy link
Author

When you say you are receiving new changes on master, does the book status say "loaded from branch master"? Because that message means that the repo is on that branch. Any subsequent push of a temp branch should be a new one.

No,
I get "loaded from branch merge-conflict-xxx", but the changes we re only pushed to master

@wilderjds
Copy link
Author

Sounds very strange indeed... If you look at the repo settings, is the main branch name correct? (See #29.)

Yes, the branch is "master". Always had been.

@stfl
Copy link

stfl commented May 2, 2024

I am seeing similar issues when rebasing master on top of merge-xyz.org-... branch.
After I push to origin/master Orgzly updates the merge branch to master but stays on the merge branch.

Even though the merge branch can be fast-forwarded to master, either after a rebase or a merge, Orgzly creates a new merge branch.

@stfl
Copy link

stfl commented May 2, 2024

5422c66 *   origin/master origin/merge-freelance.org-28ae343-2024-05-02_142716 origin/merge-freelance.org-28ae343-2024-05-02_140728 Merge remote-tracking branch 'origin/merge-freelance.org-28ae343-2024-05-02_140728'
        |\  
a07f3a3 | * Orgzly update: inbox.org
955a6b4 * | origin/merge-freelance.org-28ae343-2024-05-02_140123 changes from amsel on Thu May 2 02:06:53 PM CEST 2024
78304c9 * | changes from amsel on Thu May 2 02:06:48 PM CEST 2024
        |/  
4d3d93a * Orgzly update: inbox.org
e221d7e * Orgzly update: inbox.org
76640f8 * origin/merge-freelance.org-28ae343-2024-05-02_084944 changes from amsel on Thu May 2 01:19:29 PM CEST 2024

@wilderjds
Copy link
Author

I probably figured out what was causing the issue for me (but I have no clue about how I ended up with that). I explored the Android repo with termux and found out that master had diverged from the remote (despite being on a conflict branch). Orgzly-revived was happily fetching updates from master and the conflict branch. But since master had diverged it refused to fast-forward. Since we were sitting on the conflict branch no action was taken, master was not in sync with the conflict and no "return to main branch" was happening.

I manually merged master with the remote and then orgzly was happy.

@stfl
Copy link

stfl commented May 2, 2024

Yes. That makes sense. I am the end doing a rebase forces the other end to do a reset.

I am using git-sync for my other devices which rebases as the default sync procedure.

@amberin
Copy link
Member

amberin commented May 2, 2024

@wilderjds Interesting. I'd love to know how your master branch ended up in that diverged state...

@wilderjds
Copy link
Author

@wilderjds Interesting. I'd love to know how your master branch ended up in that diverged state...

No idea tbh, but will report here if it happens again. Now that I found out that I can keep track of stuff in termux, it will be easier to see what is going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Git repos Related to Git syncing
Projects
None yet
Development

No branches or pull requests

3 participants