Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9121729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:55:41+00:00 2026-06-17T05:55:41+00:00

I use git_repository_index to get the index first ,and then I use git_index_entrycount to

  • 0

I use git_repository_index to get the index first ,and then I use git_index_entrycount to see how many index items in it , but the result is 0? why? Below is my code, what’s wrong with it? Thx

(void)viewDidLoad
{
[super viewDidLoad];
git_repository *repo;
progress_data pd = {{0}};
NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docPath = [array objectAtIndex:0];

git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT;
git_checkout_opts checkout_opts = GIT_CHECKOUT_OPTS_INIT;
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
checkout_opts.progress_cb = checkout_progress;
checkout_opts.progress_payload = &pd;
clone_opts.checkout_opts = checkout_opts;
clone_opts.fetch_progress_cb = &fetch_progress;
clone_opts.fetch_progress_payload = &pd;
clone_opts.cred_acquire_cb = cred_acquire;
NSString *pp = [docPath stringByAppendingPathComponent:@"/abc" ];
const char * a =[pp UTF8String];   

int res =  git_clone(&repo, "http://path/.git", a, &clone_opts);
NSLog(@"Get it. res:%d\n path:%s", res, a);
//get index
int ret;
git_index* index;
ret = git_repository_index(&index, repo);
NSLog(@"git_repository_index ret:%d", ret);
int count = git_index_entrycount(index);
if(count != 0)
{
    NSLog(@"index number:%d", count);
}
else
{
    NSLog(@"count == 0");
}

const git_error *err = giterr_last();
if(err == NULL)
{
    NSLog(@"NULL");
}
else
{
    NSLog(@"err:%s", err->message);
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:55:42+00:00Added an answer on June 17, 2026 at 5:55 am

    On order to trigger the checkout as part of the git_clone() process, have you considered using
    GIT_CHECKOUT_SAFE_CREATE as the checkout_strategy?

    Both this commit and the the git_checkout() documentation hint about this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there are many tutorials to use Dropbox as a Git repository, but
I use git_index_add_from_workdir to add, but why git_index_entrycount return 0? and another question, I
I use IntelliJ Idea with Git. When I pull from repository, I get following
I'm trying to implement elasticsearch in my play 2 app: https://github.com/cleverage/play2-elasticsearch but I get
Take a look to that code <?php namespace Sestante\SestanteBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use
Perhaps I am going about this wrong, but I am following git tutorials as
I'm trying to use Git for the first time. I did everything that github
As I read through as many sources on how to use git, I haven't
I'm trying to use git on windows to clone a remote repository. I can
Does Git only use the remote name origin for a repository which was created

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.