How to have git treat tar archives transparently as directories?

冷暖自知 提交于 2019-12-11 02:26:13

问题


I'd like git to version a tar file such that for repository-related functions such as git-diff (and even sophisticated git-merge 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 tar files being merely a concatenation of files and metadata without compression, treating them might be easier.


回答1:


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.



来源:https://stackoverflow.com/questions/37000849/how-to-have-git-treat-tar-archives-transparently-as-directories

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!