How to have git treat tar archives transparently a

2019-07-15 03:09发布

I'd like to version a file such that for repository-related functions such as (and even sophisticated conflict solutions) the file appears to be a directory with its included files being committed regularly to git, except that on checkout one should obtain a valid tar archive again. Is this somehow achievable?

I first thought about using smudge/clean filters, but they merely allow you to modify the file contents of the stored git blob.

So, now I'm thinking about using hooks (pre-commit and post-checkout, as suggested here, though I wish there were a pre-add filter as well...) which would either simply convert between tar file and directory structure or, in order to maintain the metadata correctly, directly plumbing with git objects (or, as a compromise, use the intermediate directory but override the metadata). But, before I start with this potentially insane work, is there either

  • a better way to achieve this, or
  • an already existing solution?

This is strongly related to Can git treat zip files as directories and files inside the zip as blobs?, although I hope that due to files being merely a concatenation of files and metadata without compression, treating them might be easier.

标签: git archive tar
1条回答
贼婆χ
2楼-- · 2019-07-15 03:46

I would suggest what was mentioned in one of the comments, namely to use textconv.

Instead of manually, using cat, you could simple invoke the --textconv option for git diff.

For merging you can use the renormalize option, or configure this as the default with merge.renormalize.

I have never actually tested this, but I believe it will work.

查看更多
登录 后发表回答