Git - cannot pull, files are desynchonized somehow

<oXygen/> general issues.
chrispitude
Posts: 222
Joined: Thu May 02, 2019 2:32 pm

Git - cannot pull, files are desynchonized somehow

Post by chrispitude » Thu Jul 23, 2020 3:40 pm

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 313 times
image.png
image.png (16.18 KiB) Viewed 313 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?

chrispitude
Posts: 222
Joined: Thu May 02, 2019 2:32 pm

Re: Git - cannot pull, files are desynchonized somehow

Post by chrispitude » Thu Jul 23, 2020 4:06 pm

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.

alex_jitianu
Posts: 779
Joined: Wed Nov 16, 2005 11:11 am

Re: Git - cannot pull, files are desynchonized somehow

Post by alex_jitianu » Thu Jul 23, 2020 5:29 pm

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

chrispitude
Posts: 222
Joined: Thu May 02, 2019 2:32 pm

Re: Git - cannot pull, files are desynchonized somehow

Post by chrispitude » Fri Jul 31, 2020 3:05 pm

Following up - I was able to discard all the local "changed" (but not really) files and repull. Everything completed successfully.

Post Reply