Merge pull request #1921 from git-lfs/track-with-empty-lines

commands: teach track how to handle empty lines in .gitattributes
This commit is contained in:
risk danger olson 2017-02-07 13:45:59 -07:00 committed by GitHub
commit 0685231f1c
2 changed files with 23 additions and 7 deletions

@ -119,6 +119,10 @@ ArgsLoop:
for scanner.Scan() {
line := scanner.Text()
fields := strings.Fields(line)
if len(fields) < 1 {
continue
}
pattern := fields[0]
if newline, ok := changedAttribLines[pattern]; ok {
// Replace this line (newline already embedded)

@ -12,6 +12,13 @@ begin_test "track"
cd track
git init
echo "###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
#*.cs diff=csharp" > .gitattributes
# track *.jpg once
git lfs track "*.jpg" | grep "Tracking \*.jpg"
assert_attributes_count "jpg" "filter=lfs" 1
@ -26,12 +33,18 @@ begin_test "track"
echo "*.gif filter=lfs -text" > a/.gitattributes
echo "*.png filter=lfs -text" > a/b/.gitattributes
out=$(git lfs track)
echo "$out" | grep "Listing tracked patterns"
echo "$out" | grep "*.mov ($(native_path_escaped ".git/info/attributes"))"
echo "$out" | grep "*.jpg (.gitattributes)"
echo "$out" | grep "*.gif ($(native_path_escaped "a/.gitattributes"))"
echo "$out" | grep "*.png ($(native_path_escaped "a/b/.gitattributes"))"
git lfs track | tee track.log
grep "Listing tracked patterns" track.log
grep "*.mov ($(native_path_escaped ".git/info/attributes"))" track.log
grep "*.jpg (.gitattributes)" track.log
grep "*.gif ($(native_path_escaped "a/.gitattributes"))" track.log
grep "*.png ($(native_path_escaped "a/b/.gitattributes"))" track.log
grep "Set default behavior" .gitattributes
grep "############" .gitattributes
grep "* text=auto" .gitattributes
grep "diff=csharp" .gitattributes
grep "*.jpg" .gitattributes
)
end_test
@ -374,4 +387,3 @@ begin_test "track lockable read-only/read-write"
)
end_test