-
Notifications
You must be signed in to change notification settings - Fork 200
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 doesn't appear to be working #511
Comments
Hey! Thank you for the issue. There were always difficulties with LFS because lefthook replaces the hook generated by LFS. Could you send the output of the |
Here you go. I was wondering because there is no STDIN available in lefthook maybe it is appending empty lfs refs and it thinks it has done everything it needs.
|
We're having the same error sadly, since using lefthook the lfs objects do not get pushed and we encounter smudge errors when trying to fetch the commits containing them. Here's an example of an usual push that should push lfs objects but doesnt: $ LEFTHOOK_VERBOSE=1 git push origin the_branch:the_branch
+ '[' '' = 0 ']'
+ call_lefthook run pre-push origin https://remote
++ git rev-parse --show-toplevel
+ dir=C:/DNE/Git/monorepo-dev
++ uname
++ tr '[:upper:]' '[:lower:]'
+ osArch=mingw64_nt-10.0-19045
++ uname -m
++ sed s/aarch64/arm64/
+ cpuArch=x86_64
+ test -n ''
+ lefthook.exe -h
+ lefthook.bat -h
+ test -f C:/DNE/Git/monorepo-dev/node_modules/lefthook/bin/index.js
+ test -f C:/DNE/Git/monorepo-dev/node_modules/@evilmartians/lefthook/bin/lefthook_mingw64_nt-10.0-19045_x86_64/lefthook.exe
+ test -f C:/DNE/Git/monorepo-dev/node_modules/@evilmartians/lefthook-installer/bin/lefthook_mingw64_nt-10.0-19045_x86_64/lefthook.exe
+ bundle exec lefthook -h
+ yarn lefthook -h
+ pnpm lefthook -h
+ swift package plugin lefthook
+ command -v npx
+ npx lefthook run pre-push origin https://remote
│ [lefthook] cmd: [git rev-parse --show-toplevel]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: C:/DNE/Git/monorepo-dev
│ [lefthook] cmd: [git rev-parse --git-path hooks]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git/hooks
│ [lefthook] cmd: [git rev-parse --git-path info]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git/info
│ [lefthook] cmd: [git rev-parse --git-dir]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git
│ [lefthook] cmd: [git hash-object -t tree /dev/null]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: 4b825dc642cb6eb9a060e54bf8d69288fbee4904
│ [git-lfs] executing hook: git lfs pre-push origin https://remote
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: Create a new pull request for 'the_branch':
remote: https://remote
remote:
remote: . Processing 1 references
remote: Processed 1 references in total
To https://remote
* [new branch] the_branch -> the_branch
* git lfs seems to be called, but the objects are not found on the remote. Trying to get more information with $ LEFTHOOK_VERBOSE=1 GIT_TRACE=1 git push origin the_branch:the_branch
11:00:09.850967 exec-cmd.c:244 trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
11:00:09.857969 git.c:463 trace: built-in: git push origin the_branch:the_branch
11:00:09.858969 run-command.c:659 trace: run_command: GIT_DIR=.git git remote-https origin https://remote
11:00:09.868974 exec-cmd.c:244 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
11:00:09.874980 git.c:749 trace: exec: git-remote-https origin https://remote
11:00:09.874980 run-command.c:659 trace: run_command: git-remote-https origin https://remote
11:00:09.886982 exec-cmd.c:244 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
11:00:10.468957 run-command.c:659 trace: run_command: 'git credential-manager get'
11:00:10.987143 exec-cmd.c:244 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
11:00:10.993148 git.c:749 trace: exec: git-credential-manager get
11:00:10.993148 run-command.c:659 trace: run_command: git-credential-manager get
11:00:11.056920 exec-cmd.c:244 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
11:00:11.063584 git.c:463 trace: built-in: git config --null --list
11:00:12.013188 run-command.c:659 trace: run_command: 'git credential-manager store'
11:00:12.054024 exec-cmd.c:244 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
11:00:12.060026 git.c:749 trace: exec: git-credential-manager store
11:00:12.060026 run-command.c:659 trace: run_command: git-credential-manager store
11:00:12.126649 exec-cmd.c:244 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
11:00:12.133892 git.c:463 trace: built-in: git config --null --list
11:00:12.345316 run-command.c:659 trace: run_command: .git/hooks/pre-push origin https://remote
+ '[' '' = 0 ']'
+ call_lefthook run pre-push origin https://remote
++ git rev-parse --show-toplevel
11:00:12.398168 exec-cmd.c:244 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
11:00:12.404169 git.c:463 trace: built-in: git rev-parse --show-toplevel
+ dir=C:/DNE/Git/monorepo-dev
++ uname
++ tr '[:upper:]' '[:lower:]'
+ osArch=mingw64_nt-10.0-19045
++ uname -m
++ sed s/aarch64/arm64/
+ cpuArch=x86_64
+ test -n ''
+ lefthook.exe -h
+ lefthook.bat -h
+ test -f C:/DNE/Git/monorepo-dev/node_modules/lefthook/bin/index.js
+ test -f C:/DNE/Git/monorepo-dev/node_modules/@evilmartians/lefthook/bin/lefthook_mingw64_nt-10.0-19045_x86_64/lefthook.exe
+ test -f C:/DNE/Git/monorepo-dev/node_modules/@evilmartians/lefthook-installer/bin/lefthook_mingw64_nt-10.0-19045_x86_64/lefthook.exe
+ bundle exec lefthook -h
+ yarn lefthook -h
+ pnpm lefthook -h
+ swift package plugin lefthook
+ command -v npx
+ npx lefthook run pre-push origin https://remote
│ [lefthook] cmd: [git rev-parse --show-toplevel]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: 11:00:15.987374 exec-cmd.c:244 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
11:00:15.992376 git.c:463 trace: built-in: git rev-parse --show-toplevel
C:/DNE/Git/monorepo-dev
│ [lefthook] cmd: [git rev-parse --git-path hooks]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: 11:00:16.022296 exec-cmd.c:244 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
11:00:16.029019 git.c:463 trace: built-in: git rev-parse --git-path hooks
.git/hooks
│ [lefthook] cmd: [git rev-parse --git-path info]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: 11:00:16.064186 exec-cmd.c:244 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
11:00:16.069310 git.c:463 trace: built-in: git rev-parse --git-path info
.git/info
Error: mkdir .\11:00:16.064186 exec-cmd.c:244 trace: resolved executable dir: C:\Program Files\Git\mingw64\libexec\git-core
11:00:16.069310 git.c:463 trace: built-in: git rev-parse --git-path info
.git\info: The filename, directory name, or volume label syntax is incorrect.
error: failed to push some refs to 'https://remote' Running |
Hey! Actually lefthook is just calling what Git LFS adds in the .git/hooks/pre-push with you run #!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'pre-push' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
git lfs pre-push "$@" So, it calls Could you show what's in your hook after running |
Thanks for the quick response.
Same as you, the usual git lfs hook.
Yes it does, we confirmed it after a |
So, it calls the same |
Yes, and as far as I can tell pushing with lefthook installed succeeds, but the objects don't end up on the server which is strange. |
That's weird. I will try to investigate, but please come back with any information you discover. |
Hi, have you had the chance to take a look at this? Do you have an ETA (even very approximate) on when you might? We've recently migrated from (I hope this doesn't sound passive-aggressive, I'm just trying to get a clear picture so we can decide what to do on our end) |
@mrexox git lfs pre-push <remote> [remoteurl]
Responds to Git pre-hook events. It reads the range of commits from
STDIN, in the following format:
<local-ref> SP <local-sha1> SP <remote-ref> SP <remote-sha1> \n
This issue has an easy reproduction in a repository with pre-push hooks. |
Tried adding a dumb Lefthook should probably read stdin and provide it to all hooks as needed. |
@tdesveaux , it makes sense to me. Thank you for checking the RawExecute method. I agree that all hooks should receive the same STDIN in case of pre-push hook. I will try to think out this feature. The only complication here is that some commands may be executed in interactive mode, so we can't just read STDIN into a buffer for them. But I guess this is anyway feasible to find a workaround. |
If I can suggest a quick "fix" for the moment. This way, you can add I'm not knowledgeable on the lefthook codebase at all, so this might not be possible. If this suggestion is fine with you, I could try to implement it. |
I like your suggestion. I'd be glad to receive a PR with this fix 👍 |
🔧 Summary
We have lfs setup on our environments and after installing the lefthook hooks it replaces the git lfs hooks. From the documentation it lefthook does support lfs and if I turn on verbose I can see it try to execute lfs but not sure if there is secret sauce in the lfs hooks but every push doens't include the lfs file upload.
I have tried both wsl2 and windows and both behave the same. If I remove the lefthook pre-push hooks and re-instate the lfs ones using
git lfs update --force
. If i push then i can see that the lfs update has triggered.The only thing I can think of is that potentially would be different execution environment between the two. I noticed that the hook uses
git-lfs
and the lefthook call usesgit lfs
. Lastly I also noticed in the hook for windows it does aunset GIT_PREFIX; ssh git@bitbucket.org 'git-receive-pack '\''brian_garvey/lfs-lefthook-test.git'\'''
Here is the test repo LFS Lefthook Test. I tried to keep it simple.
Lefthook version
lefthook -> 1.4.3
git -> 2.41.0
git-lfs -> 3.0.2 (WSL 2) & 3.3.0 (windows)
Steps to reproduce
lefthook install -a
git add .
andgit commit -m 'message'
git push
Expected results
LFS images are pushed to the remote repository and and subsequently pull them down
Actual results
Check bitbucket UI and see that images are not loading and external pull shows 404 errors for the lfs files
Logs / Screenshots
git hook version
lefthook version
The text was updated successfully, but these errors were encountered: