Skip to content

Improve error message of local transfers when safe.directory is required #5081

@h1day

Description

@h1day

Describe the bug
I couldn't not download an LFS file from a bare repository in a filesever.
But, my repository without LFS worked correctly.

Now I found out that change for cve-2022-24765 occured this problem. And LFS with the command below is working fine.

git config --global --add safe.directory ///DESKTOP-H1DAY/myremote
  1. Is this behavior as intended?
  2. Could you please clarify the message in this case for people like me?
    It was difficult for me to realize that this error was related to the new config..
18:55:04.332857 trace git-lfs: xfer[git-lfs]: error creating handler: failed to call `git rev-parse --git-dir`: exit status 128
18:55:04.333919 trace git-lfs: xfer: Aborting worker process: 0
Error downloading object: image.png (bf4b01c): Smudge error: Error downloading image.png (bf4b01c4837fc9b0366162dd9d0af2fc41ac5773aab9be49dbdcecdd5c3a8f03): EOF

To Reproduce
Steps to reproduce the behavior:

  1. Making a windows shared folder.
  2. Create a bare repository in a shared folder by someone who is not you.
  3. You git clone the bare repository locally.
  4. See error.
  5. Command git config --global --add safe.directory ///DESKTOP-H1DAY/myremote
  6. You git clone the bare repository locally.
  7. Work correctly.
PS C:\work\temp> $env:GIT_CURL_VERBOSE=1
PS C:\work\temp> $env:GIT_TRANSFER_TRACE=1
PS C:\work\temp> $env:GIT_TRACE=1
PS C:\work\temp> git clone  file:////DESKTOP-H1DAY/myremote/remote.git local
18:55:02.429013 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
18:55:02.430040 git.c:460               trace: built-in: git clone file:////DESKTOP-H1DAY/myremote/remote.git local
Cloning into 'local'...
18:55:02.453013 run-command.c:654       trace: run_command: unset GIT_DIR; GIT_PROTOCOL=version=2 'git-upload-pack '\''//DESKTOP-H1DAY/myremote/remote.git'\'''
18:55:02.510432 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
18:55:02.511405 git.c:460               trace: built-in: git upload-pack //DESKTOP-H1DAY/myremote/remote.git
18:55:02.565817 run-command.c:654       trace: run_command: git pack-objects --revs --thin --stdout --progress --delta-base-offset
18:55:02.572820 run-command.c:654       trace: run_command: git index-pack --stdin -v --fix-thin '--keep=fetch-pack 7524 on DESKTOP-H1DAY' --check-self-contained-and-connected
remote: 18:55:02.579822 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core18:55:02.584819 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core

