You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In addition to .gitattributes files in any directory in a repository, Git also supports several types of special attributes files, including $GIT_DIR/info/attributes, which has the highest priority of any attributes file, and the global and system-wide Git attributes files, which have the lowest priority. The gitattributes(5) manual page describes these in detail.
The git lfs track command parses all of these special attributes files, and when no command options are given, it outputs a list of all file patterns with a filter attribute defined with the value lfs.
However, this listing has a number of inconsistencies and errors when file patterns are defined in any Git attributes file other than a .gitattributes one.
To Reproduce
This example assumes Git was installed under /usr/local and that no /usr/local/etc/gitattributes file exists. Note the need to use PREFIX=/usr/local so that git lfs track finds the system-wide Git attributes file.
The file pattern from the $GIT_DIR/info/attributes file should not be listed as .git/info/<pattern> but just <pattern>.
The file pattern from the global Git attributes file (i.e., $HOME/.config/git/attributes or equivalent, such as $XDG_CONFIG_HOME/git/attributes) and the system-wide Git attributes file should have their source file names listed instead of just ().
The file patterns should be listed with their relative priority as a first sorting principle, so the $GIT_DIR/info/attributes one should be listed first. At the moment they are listed by the length of the file path, so it sorts between a longer directory name and a shorter one.
In summary, we should expect a listing something like the following, assuming that .gitattributes file paths are sorted alphanumerically as in a normal file listing:
$ PREFIX=/usr/local git lfs track
Listing tracked patterns
*.boo (.git/info/attributes)
dir/*.goo (dir/.gitattributes)
thisisalongdir/*.moo (thisisalongdir/.gitattributes)
*.foo (.gitattributes)
*.yoo (<path to user home dir>/.config/git/attributes)
*.zoo (<prefix>/etc/gitattributes)
Listing excluded patterns
System environment
The example above is performed on macOS with Git installed under /usr/local, but applies to any system with appropriate choice of $prefix for the commands which touch $prefix/etc/gitattributes.
Output of git lfs env
git-lfs/3.2.0 (GitHub; darwin amd64; go 1.19.1; git b64865c0)
git version 2.33.0
Additional context
As noted in PR #3076, no distinction is made between patterns defined in local .gitattributes files and the other special Git attributes files:
In the future, we might consider adding a denotation in the output of git-lfs-track(1) when listing a pattern that comes from outside the repository-local .gitattributes file, but we presently are unable to do this since it would involve a breaking change in the formatting of git-lfs-track(1).
See #3076 and #3070 for previous work on support for reading special Git attributes files.
The text was updated successfully, but these errors were encountered:
Describe the bug
In addition to
.gitattributes
files in any directory in a repository, Git also supports several types of special attributes files, including$GIT_DIR/info/attributes
, which has the highest priority of any attributes file, and the global and system-wide Git attributes files, which have the lowest priority. Thegitattributes(5)
manual page describes these in detail.The
git lfs track
command parses all of these special attributes files, and when no command options are given, it outputs a list of all file patterns with afilter
attribute defined with the valuelfs
.However, this listing has a number of inconsistencies and errors when file patterns are defined in any Git attributes file other than a
.gitattributes
one.To Reproduce
This example assumes Git was installed under
/usr/local
and that no/usr/local/etc/gitattributes
file exists. Note the need to usePREFIX=/usr/local
so thatgit lfs track
finds the system-wide Git attributes file.Expected behaviour
The file pattern from the
$GIT_DIR/info/attributes
file should not be listed as.git/info/<pattern>
but just<pattern>
.The file pattern from the global Git attributes file (i.e.,
$HOME/.config/git/attributes
or equivalent, such as$XDG_CONFIG_HOME/git/attributes
) and the system-wide Git attributes file should have their source file names listed instead of just()
.The file patterns should be listed with their relative priority as a first sorting principle, so the
$GIT_DIR/info/attributes
one should be listed first. At the moment they are listed by the length of the file path, so it sorts between a longer directory name and a shorter one.In summary, we should expect a listing something like the following, assuming that
.gitattributes
file paths are sorted alphanumerically as in a normal file listing:System environment
The example above is performed on macOS with Git installed under
/usr/local
, but applies to any system with appropriate choice of$prefix
for the commands which touch$prefix/etc/gitattributes
.Output of
git lfs env
Additional context
As noted in PR #3076, no distinction is made between patterns defined in local
.gitattributes
files and the other special Git attributes files:See #3076 and #3070 for previous work on support for reading special Git attributes files.
The text was updated successfully, but these errors were encountered: