为什么git快速导入文件模式是硬编码的? [英] why git fast-import file modes are hardcoded?

查看:145
本文介绍了为什么git快速导入文件模式是硬编码的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将我的CVS存储库转换为GIT,并且遇到了一个奇怪的问题:
git fast-import 具有硬编码文件模式100755和100644,
$ b

来源:

  p = get_mode(p ,&模式); 
if(!p)
die(Corrupt mode:%s,command_buf.buf);
switch(mode){
case 0644:
case 0755:
mode | = S_IFREG;
case S_IFREG | 0644:
case S_IFREG | 0755:
案例S_IFLNK:
案例S_IFDIR:
案例S_IFGITLINK:
/ * ok * /
break;
默认值:
die(Corrupt mode:%s,command_buf.buf);
}

// https://github.com/git/git/blob/master/fast-import.c 2272-2288



有人可以给我解释一下这种解决方案的原因吗?

不存储文件模式,它只使用类似unix文件模式的文件存储文件类型(符号链接,目录,可执行文件,不可执行文件)。



存储内容那不是这些硬编码位之一,例如 0777 不合法。这将是一个损坏的树对象, git fsck 会抱怨它。



排除在此 - 0664 在树中是允许的,并且被视为警告而不是错误。)


I'm trying to convert my CVS repository into GIT and I faced with strange issue: git fast-import has hardcoded file modes 100755 and 100644, otherwise it dies.

source:

p = get_mode(p, &mode);
if (!p)
    die("Corrupt mode: %s", command_buf.buf);
switch (mode) {
    case 0644:
    case 0755:
    mode |= S_IFREG;
    case S_IFREG | 0644:
    case S_IFREG | 0755:
    case S_IFLNK:
    case S_IFDIR:
    case S_IFGITLINK:
        /* ok */
        break;
    default:
        die("Corrupt mode: %s", command_buf.buf);
}

// https://github.com/git/git/blob/master/fast-import.c 2272-2288

could someone please explain me the reason of such solution?

解决方案

Git doesn't store file modes, it only stores the type of file (symlink, directory, executable, not executable) using something that looks suspiciously like unix file modes.

Storing something that is not one of these hardcoded bits, for example, 0777 would not be legal. This would be a corrupt tree object and git fsck would complain about it.

(Note that there is a historical exclusion to this - 0664 is allowed in a tree, and is considered a warning instead of an error.)

这篇关于为什么git快速导入文件模式是硬编码的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