小编Vad*_*dim的帖子

libgit2 git_checkout_head with GIT_CHECKOUT_SAFE do nothing with working dir

I'm trying to do branch switching using libgit2. Repo already cloned and references to existing remote branches created.

If I put GIT_CHECKOUT_FORCE to checkout_strategy, it works as expected - create missing, modify existing, delete removed.

If GIT_CHECKOUT_RECREATE_MISSING - create missing only.

If GIT_CHECKOUT_SAFE - do nothing. Am I missing something?

git_reference_lookup(&branch_ref, repo, ref_name);
git_repository_set_head(repo, git_reference_name(branch_ref));
git_reference_symbolic_create(&head, repo, "HEAD", git_reference_name(branch_ref), 1, NULL);
git_checkout_head(repo, &opts);
Run Code Online (Sandbox Code Playgroud)

I got branches

  • master (current): f1.txt f2.txt
  • new: f1.txt (content differs from master's one)

After GIT_CHECKOUT_SAFE to …

c libgit2

6
推荐指数
1
解决办法
126
查看次数

标签 统计

c ×1

libgit2 ×1