{{ message }}
Repository navigation
Commit e9c1bc2
committed
docs,t: expand checkout and pull sparse cone tests
In commit 5aa7be5 of PR #5796 we added
tests of the sparse checkout support provided by our "git lfs checkout"
and "git lfs pull" commands, which makes use of the "git ls-files"
command and the --sparse option that was introduced for that command
in Git v2.35.0.
In practice, the "git lfs checkout" and "git lfs pull" commands require
Git v2.42.0 or higher to be available before they invoke "git ls-files",
and otherwise fall back to using the "git ls-tree" command. We require
at least Git v2.42.0 because that version introduced support for the
"objecttype" field name in the "git ls-files" command's --format option
and we depend on that field to be able to mimic the output format of
the "git ls-tree" command with the "git ls-files" command. We noted
these details in commit beae114 of
PR #5699, when we revised the runScanLFSFiles() function in our "lfs"
package to choose between the use of "git ls-files" and "git ls-tree".
One difference between the "git ls-files" and "git ls-tree" commands,
however, is that the former lists the files in the Git index (since we
always pass the --cached option) while the latter lists the files in
the Git tree associated with a given reference, which in the case of our
"git lfs checkout" and "git lfs pull" commands is always the current
"HEAD" symbolic reference.
As a consequence, as discussed in issue #6004, if certain files are absent
from the current working tree and Git index as the result of a partial
clone or sparse checkout, the behaviour of the "git lfs checkout" and
"git lfs pull" commands varies depending on the installed version of Git.
If Git v2.42.0 or higher is installed, the "git lfs checkout" and
"git lfs pull" commands invoke the "git ls-files" command and provide
an "attr:filter=lfs" pathspec so the Git command will filter out files
which do not match a Git LFS filter attribute. However, in order to
be reported, Git LFS pointer files must exist in the Git index; if
they only appear in the working tree or the Git tree associated with
the "HEAD" reference, they will be ignored.
(Note that in a non-bare repository, the "git ls-files" command will only
match the "attr:filter=lfs" pathspec against attributes defined in
".gitattributes" files in the index or working tree, plus any local files
such as the "$GIT_DIR/info/attributes" file. Any ".gitattributes" files
that are present only in the Git tree associated with the "HEAD" reference
will not be consulted. In a bare repository, meanwhile, the "git ls-files"
command will by default not match the pathspec against attributes defined
in ".gitattributes" files at all, regardless of whether such files exist
in the index or in the tree referenced by "HEAD".)
If a version of Git older than v2.42.0 is installed and so the
"git ls-tree" command is invoked instead of the "git ls-files" command,
then a full list of the files in the tree-ish referenced by "HEAD" is
returned. The "git lfs checkout" and "git lfs pull" commands will then
attempt to check out the Git LFS objects associated with all the Git LFS
pointer files found in this list. In the case of the "git lfs pull"
command, it will also try to fetch those objects if they are not already
present in the local storage directories.
(Note, though, that when the "git lfs checkout" and "git lfs pull" commands
retrieve a list of files using the "git ls-tree" command, they do not
check whether the pointer files they find in that list actually match
Git LFS filter attributes in any ".gitattributes" or other Git attributes
files. So a user may remove all the ".gitattributes" files from their
working tree and index, commit those changes to "HEAD", and the Git LFS
commands will still attempt to check out objects for any files found in
the "HEAD" commit's tree that can be parsed as valid pointers. When the
"git ls-files" command is used instead of the "git ls-tree" command to
retrieve a file list, this legacy behaviour does not occur, because the
"attr:filter=lfs" pathspec requires that the "git ls-files" command
only return a list of files which match at least one Git LFS filter
attribute.)
In subsequent commits we will alter how the "git lfs checkout" and
"git lfs pull" commands operate within bare repositories and how they
handle file paths, including by changing the current working directory
to the root of the current working tree, if one is present. Of necessity,
our tests and documentation will also be expanded to reflect the variable
behaviour of the "git lfs pull" command in particular, since its effects
in a bare repository depend in part on the installed version of Git.
Before we make these changes, we first revise our existing tests of
the "git lfs checkout" and "git lfs pull" commands with partial clones
and sparse checkouts so that the tests confirm the key differences in
behaviour when the installed version of Git is v2.42.0 or higher.
Our tests now demonstrate that with an older version of Git, objects
will be fetched (in the case of the "git lfs pull" command) and checked
out for all Git LFS files, including those outside the configured
sparse cone.
We also update the manual pages for these commands to include an
explanation of how their operation varies depending on the installed
version of Git, how this may affect repositories with partial clones
and sparse checkouts, and the options available to users if they find
the "git lfs checkout" and "git lfs pull" commands appear to be ignoring
certain files.
As well, we edit the initial section in our git-lfs-pull(1) manual page
where we incorrectly state that the command is always equivalent
to running "git lfs fetch" followed by "git lfs checkout", and fix the
formatting of the example commands provided in this section.
When we converted our manual page source files from the Ronn format to
AsciiDoc in commit 0c66dcf of PR #5054,
the two example commands in this section were accidentally merged onto
a single line, and the "<remote>" option for the "git lfs fetch" command
was elided.
We therefore restore the original version of these two example commands
and add leading shell prompt indicators to further clarify that the
example includes two separate commands.1 parent 5d2645d commit e9c1bc2
4 files changed
Lines changed: 107 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
19 | 38 | | |
20 | 39 | | |
21 | 40 | | |
| |||
52 | 71 | | |
53 | 72 | | |
54 | 73 | | |
55 | | - | |
| 74 | + | |
56 | 75 | | |
57 | 76 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
686 | 686 | | |
687 | 687 | | |
688 | 688 | | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
693 | 694 | | |
694 | 695 | | |
695 | 696 | | |
| |||
736 | 737 | | |
737 | 738 | | |
738 | 739 | | |
739 | | - | |
740 | | - | |
741 | 740 | | |
742 | 741 | | |
743 | 742 | | |
744 | 743 | | |
745 | 744 | | |
746 | | - | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
747 | 767 | | |
748 | 768 | | |
749 | 769 | | |
750 | 770 | | |
751 | 771 | | |
752 | 772 | | |
753 | | - | |
754 | | - | |
755 | 773 | | |
756 | 774 | | |
757 | 775 | | |
758 | 776 | | |
759 | 777 | | |
760 | | - | |
761 | 778 | | |
762 | | - | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
763 | 789 | | |
764 | 790 | | |
765 | 791 | | |
| |||

0 commit comments