# cannot checkout file in partial clone on windows

1 messages from 2023-05-02 to 2023-05-02. Participants: Anthony Sottile.
Thread: https://gitlist.dev/t/59683

## Anthony Sottile, 2023-05-02 13:51

Subject: cannot checkout file in partial clone on windows
Message-ID: <CA+dzEBm-uVbsiq26J+Zt10RDg7sEH2FFTwAhbeXOaH_0u0Rx=g@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BdzEBm-uVbsiq26J%2BZt10RDg7sEH2FFTwAhbeXOaH_0u0Rx%3Dg%40mail.gmail.com

```
this appears to be a windows-specific issue

short reproduction:

ˋˋˋbash
set -euxo pipefail

rm -rf t
git init t
cd t
git remote add origin https://github.com/pre-commit/pre-commit-hooks
git config extensions.partialClone true
git fetch origin HEAD --quiet --filter=blob:none --tags

git checkout v4.4.0 -- .pre-commit-hooks.yaml

ls -al
ˋˋˋ

on linux it produces this output:

ˋˋˋconsole
$ bash t.sh
+ rm -rf t
+ git init t
Initialized empty Git repository in /tmp/t/.git/
+ cd t
+ git remote add origin https://github.com/pre-commit/pre-commit-hooks
+ git config extensions.partialClone true
+ git fetch origin HEAD --quiet --filter=blob:none --tags
+ git checkout v4.4.0 -- .pre-commit-hooks.yaml
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (1/1), 1.73 KiB | 1.73 MiB/s, done.
+ ls -al
total 36
drwxr-xr-x  3 asottile asottile  4096 May  2 09:48 .
drwxrwxrwt 27 root     root     20480 May  2 09:47 ..
drwxr-xr-x  7 asottile asottile  4096 May  2 09:48 .git
-rw-r--r--  1 asottile asottile  6950 May  2 09:48 .pre-commit-hooks.yaml

ˋˋˋ

on windows it does the following:

ˋˋˋconsole
>bash t.sh
+ rm -rf t
+ git init t
Initialized empty Git repository in
C:/Users/Anthony/workspace/pre-commit/t/.git/
+ cd t
+ git remote add origin https://github.com/pre-commit/pre-commit-hooks
+ git config extensions.partialClone true
+ git fetch origin HEAD --quiet --filter=blob:none --tags
+ git checkout v4.4.0 -- .pre-commit-hooks.yaml
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (1/1), 1.73 KiB | 1.73 MiB/s, done.
error: unable to read sha1 file of .pre-commit-hooks.yaml
(f8523d4a677b2904df1ebf50c826323b2555edeb)
ˋˋˋ

I can work around it by running `git show
v4.4.0:.pre-commit-hooks.yaml > /dev/null` before the checkout oddly
enough:

ˋˋˋconsole
>bash t.sh
+ rm -rf t
+ git init t
Initialized empty Git repository in
C:/Users/Anthony/workspace/pre-commit/t/.git/
+ cd t
+ git remote add origin https://github.com/pre-commit/pre-commit-hooks
+ git config extensions.partialClone true
+ git fetch origin HEAD --quiet --filter=blob:none --tags
+ git show v4.4.0:.pre-commit-hooks.yaml
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (1/1), 1.73 KiB | 1.73 MiB/s, done.
+ git checkout v4.4.0 -- .pre-commit-hooks.yaml
+ ls -al
total 20
drwxr-xr-x 1 Anthony 197609    0 May  2 09:50 .
drwxr-xr-x 1 Anthony 197609    0 May  2 09:50 ..
drwxr-xr-x 1 Anthony 197609    0 May  2 09:50 .git
-rw-r--r-- 1 Anthony 197609 6950 May  2 09:50 .pre-commit-hooks.yaml
ˋˋˋ

anthony

```
