签出新分支时无法更改filemode

时间:2015-02-06 20:56:37

标签: c libgit2

我正在编写一个简单的代码来实现git checkout branch-name

git_repository *repo = NULL;
git_signature *sig;
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
opts.checkout_strategy = GIT_CHECKOUT_FORCE;

git_signature_now(&sig, "name", "email");

git_repository_open(&repo, "test");
git_repository_set_head(repo, "refs/heads/v1", sig, NULL);
git_checkout_tree(repo, NULL, &opts);

git_signature_free(sig);
git_repository_free(repo);

除了文件模式更改外,一切正常。

$ git status
On branch v1
Your branch is up-to-date with 'sugareps/ibm_r22'.
Changes to be committed:
    modified:  include/javascript/select2/select2-spinner.gif
    modified:  include/javascript/select2/select2.png

Changes not staged for commit:
    modified:  /modules/DropDownBrowser.php


$git diff # or git diff --cached
old mode 100644
new mode 100755

我该怎么做?有人可以给我一些建议。

1 个答案:

答案 0 :(得分:0)

link表明libgit2在创建文件或目录时会考虑umask。这意味着如果您希望libgit2能够创建具有任何权限的文件,则需要先将umask设置为0。