git-lfs/t/t-attributes.sh
brian m. carlson c38ad0f0fd
commands/track: read all attributes files to parse macros
Currently, when checking for files being tracked, we don't read
gitattributes files that are not in the working directory, so we don't
expand any macros that might be in them.  Ensure that when we read any
gitattributes file, we read all of them, and in the right order, to
expand macros in later files that have been defined in earlier ones.
2018-12-03 17:18:50 +00:00

87 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
. "$(dirname "$0")/testlib.sh"
begin_test "macros"
(
set -e
reponame="$(basename "$0" ".sh")"
clone_repo "$reponame" repo
mkdir dir
printf '[attr]lfs filter=lfs diff=lfs merge=lfs -text\n*.dat lfs\n' \
> .gitattributes
printf '[attr]lfs2 filter=lfs diff=lfs merge=lfs -text\n*.bin lfs2\n' \
> dir/.gitattributes
git add .gitattributes dir
git commit -m 'initial import'
contents="some data"
printf "$contents" > foo.dat
git add *.dat
git commit -m 'foo.dat'
assert_local_object "$(calc_oid "$contents")" 9
contents2="other data"
printf "$contents2" > dir/foo.bin
git add dir
git commit -m 'foo.bin'
refute_local_object "$(calc_oid "$contents2")"
git lfs track '*.dat' 2>&1 | tee track.log
grep '"*.dat" already supported' track.log
git lfs track 'dir/*.bin' 2>&1 | tee track.log
! grep '"dir/*.bin" already supported' track.log
)
end_test
begin_test "macros with HOME"
(
set -e
reponame="$(basename "$0" ".sh")-home"
clone_repo "$reponame" repo-home
mkdir -p "$HOME/.config/git"
printf '[attr]lfs filter=lfs diff=lfs merge=lfs -text\n*.dat lfs\n' \
> "$HOME/.config/git/attributes"
contents="some data"
printf "$contents" > foo.dat
git add *.dat
git commit -m 'foo.dat'
assert_local_object "$(calc_oid "$contents")" 9
git lfs track 2>&1 | tee track.log
grep '*.dat' track.log
)
end_test
begin_test "macros with HOME split"
(
set -e
reponame="$(basename "$0" ".sh")-home-split"
clone_repo "$reponame" repo-home-split
mkdir -p "$HOME/.config/git"
printf '[attr]lfs filter=lfs diff=lfs merge=lfs -text\n' \
> "$HOME/.config/git/attributes"
printf '*.dat lfs\n' > .gitattributes
git add .gitattributes
git commit -m 'initial import'
contents="some data"
printf "$contents" > foo.dat
git add *.dat
git commit -m 'foo.dat'
assert_local_object "$(calc_oid "$contents")" 9
git lfs track '*.dat' 2>&1 | tee track.log
grep '"*.dat" already supported' track.log
)
end_test