# [PATCH v1] git-p4: add diff/merge properties to .gitattributes for GitLFS files

3 messages from 2016-12-18 to 2016-12-20. Participants: larsxschneider@gmail.com, Junio C Hamano, Luke Diamand.
Thread: https://gitlist.dev/t/44731

## larsxschneider@gmail.com, 2016-12-18 19:01

Subject: [PATCH v1] git-p4: add diff/merge properties to .gitattributes for GitLFS files
Message-ID: <20161218190140.3732-1-larsxschneider@gmail.com>
URL: https://gitlist.dev/e/20161218190140.3732-1-larsxschneider%40gmail.com

```
From: Lars Schneider <larsxschneider@gmail.com>

The `git lfs track` command generates a .gitattributes file with diff
and merge properties [1]. Set the same .gitattributes format for files
tracked with GitLFS in git-p4.

[1] https://github.com/git-lfs/git-lfs/blob/v1.5.3/commands/command_track.go#L121

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
---

Notes:
    Base Commit: d1271bddd4 (v2.11.0)
    Diff on Web: https://github.com/git/git/compare/d1271bddd4...larsxschneider:e045b3d5c8
    Checkout:    git fetch https://github.com/larsxschneider/git git-p4/fix-lfs-attributes-v1 && git checkout e045b3d5c8

 git-p4.py                 |  4 ++--
 t/t9824-git-p4-git-lfs.sh | 24 ++++++++++++------------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/git-p4.py b/git-p4.py
index fd5ca52462..87b6932c81 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1098,10 +1098,10 @@ class GitLFS(LargeFileSystem):
                 '# Git LFS (see https://git-lfs.github.com/)\n',
                 '#\n',
             ] +
-            ['*.' + f.replace(' ', '[[:space:]]') + ' filter=lfs -text\n'
+            ['*.' + f.replace(' ', '[[:space:]]') + ' filter=lfs diff=lfs merge=lfs -text\n'
                 for f in sorted(gitConfigList('git-p4.largeFileExtensions'))
             ] +
-            ['/' + f.replace(' ', '[[:space:]]') + ' filter=lfs -text\n'
+            ['/' + f.replace(' ', '[[:space:]]') + ' filter=lfs diff=lfs merge=lfs -text\n'
                 for f in sorted(self.largeFiles) if not self.hasLargeFileExtension(f)
             ]
         )
diff --git a/t/t9824-git-p4-git-lfs.sh b/t/t9824-git-p4-git-lfs.sh
index 110a7e7924..1379db6357 100755
--- a/t/t9824-git-p4-git-lfs.sh
+++ b/t/t9824-git-p4-git-lfs.sh
@@ -81,9 +81,9 @@ test_expect_success 'Store files in LFS based on size (>24 bytes)' '
 		#
 		# Git LFS (see https://git-lfs.github.com/)
 		#
-		/file2.dat filter=lfs -text
-		/file4.bin filter=lfs -text
-		/path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs -text
+		/file2.dat filter=lfs diff=lfs merge=lfs -text
+		/file4.bin filter=lfs diff=lfs merge=lfs -text
+		/path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs diff=lfs merge=lfs -text
 		EOF
 		test_path_is_file .gitattributes &&
 		test_cmp expect .gitattributes
@@ -109,7 +109,7 @@ test_expect_success 'Store files in LFS based on size (>25 bytes)' '
 		#
 		# Git LFS (see https://git-lfs.github.com/)
 		#
-		/file4.bin filter=lfs -text
+		/file4.bin filter=lfs diff=lfs merge=lfs -text
 		EOF
 		test_path_is_file .gitattributes &&
 		test_cmp expect .gitattributes
@@ -135,7 +135,7 @@ test_expect_success 'Store files in LFS based on extension (dat)' '
 		#
 		# Git LFS (see https://git-lfs.github.com/)
 		#
-		*.dat filter=lfs -text
+		*.dat filter=lfs diff=lfs merge=lfs -text
 		EOF
 		test_path_is_file .gitattributes &&
 		test_cmp expect .gitattributes
@@ -163,8 +163,8 @@ test_expect_success 'Store files in LFS based on size (>25 bytes) and extension
 		#
 		# Git LFS (see https://git-lfs.github.com/)
 		#
-		*.dat filter=lfs -text
-		/file4.bin filter=lfs -text
+		*.dat filter=lfs diff=lfs merge=lfs -text
+		/file4.bin filter=lfs diff=lfs merge=lfs -text
 		EOF
 		test_path_is_file .gitattributes &&
 		test_cmp expect .gitattributes
@@ -199,8 +199,8 @@ test_expect_success 'Remove file from repo and store files in LFS based on size
 		#
 		# Git LFS (see https://git-lfs.github.com/)
 		#
-		/file2.dat filter=lfs -text
-		/path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs -text
+		/file2.dat filter=lfs diff=lfs merge=lfs -text
+		/path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs diff=lfs merge=lfs -text
 		EOF
 		test_path_is_file .gitattributes &&
 		test_cmp expect .gitattributes
@@ -237,8 +237,8 @@ test_expect_success 'Add .gitattributes and store files in LFS based on size (>2
 		#
 		# Git LFS (see https://git-lfs.github.com/)
 		#
-		/file2.dat filter=lfs -text
-		/path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs -text
+		/file2.dat filter=lfs diff=lfs merge=lfs -text
+		/path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs diff=lfs merge=lfs -text
 		EOF
 		test_path_is_file .gitattributes &&
 		test_cmp expect .gitattributes
@@ -278,7 +278,7 @@ test_expect_success 'Add big files to repo and store files in LFS based on compr
 		#
 		# Git LFS (see https://git-lfs.github.com/)
 		#
-		/file6.bin filter=lfs -text
+		/file6.bin filter=lfs diff=lfs merge=lfs -text
 		EOF
 		test_path_is_file .gitattributes &&
 		test_cmp expect .gitattributes
-- 
2.11.0


```

## Junio C Hamano, 2016-12-19 21:29

Subject: Re: [PATCH v1] git-p4: add diff/merge properties to .gitattributes for GitLFS files
Message-ID: <xmqqy3zbmwu5.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqy3zbmwu5.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <20161218190140.3732-1-larsxschneider@gmail.com>

```
larsxschneider@gmail.com writes:

> From: Lars Schneider <larsxschneider@gmail.com>
>
> The `git lfs track` command generates a .gitattributes file with diff
> and merge properties [1]. Set the same .gitattributes format for files
> tracked with GitLFS in git-p4.
>
> [1] https://github.com/git-lfs/git-lfs/blob/v1.5.3/commands/command_track.go#L121
>
> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
> ---

Thanks.  Luke, does this look ok?

>
> Notes:
>     Base Commit: d1271bddd4 (v2.11.0)
>     Diff on Web: https://github.com/git/git/compare/d1271bddd4...larsxschneider:e045b3d5c8
>     Checkout:    git fetch https://github.com/larsxschneider/git git-p4/fix-lfs-attributes-v1 && git checkout e045b3d5c8
>
>  git-p4.py                 |  4 ++--
>  t/t9824-git-p4-git-lfs.sh | 24 ++++++++++++------------
>  2 files changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/git-p4.py b/git-p4.py
> index fd5ca52462..87b6932c81 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -1098,10 +1098,10 @@ class GitLFS(LargeFileSystem):
>                  '# Git LFS (see https://git-lfs.github.com/)\n',
>                  '#\n',
>              ] +
> -            ['*.' + f.replace(' ', '[[:space:]]') + ' filter=lfs -text\n'
> +            ['*.' + f.replace(' ', '[[:space:]]') + ' filter=lfs diff=lfs merge=lfs -text\n'
>                  for f in sorted(gitConfigList('git-p4.largeFileExtensions'))
>              ] +
> -            ['/' + f.replace(' ', '[[:space:]]') + ' filter=lfs -text\n'
> +            ['/' + f.replace(' ', '[[:space:]]') + ' filter=lfs diff=lfs merge=lfs -text\n'
>                  for f in sorted(self.largeFiles) if not self.hasLargeFileExtension(f)
>              ]
>          )
> diff --git a/t/t9824-git-p4-git-lfs.sh b/t/t9824-git-p4-git-lfs.sh
> index 110a7e7924..1379db6357 100755
> --- a/t/t9824-git-p4-git-lfs.sh
> +++ b/t/t9824-git-p4-git-lfs.sh
> @@ -81,9 +81,9 @@ test_expect_success 'Store files in LFS based on size (>24 bytes)' '
>  		#
>  		# Git LFS (see https://git-lfs.github.com/)
>  		#
> -		/file2.dat filter=lfs -text
> -		/file4.bin filter=lfs -text
> -		/path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs -text
> +		/file2.dat filter=lfs diff=lfs merge=lfs -text
> +		/file4.bin filter=lfs diff=lfs merge=lfs -text
> +		/path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs diff=lfs merge=lfs -text
>  		EOF
>  		test_path_is_file .gitattributes &&
>  		test_cmp expect .gitattributes
> @@ -109,7 +109,7 @@ test_expect_success 'Store files in LFS based on size (>25 bytes)' '
>  		#
>  		# Git LFS (see https://git-lfs.github.com/)
>  		#
> -		/file4.bin filter=lfs -text
> +		/file4.bin filter=lfs diff=lfs merge=lfs -text
>  		EOF
>  		test_path_is_file .gitattributes &&
>  		test_cmp expect .gitattributes
> @@ -135,7 +135,7 @@ test_expect_success 'Store files in LFS based on extension (dat)' '
>  		#
>  		# Git LFS (see https://git-lfs.github.com/)
>  		#
> -		*.dat filter=lfs -text
> +		*.dat filter=lfs diff=lfs merge=lfs -text
>  		EOF
>  		test_path_is_file .gitattributes &&
>  		test_cmp expect .gitattributes
> @@ -163,8 +163,8 @@ test_expect_success 'Store files in LFS based on size (>25 bytes) and extension
>  		#
>  		# Git LFS (see https://git-lfs.github.com/)
>  		#
> -		*.dat filter=lfs -text
> -		/file4.bin filter=lfs -text
> +		*.dat filter=lfs diff=lfs merge=lfs -text
> +		/file4.bin filter=lfs diff=lfs merge=lfs -text
>  		EOF
>  		test_path_is_file .gitattributes &&
>  		test_cmp expect .gitattributes
> @@ -199,8 +199,8 @@ test_expect_success 'Remove file from repo and store files in LFS based on size
>  		#
>  		# Git LFS (see https://git-lfs.github.com/)
>  		#
> -		/file2.dat filter=lfs -text
> -		/path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs -text
> +		/file2.dat filter=lfs diff=lfs merge=lfs -text
> +		/path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs diff=lfs merge=lfs -text
>  		EOF
>  		test_path_is_file .gitattributes &&
>  		test_cmp expect .gitattributes
> @@ -237,8 +237,8 @@ test_expect_success 'Add .gitattributes and store files in LFS based on size (>2
>  		#
>  		# Git LFS (see https://git-lfs.github.com/)
>  		#
> -		/file2.dat filter=lfs -text
> -		/path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs -text
> +		/file2.dat filter=lfs diff=lfs merge=lfs -text
> +		/path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs diff=lfs merge=lfs -text
>  		EOF
>  		test_path_is_file .gitattributes &&
>  		test_cmp expect .gitattributes
> @@ -278,7 +278,7 @@ test_expect_success 'Add big files to repo and store files in LFS based on compr
>  		#
>  		# Git LFS (see https://git-lfs.github.com/)
>  		#
> -		/file6.bin filter=lfs -text
> +		/file6.bin filter=lfs diff=lfs merge=lfs -text
>  		EOF
>  		test_path_is_file .gitattributes &&
>  		test_cmp expect .gitattributes

```

## Luke Diamand, 2016-12-20 11:09

Subject: Re: [PATCH v1] git-p4: add diff/merge properties to .gitattributes for GitLFS files
Message-ID: <CAE5ih79CyeEM0DZXBmrY6tSVD6Y-iMY0Wc6d8Wm1e=rT2zY-yQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAE5ih79CyeEM0DZXBmrY6tSVD6Y-iMY0Wc6d8Wm1e%3DrT2zY-yQ%40mail.gmail.com
In-Reply-To: <xmqqy3zbmwu5.fsf@gitster.mtv.corp.google.com>

```
On 19 December 2016 at 21:29, Junio C Hamano <gitster@pobox.com> wrote:
> larsxschneider@gmail.com writes:
>
>> From: Lars Schneider <larsxschneider@gmail.com>
>>
>> The `git lfs track` command generates a .gitattributes file with diff
>> and merge properties [1]. Set the same .gitattributes format for files
>> tracked with GitLFS in git-p4.
>>
>> [1] https://github.com/git-lfs/git-lfs/blob/v1.5.3/commands/command_track.go#L121
>>
>> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
>> ---
>
> Thanks.  Luke, does this look ok?

Yes, looks good to me.

Luke


>
>>
>> Notes:
>>     Base Commit: d1271bddd4 (v2.11.0)
>>     Diff on Web: https://github.com/git/git/compare/d1271bddd4...larsxschneider:e045b3d5c8
>>     Checkout:    git fetch https://github.com/larsxschneider/git git-p4/fix-lfs-attributes-v1 && git checkout e045b3d5c8
>>
>>  git-p4.py                 |  4 ++--
>>  t/t9824-git-p4-git-lfs.sh | 24 ++++++++++++------------
>>  2 files changed, 14 insertions(+), 14 deletions(-)
>>
>> diff --git a/git-p4.py b/git-p4.py
>> index fd5ca52462..87b6932c81 100755
>> --- a/git-p4.py
>> +++ b/git-p4.py
>> @@ -1098,10 +1098,10 @@ class GitLFS(LargeFileSystem):
>>                  '# Git LFS (see https://git-lfs.github.com/)\n',
>>                  '#\n',
>>              ] +
>> -            ['*.' + f.replace(' ', '[[:space:]]') + ' filter=lfs -text\n'
>> +            ['*.' + f.replace(' ', '[[:space:]]') + ' filter=lfs diff=lfs merge=lfs -text\n'
>>                  for f in sorted(gitConfigList('git-p4.largeFileExtensions'))
>>              ] +
>> -            ['/' + f.replace(' ', '[[:space:]]') + ' filter=lfs -text\n'
>> +            ['/' + f.replace(' ', '[[:space:]]') + ' filter=lfs diff=lfs merge=lfs -text\n'
>>                  for f in sorted(self.largeFiles) if not self.hasLargeFileExtension(f)
>>              ]
>>          )
>> diff --git a/t/t9824-git-p4-git-lfs.sh b/t/t9824-git-p4-git-lfs.sh
>> index 110a7e7924..1379db6357 100755
>> --- a/t/t9824-git-p4-git-lfs.sh
>> +++ b/t/t9824-git-p4-git-lfs.sh
>> @@ -81,9 +81,9 @@ test_expect_success 'Store files in LFS based on size (>24 bytes)' '
>>               #
>>               # Git LFS (see https://git-lfs.github.com/)
>>               #
>> -             /file2.dat filter=lfs -text
>> -             /file4.bin filter=lfs -text
>> -             /path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs -text
>> +             /file2.dat filter=lfs diff=lfs merge=lfs -text
>> +             /file4.bin filter=lfs diff=lfs merge=lfs -text
>> +             /path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs diff=lfs merge=lfs -text
>>               EOF
>>               test_path_is_file .gitattributes &&
>>               test_cmp expect .gitattributes
>> @@ -109,7 +109,7 @@ test_expect_success 'Store files in LFS based on size (>25 bytes)' '
>>               #
>>               # Git LFS (see https://git-lfs.github.com/)
>>               #
>> -             /file4.bin filter=lfs -text
>> +             /file4.bin filter=lfs diff=lfs merge=lfs -text
>>               EOF
>>               test_path_is_file .gitattributes &&
>>               test_cmp expect .gitattributes
>> @@ -135,7 +135,7 @@ test_expect_success 'Store files in LFS based on extension (dat)' '
>>               #
>>               # Git LFS (see https://git-lfs.github.com/)
>>               #
>> -             *.dat filter=lfs -text
>> +             *.dat filter=lfs diff=lfs merge=lfs -text
>>               EOF
>>               test_path_is_file .gitattributes &&
>>               test_cmp expect .gitattributes
>> @@ -163,8 +163,8 @@ test_expect_success 'Store files in LFS based on size (>25 bytes) and extension
>>               #
>>               # Git LFS (see https://git-lfs.github.com/)
>>               #
>> -             *.dat filter=lfs -text
>> -             /file4.bin filter=lfs -text
>> +             *.dat filter=lfs diff=lfs merge=lfs -text
>> +             /file4.bin filter=lfs diff=lfs merge=lfs -text
>>               EOF
>>               test_path_is_file .gitattributes &&
>>               test_cmp expect .gitattributes
>> @@ -199,8 +199,8 @@ test_expect_success 'Remove file from repo and store files in LFS based on size
>>               #
>>               # Git LFS (see https://git-lfs.github.com/)
>>               #
>> -             /file2.dat filter=lfs -text
>> -             /path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs -text
>> +             /file2.dat filter=lfs diff=lfs merge=lfs -text
>> +             /path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs diff=lfs merge=lfs -text
>>               EOF
>>               test_path_is_file .gitattributes &&
>>               test_cmp expect .gitattributes
>> @@ -237,8 +237,8 @@ test_expect_success 'Add .gitattributes and store files in LFS based on size (>2
>>               #
>>               # Git LFS (see https://git-lfs.github.com/)
>>               #
>> -             /file2.dat filter=lfs -text
>> -             /path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs -text
>> +             /file2.dat filter=lfs diff=lfs merge=lfs -text
>> +             /path[[:space:]]with[[:space:]]spaces/file3.bin filter=lfs diff=lfs merge=lfs -text
>>               EOF
>>               test_path_is_file .gitattributes &&
>>               test_cmp expect .gitattributes
>> @@ -278,7 +278,7 @@ test_expect_success 'Add big files to repo and store files in LFS based on compr
>>               #
>>               # Git LFS (see https://git-lfs.github.com/)
>>               #
>> -             /file6.bin filter=lfs -text
>> +             /file6.bin filter=lfs diff=lfs merge=lfs -text
>>               EOF
>>               test_path_is_file .gitattributes &&
>>               test_cmp expect .gitattributes

```