18:55:02.586818 git.c:460               trace: built-in: git index-pack --stdin -v --fix-thin '--keep=fetch-pack 7524 on DESKTOP-H1DAY' --check-self-contained-and-connected
remote: 18:55:02.590918 git.c:460               trace: built-in: git pack-objects --revs --thin --stdout --progress --delta-base-offset
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 9 (delta 1), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (9/9), done.
Resolving deltas: 100% (1/1), done.
18:55:02.660623 run-command.c:654       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs '--progress=Checking connectivity'
18:55:02.672102 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
18:55:02.674112 git.c:460               trace: built-in: git rev-list --objects --stdin --not --all --quiet --alternate-refs '--progress=Checking connectivity'
18:55:02.687923 run-command.c:654       trace: run_command: 'git-lfs filter-process'
18:55:02.748796 trace git-lfs: exec: uname
18:55:02.851578 trace git-lfs: exec: cygpath '-w' 'C:/work/temp/local/.git'
18:55:02.882956 trace git-lfs: exec: git 'version'
18:55:02.930811 trace git-lfs: exec: git '-c' 'filter.lfs.smudge=' '-c' 'filter.lfs.clean=' '-c' 'filter.lfs.process=' '-c' 'filter.lfs.required=false' 'rev-parse' '--git-dir' '--show-toplevel'
18:55:02.959305 trace git-lfs: exec: cygpath '-w' 'C:\work\temp\local\.git'
18:55:02.991064 trace git-lfs: exec: cygpath '-w' 'C:/work/temp/local'
18:55:03.021385 trace git-lfs: exec: git 'rev-parse' '--is-bare-repository'
18:55:03.051623 trace git-lfs: exec: git 'config' '--includes' '--local' 'lfs.repositoryformatversion'
18:55:03.082464 trace git-lfs: exec: git 'config' '--includes' '--replace-all' 'lfs.repositoryformatversion' '0'
18:55:03.114641 trace git-lfs: exec: cygpath '-w' 'C:\work\temp\local'
18:55:03.144613 trace git-lfs: exec: git 'config' '--includes' '-l'
18:55:03.175480 trace git-lfs: exec: git 'rev-parse' '--is-bare-repository'
18:55:03.205839 trace git-lfs: exec: git 'config' '--includes' '-l' '--blob' ':.lfsconfig'
18:55:03.236828 trace git-lfs: exec: git 'config' '--includes' '-l' '--blob' 'HEAD:.lfsconfig'
18:55:03.267612 trace git-lfs: Install hook: pre-push, force=false, path=C:\work\temp\local\.git\hooks\pre-push
18:55:03.268588 trace git-lfs: Install hook: post-checkout, force=false, path=C:\work\temp\local\.git\hooks\post-checkout
18:55:03.269131 trace git-lfs: Install hook: post-commit, force=false, path=C:\work\temp\local\.git\hooks\post-commit
18:55:03.269780 trace git-lfs: Install hook: post-merge, force=false, path=C:\work\temp\local\.git\hooks\post-merge
18:55:03.269780 trace git-lfs: Initialize filter-process
18:55:03.270972 trace git-lfs: exec: git '-c' 'filter.lfs.smudge=' '-c' 'filter.lfs.clean=' '-c' 'filter.lfs.process=' '-c' 'filter.lfs.required=false' 'rev-parse' 'HEAD' '--symbolic-full-name' 'HEAD'
18:55:03.298447 trace git-lfs: tq: running as batched queue, batch size of 100
18:55:03.300828 trace git-lfs: filepathfilter: accepting "image.png"
18:55:03.301775 trace git-lfs: tq: sending batch of size 1
18:55:03.302285 trace git-lfs: tq: starting transfer adapter "lfs-standalone-file"
18:55:03.302401 trace git-lfs: xfer: adapter "lfs-standalone-file" Begin() with 1 workers
18:55:03.302401 trace git-lfs: xfer: starting up custom transfer process "lfs-standalone-file" for worker 0
18:55:03.305548 trace git-lfs: exec: sh '-c' 'git-lfs standalone-file'
18:55:03.307742 trace git-lfs: xfer: Custom adapter worker 0 sending message: {"event":"init","operation":"download","remote":"origin","concurrent":false,"concurrenttransfers":8}
18:55:03.393223 trace git-lfs: xfer[git-lfs]: 18:55:03.357959 trace git-lfs: exec: uname
18:55:03.454676 trace git-lfs: xfer[git-lfs]: 18:55:03.454676 trace git-lfs: exec: cygpath '-w' 'C:\work\temp\local\.git'
18:55:03.485287 trace git-lfs: xfer[git-lfs]: 18:55:03.485287 trace git-lfs: exec: git 'version'
18:55:03.531849 trace git-lfs: xfer[git-lfs]: 18:55:03.531849 trace git-lfs: exec: git '-c' 'filter.lfs.smudge=' '-c' 'filter.lfs.clean=' '-c' 'filter.lfs.process=' '-c' 'filter.lfs.required=false' 'rev-parse' '--git-dir' '--show-toplevel'
18:55:03.563162 trace git-lfs: xfer[git-lfs]: 18:55:03.563162 trace git-lfs: exec: cygpath '-w' 'C:\work\temp\local\.git'
18:55:03.594608 trace git-lfs: xfer[git-lfs]: 18:55:03.594429 trace git-lfs: exec: cygpath '-w' 'C:/work/temp/local'
18:55:03.623925 trace git-lfs: xfer[git-lfs]: 18:55:03.623345 trace git-lfs: exec: git 'config' '--includes' '-l'
18:55:03.654154 trace git-lfs: xfer[git-lfs]: 18:55:03.654039 trace git-lfs: exec: git 'rev-parse' '--is-bare-repository'
18:55:03.684362 trace git-lfs: xfer[git-lfs]: 18:55:03.684252 trace git-lfs: exec: git 'config' '--includes' '-l' '--blob' ':.lfsconfig'
18:55:03.715393 trace git-lfs: xfer[git-lfs]: 18:55:03.715274 trace git-lfs: exec: git 'config' '--includes' '-l' '--blob' 'HEAD:.lfsconfig'
18:55:03.747564 trace git-lfs: xfer[git-lfs]: 18:55:03.746959 trace git-lfs: exec: cygpath '-w' '//DESKTOP-H1DAY/myremote/remote.git'
18:55:03.784313 trace git-lfs: xfer[git-lfs]: 18:55:03.783808 trace git-lfs: exec: git 'rev-parse' '--git-dir'
18:55:03.823492 trace git-lfs: xfer[git-lfs]: error creating handler: failed to call `git rev-parse --git-dir`: exit status 128
18:55:03.824611 trace git-lfs: xfer: Aborting worker process: 0
18:55:03.825378 trace git-lfs: tq: running as batched queue, batch size of 100
18:55:03.825910 trace git-lfs: filepathfilter: accepting "image.png"
Downloading image.png (32 KB)
18:55:03.826548 trace git-lfs: tq: running as batched queue, batch size of 100
18:55:03.827051 trace git-lfs: tq: sending batch of size 1
18:55:03.827274 trace git-lfs: tq: starting transfer adapter "lfs-standalone-file"
18:55:03.827490 trace git-lfs: xfer: adapter "lfs-standalone-file" Begin() with 1 workers
18:55:03.827715 trace git-lfs: xfer: starting up custom transfer process "lfs-standalone-file" for worker 0
18:55:03.829621 trace git-lfs: exec: sh '-c' 'git-lfs standalone-file'
18:55:03.831929 trace git-lfs: xfer: Custom adapter worker 0 sending message: {"event":"init","operation":"download","remote":"origin","concurrent":false,"concurrenttransfers":8}
18:55:03.913080 trace git-lfs: xfer[git-lfs]: 18:55:03.882086 trace git-lfs: exec: uname
18:55:03.965241 trace git-lfs: xfer[git-lfs]: 18:55:03.965119 trace git-lfs: exec: cygpath '-w' 'C:\work\temp\local\.git'
18:55:03.994663 trace git-lfs: xfer[git-lfs]: 18:55:03.994494 trace git-lfs: exec: git 'version'
18:55:04.041516 trace git-lfs: xfer[git-lfs]: 18:55:04.041516 trace git-lfs: exec: git '-c' 'filter.lfs.smudge=' '-c' 'filter.lfs.clean=' '-c' 'filter.lfs.process=' '-c' 'filter.lfs.required=false' 'rev-parse' '--git-dir' '--show-toplevel'
18:55:04.072938 trace git-lfs: xfer[git-lfs]: 18:55:04.072819 trace git-lfs: exec: cygpath '-w' 'C:\work\temp\local\.git'
18:55:04.104373 trace git-lfs: xfer[git-lfs]: 18:55:04.104274 trace git-lfs: exec: cygpath '-w' 'C:/work/temp/local'
18:55:04.133685 trace git-lfs: xfer[git-lfs]: 18:55:04.133557 trace git-lfs: exec: git 'config' '--includes' '-l'
18:55:04.166406 trace git-lfs: xfer[git-lfs]: 18:55:04.166406 trace git-lfs: exec: git 'rev-parse' '--is-bare-repository'
18:55:04.195428 trace git-lfs: xfer[git-lfs]: 18:55:04.195287 trace git-lfs: exec: git 'config' '--includes' '-l' '--blob' ':.lfsconfig'
18:55:04.226318 trace git-lfs: xfer[git-lfs]: 18:55:04.226318 trace git-lfs: exec: git 'config' '--includes' '-l' '--blob' 'HEAD:.lfsconfig'
18:55:04.258812 trace git-lfs: xfer[git-lfs]: 18:55:04.258812 trace git-lfs: exec: cygpath '-w' '//DESKTOP-H1DAY/myremote/remote.git'
18:55:04.294469 trace git-lfs: xfer[git-lfs]: 18:55:04.294469 trace git-lfs: exec: git 'rev-parse' '--git-dir'
18:55:04.332857 trace git-lfs: xfer[git-lfs]: error creating handler: failed to call `git rev-parse --git-dir`: exit status 128
18:55:04.333919 trace git-lfs: xfer: Aborting worker process: 0
Error downloading object: image.png (bf4b01c): Smudge error: Error downloading image.png (bf4b01c4837fc9b0366162dd9d0af2fc41ac5773aab9be49dbdcecdd5c3a8f03): EOF

