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

git lfs lock works incorrectly if the CD contains a junction, and the lock can't be removed #3554

Closed
JFLarvoire opened this issue Mar 7, 2019 · 6 comments
Labels

Comments

@JFLarvoire
Copy link

Using Git for Windows v2.21.0.
In my root directory, I have a C:\JFL junction that points to my home directory C:\Users\Larvoire\Documents. To save typing, I usually use that junction to quickly change the current directory to one of my sources directories.

C:\JFL\Temp>dir C:\ | findstr JFL
2018-02-13  11:01    <JUNCTION>     JFL [C:\Users\Larvoire\Documents]

C:\JFL\Temp>cd C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide

C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide>

I ran the commands below, and now I can't get rid of the lock:

C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs lock SAFcollectorUserGuide.docx
Locked ../../../../Users/Larvoire/Documents/SRC/HPSD/SAFcollector4/Collectors/UserGuide/SAFcollectorUserGuide.docx

C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs locks
../../../../Users/Larvoire/Documents/SRC/HPSD/SAFcollector4/Collectors/UserGuide/SAFcollectorUserGuide.docx     jf-larvoire     ID:11

C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs unlock SAFcollectorUserGuide.docx
Git status failed: exit status 128

C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs unlock ../../../../Users/Larvoire/Documents/SRC/HPSD/SAFcollector4/Collectors/UserGuide/SAFcollectorUserGuide.docx
Unable to determine path: FindFirstFile C:\Users\Larvoire\Documents\SRC\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\Collectors\UserGuide\SAFcollectorUserGuide.docx: The system cannot find the path specified.

C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs unlock -i 11
Git status failed: exit status 128

C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs locks
../../../../Users/Larvoire/Documents/SRC/HPSD/SAFcollector4/Collectors/UserGuide/SAFcollectorUserGuide.docx     jf-larvoire     ID:11

C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide>

(Side issue (?): When I tried using the relative path above, notice how the FindFirstFile error references a pathname that's obviously wrong, with \Users\Larvoire\Documents\SRC repeated twice!
I tried moving up two levels, to the base of the project. There the symptom is the same, but the repeating string is \Users\Larvoire.
Unfortunately, I can't go two more levels up, because then git can't find its project configuration files.)

When not using the C:\JFL junction, another lock can be created and deleted, but the initial lock still can't:

C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs lock SAFcollectorUserGuide.docx
Locked Collectors/UserGuide/SAFcollectorUserGuide.docx

C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs locks
../../../../Users/Larvoire/Documents/SRC/HPSD/SAFcollector4/Collectors/UserGuide/SAFcollectorUserGuide.docx     jf-larvoire     ID:11
Collectors/UserGuide/SAFcollectorUserGuide.docx                                                                 jf-larvoire     ID:12

C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs unlock SAFcollectorUserGuide.docx
Unlocked Collectors/UserGuide/SAFcollectorUserGuide.docx

C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs unlock --force -i 11
Git status failed: exit status 128

C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs locks
../../../../Users/Larvoire/Documents/SRC/HPSD/SAFcollector4/Collectors/UserGuide/SAFcollectorUserGuide.docx     jf-larvoire     ID:11

C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\Collectors\UserGuide>

I suspect this is another case of bug #3277 "Canonicalize paths properly on Windows".
While you're at it, you may want to check if SYMLINKD symbolic links have the same problem. (As junctions are just variations on that theme.)

Also the unlock --force option should be able to remove the lock when specified by ID, even if it thinks that the path does not make sense.

@bk2204
Copy link
Member

bk2204 commented Mar 7, 2019

Hey, thanks for writing in.

This is an interesting problem that we haven't seen before. We're producing a relative path that is outside of the top-level directory, which we shouldn't be doing. We rely on Git to canonicalize the path that it gives us, but I'm thinking that in this case, that might not be happening.

Can you provide the output of git lfs env when run in this directory? I want to see what Git thinks the path is here.

@JFLarvoire
Copy link
Author

Here it is:

C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs env
git-lfs/2.7.1 (GitHub; windows amd64; go 1.11.5; git 6b7fb6e3)
git version 2.21.0.windows.1

Endpoint=https://github.hpe.com/TME/SAFcollector4.git/info/lfs (auth=none)
  [email protected]:TME/SAFcollector4.git
LocalWorkingDir=C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4
LocalGitDir=C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\.git
LocalGitStorageDir=C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\.git
LocalMediaDir=C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\.git\lfs\objects
LocalReferenceDirs=
TempDir=C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\.git\lfs\tmp
ConcurrentTransfers=3
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\.git\lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic
UploadTransfers=basic
GIT_EXEC_PATH=C:/Program Files/Git/mingw64/libexec/git-core
GIT_SSH=C:\Program Files\TortoiseGit\bin\TortoiseGitPlink.exe
git config filter.lfs.process = "git-lfs filter-process"
git config filter.lfs.smudge = "git-lfs smudge %f"
git config filter.lfs.clean = "git-lfs clean %f"

C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide>

@bk2204
Copy link
Member

bk2204 commented Mar 7, 2019

Thanks for that information. I've looked at this on a Windows VM and the issue is that git rev-parse --show-toplevel reports an incorrect path. Specifically, it fails to consider the junction point when resolving symlinks.

Git LFS, on the other hand, resolves those paths correctly, and then there's a mismatch between the absolute directory computed by Git LFS and the unresolved path produced by Git. I've opened git-for-windows/git#2114 to get this issue addressed.

I think on our side, we need to reject any relative paths that contain .., since that means something is wrong. I also want to see if we can force an unlock by ID as well.

@JFLarvoire
Copy link
Author

@bk2204 Thanks implementing a fix. Could you please send me a binary version including it?
I'm still stuck with that locked file that refuses to be unlocked. And this is now becoming a serious problem for us, as somebody else needs to work on it.

@bk2204
Copy link
Member

bk2204 commented Apr 8, 2019

Sure. There are two binaries in the attached zip file, but note that they aren't signed.

git-lfs-windows-master.zip

@JFLarvoire
Copy link
Author

Thanks a lot!
After a few hiccups, I eventually managed to delete that !@#$%^ lock!

C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs unlock -f -i 11
Unable to unlock 11: You must have admin access to force delete a lock

C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\Collectors\UserGuide>

Then the project maintainer kindly promoted me as project admin.

C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs locks
../../../../Users/Larvoire/Documents/SRC/HPSD/SAFcollector4/Collectors/UserGuide/SAFcollectorUserGuide.docx     jf-larvoire     ID:11

C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs unlock -f -i 11
Unable to unlock 11: CreateFile C:\Users\Larvoire\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\Collectors\UserGuide\SAFcollectorUserGuide.docx: The system cannot find the path specified.

C:\Users\Larvoire\Documents\SRC\HPSD\SAFcollector4\Collectors\UserGuide>cd \JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide

C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide>

Notice the duplicated \Users\Larvoire in the error message above.
Then I thought that I should retry using the original Current Directory with the junction:

C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs unlock -f -i 11
Unable to unlock 11: Lock not found

C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide>git lfs locks

C:\JFL\SRC\HPSD\SAFcollector4\Collectors\UserGuide>

Success at last, despite the error message. :-)
And confirmed by my colleague who was then able to lock the file on his side.
So thanks again for all.

Jean-François

@bk2204 bk2204 closed this as completed Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants