Page 1 of 1

Git - cannot pull, files are desynchonized somehow

Posted: Thu Jul 23, 2020 3:40 pm
by chrispitude
One of my users is unable to do a Pull in the Git Staging window. The pull button reports her as 27 commits behind.

When she presses the Pull button, it shows "connecting" for the status, but then nothing happens - there's no warnings or errors, and the pull button remains at 27 commits behind.

When I invoke Oxygen from its Windows 10 .bat script via a command line window, I see the following messages during the pull:

Code: Select all

17:46:38.706 [pool-2-thread-1] ERROR com.oxygenxml.git.utils.GitOperationScheduler - java.util.concurrent.ExecutionException: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of reset command. Cannot lock C:\Users\swatib\Documents\DITA\dita-digital\.git\index. Ensure that no other process has an open file handle on the lock file C:\Users\swatib\Documents\DITA\dita-digital\.git\index.lock, then you may delete the lock file and retry.
java.util.concurrent.ExecutionException: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of reset command. Cannot lock C:\Users\swatib\Documents\DITA\dita-digital\.git\index. Ensure that no other process has an open file handle on the lock file C:\Users\swatib\Documents\DITA\dita-digital\.git\index.lock, then you may delete the lock file and retry.
        at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:?]
        at java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[?:?]
        at com.oxygenxml.git.utils.GitOperationScheduler$1.afterExecute(GitOperationScheduler.java:32) [git.support-2.2.0.jar:?]
...
Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of reset command. Cannot lock C:\Users\swatib\Documents\DITA\dita-digital\.git\index. Ensure that no other process has an open file handle on the lock file C:\Users\swatib\Documents\DITA\dita-digital\.git\index.lock, then you may delete the lock file and retry.
        at org.eclipse.jgit.api.ResetCommand.call(ResetCommand.java:209) ~[org.eclipse.jgit-5.7.0.202003110725-r.jar:5.7.0.202003110725-r]
        at com.oxygenxml.git.service.GitAccess.pull(GitAccess.java:1095) ~[git.support-2.2.0.jar:?]
...
Caused by: org.eclipse.jgit.errors.LockFailedException: Cannot lock C:\Users\swatib\Documents\DITA\dita-digital\.git\index. Ensure that no other process has an open file handle on the lock file C:\Users\swatib\Documents\DITA\dita-digital\.git\index.lock, then you may delete the lock file and retry.
        at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:218) ~[org.eclipse.jgit-5.7.0.202003110725-r.jar:5.7.0.202003110725-r]
        at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:289) ~[org.eclipse.jgit-5.7.0.202003110725-r.jar:5.7.0.202003110725-r]
        at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:255) ~[org.eclipse.jgit-5.7.0.202003110725-r.jar:5.7.0.202003110725-r]
        at org.eclipse.jgit.lib.Repository.lockDirCache(Repository.java:1269) ~[org.eclipse.jgit-5.7.0.202003110725-r.jar:5.7.0.202003110725-r]
        at org.eclipse.jgit.api.ResetCommand.resetIndex(ResetCommand.java:365) ~[org.eclipse.jgit-5.7.0.202003110725-r.jar:5.7.0.202003110725-r]
        at org.eclipse.jgit.api.ResetCommand.call(ResetCommand.java:185) ~[org.eclipse.jgit-5.7.0.202003110725-r.jar:5.7.0.202003110725-r]
        at com.oxygenxml.git.service.GitAccess.pull(GitAccess.java:1095) ~[git.support-2.2.0.jar:?]
...
We restarted her laptop and deleted the .lock file, and now we get a message that she cannot pull because she has local changes that would be overwritten. But here's the weird thing - somehow her locally modified files *are* the changes that are in those 27 missing commits!
image.png
image.png (9.9 KiB) Viewed 977 times
image.png
image.png (16.18 KiB) Viewed 977 times
Somehow she has the latest files (or almost all of them?) but her repo thinks she's behind and sees them as local modifications. Maybe Git crashed during a pull and left it in a locked and updated but not resolved state? How do I resolve this?

Re: Git - cannot pull, files are desynchonized somehow

Posted: Thu Jul 23, 2020 4:06 pm
by chrispitude
I thought about discarding all the changes that aren't her local work and re-pulling, but I was worried this might break things more than they are. I figured I'd check here for advice first.

Re: Git - cannot pull, files are desynchonized somehow

Posted: Thu Jul 23, 2020 5:29 pm
by alex_jitianu
Hello,

We normally intercept the lock related exception and present a message to the user. I will add an issue to investigate.

Most likely a pull crashed, somehow. You can discard or, if the user didn't have any local changes, you could run from the command like:

Code: Select all

git reset -q --hard HEAD
To be on the safe side, you can make a local copy of the entire WC directory, which includes the local repository as well. If things go wrong, you can restore it and try again.

Best regards,
Alex

Re: Git - cannot pull, files are desynchonized somehow

Posted: Fri Jul 31, 2020 3:05 pm
by chrispitude
Following up - I was able to discard all the local "changed" (but not really) files and repull. Everything completed successfully.

Re: Git - cannot pull, files are desynchonized somehow

Posted: Fri Nov 20, 2020 5:41 pm
by alex_jitianu
Hello,

In the latest Git client release, 2.3.1, we identify this special situation on pull and we present to the user a message dialog describing the situation and possible solutions.

I hope it helps,
Alex