如何让git将tar档案作为目录透明处理? [英] How to have git treat tar archives transparently as directories?
问题描述
我希望 git to a version a tar 文件,以便对于与存储库相关的功能,例如 git-diff 的问题(甚至复杂 git-merge 冲突解决方案)的问题文件似乎是一个目录,其中包含的文件定期提交给git,除了在签出时,应该再次获得有效的 tar
存档。这是不是可以实现?
我首先想到了使用涂抹/清洁过滤器,但它们只允许您修改存储的git blob的文件内容。
所以,现在我正考虑使用 hooks ( pre-commit
和结账后
,建议此处,但我希望还有一个 pre-add
过滤器......),它将简单地在 tar
文件和目录结构之间进行转换或者,为了正确保持元数据,直接使用 git objects (或者,作为折衷方案,使用中间目录但覆盖元数据一个)。但是,在我开始这个潜在的疯狂工作之前,有没有一种更好的方法来达到这个目的,或者 $ b
- $ b 已存在的解决方案?
这与<一个href =https://stackoverflow.com/q/8001663/321973> git可以将zip文件作为目录和zip文件中的文件视为blob?,尽管我希望由于 tar 文件仅仅是文件和元数据的串联而没有压缩,更容易。
解决方案我会建议在其中一个评论中提到什么,即使用
textconv
。
使用
cat
可以简单地调用- textconv
选项用于git diff
。
可以使用
renormalize
选项o你可以使用merge.renormalize
。
将其设置为默认值。我从来没有真正测试过这个,但我相信它将工作。
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
andpost-checkout
, as suggested here, though I wish there were apre-add
filter as well...) which would either simply convert betweentar
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.
解决方案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 forgit diff
.For merging you can use the
renormalize
option, or configure this as the default withmerge.renormalize
.I have never actually tested this, but I believe it will work.
这篇关于如何让git将tar档案作为目录透明处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!