Errors logged to 'C:\work\temp\local\.git\lfs\logs\20220723T185504.3344718.log'.
Use `git lfs logs last` to view the log.
error: external filter 'git-lfs filter-process' failed
fatal: image.png: smudge filter lfs failed
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

Expected behavior

Works fine without the commands add safe.directory like plain git.

or

Shows an error message like this.

fatal: unsafe repository ('//DESKTOP-H1DAY/myremote' is owned by someone else)
To add an exception for this directory, call:

        git config --global --add safe.directory ///DESKTOP-H1DAY/myremote

System environment

//DESKTOP-H1DAY/myremote/remote.git

  • //DESKTOP-H1DAY : windows11 as a fileserver.
  • myremote : a shared folder
  • remote.git : a bare repository. I don't have ownership of this directory.

'C:\work\temp\local'

  • windows11

Output of git lfs env

PS C:\work\temp\local> git lfs env
git-lfs/3.2.0 (GitHub; windows amd64; go 1.18.2)
git version 2.37.1.windows.1

Endpoint=file:////DESKTOP-H1DAY/myremote/remote.git (auth=none)
LocalWorkingDir=C:\work\temp\local
LocalGitDir=C:\work\temp\local\.git
LocalGitStorageDir=C:\work\temp\local\.git
LocalMediaDir=C:\work\temp\local\.git\lfs\objects
LocalReferenceDirs=
TempDir=C:\work\temp\local\.git\lfs\tmp
ConcurrentTransfers=8
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=C:\work\temp\local\.git\lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic,lfs-standalone-file,ssh
UploadTransfers=basic,lfs-standalone-file,ssh
GIT_EXEC_PATH=C:/Program Files/Git/mingw64/libexec/git-core
git config filter.lfs.process = "git-lfs filter-process"
git config filter.lfs.smudge = "git-lfs smudge -- %f"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions