Skip to content

empty file with lfs.extension. #2863

Open

Description

@shive

https://github.com/git-lfs/git-lfs/blob/master/docs/spec.md

An empty file is the pointer for an empty file. That is, empty files are passed through LFS without any change.

When I use lfs.extension the pointer of empty file does not return empty file. Is this a bug?

# git init hoge && cd hoge
# git config lfs.extension.gzip.clean 'gzip -c'
# git config lfs.extension.gzip.smudge 'gzip -d'
# touch hoge.txt
# git lfs track hoge.txt
Tracking "hoge.txt"
# git add -vA
add '.gitattributes'
add 'hoge.txt'
# git commit -am hoge
[master (root-commit) 24a663b] hoge
 2 files changed, 5 insertions(+)
 create mode 100644 .gitattributes
 create mode 100644 hoge.txt
# git lfs ls-files
b2fa61e4d9 - hoge.txt
# git status -s
 M hoge.txt
# git diff
diff --git a/hoge.txt b/hoge.txt
index b5131dc..b3b3ed3 100644
--- a/hoge.txt
+++ b/hoge.txt
@@ -1,4 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-ext-0-gzip sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
-oid sha256:b2fa61e4d933b7c2c0f0cfda057ecab4eae7916bb3e0e538753acf090a2df86c
-size 20

I use git-2.14.2 and git-lfs/2.3.2.

Activity

  1. ttaylorr commented on Feb 14, 2018

    @ttaylorr
    Contributor

    Hi @shive, thanks for opening this issue. I think that what you're describing here is in fact not a bug. While it is true that the pointer corresponding to an empty file is another empty file, the gzip compressed contents of an empty file is not. Therefore, the pointer of a gzip'd file is non-empty, too.

    For example, consider this:

    ~ $ cat | gzip -c > gzip.out
    ~ $ cat gzip.out
    Z%
    

    In the first cat(1), no data is given to gzip other than to terminate it. The output file is malformed ASCII, but is non-zero in size. Therefore, the shasum of that file is captured in the final oid field of the pointer.

    I hope that helps, and if you have additional questions please don't hesitate to reopen this issue!

  2. shive commented on Feb 14, 2018

    @shive
    Author

    @ttaylorr
    Thank you for your reply.

    In other words, in order to process an empty file correctly in lfs.extension, is it necessary to judge whether it is an empty file and branch whether or not to pass it to gzip?

    Is it wrong to pass directly to gzip?

  3. shive commented on Feb 14, 2018

    @shive
    Author

    There is no problem that the result of going through gzip does not become an empty file, but it is in trouble because git status is judged different.

  4. ttaylorr commented on Feb 14, 2018

    @ttaylorr
    Contributor

    Ah, thank you for the clarification. I think that this is indeed a bug.

  5. added this to the v2.5.0 milestone on Feb 14, 2018
  6. shive commented on Feb 14, 2018

    @shive
    Author

    Thank you!
    I am looking forward to the update.

  7. mathstuf commented on Feb 21, 2018

    @mathstuf
    Contributor

    For reference, #2447 discussed the addition of that note to the spec (and it was added in #2449).

  8. modified the milestones: v2.5.0, v2.6.0 on Jul 25, 2018
  9. modified the milestones: v2.6.0, v2.7.0 on Oct 23, 2018
  10. modified the milestones: v2.7.0, v2.8.0 on Feb 26, 2019
  11. modified the milestones: v2.8.0, v2.9.0 on Jul 25, 2019
  12. removed this from the v2.9.0 milestone on Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions