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() { for scanner.Scan() {
line := scanner.Text() line := scanner.Text()
fields := strings.Fields(line) fields := strings.Fields(line)
if len(fields) < 1 {
continue
}
pattern := fields[0] pattern := fields[0]
if newline, ok := changedAttribLines[pattern]; ok { if newline, ok := changedAttribLines[pattern]; ok {
// Replace this line (newline already embedded) // Replace this line (newline already embedded)

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