why git fast-import file modes are hardcoded?

馋奶兔 提交于 2019-12-24 07:27:44

问题


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?


回答1:


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.)



来源:https://stackoverflow.com/questions/15928488/why-git-fast-import-file-modes-are-hardcoded

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