Yang Meyer
Yang Meyer

Reputation: 5709

How to get list of files in repository in libgit/objective-git?

I want to get the list of files in a Git repository using objective-git, or libgit2

What I am doing now is calling the git command-line tool and parsing the output of git ls-files (or git ls-tree --name-only -r HEAD, which gives the same results), e.g.

$ git ls-files
meta/LICENSE.md
.gitignore
README.md

I would rather use a direct API provided by libgit2. I have tried objective-git’s -[GTTree enumerateContentsWithOptions:error:block:] method, but the enumerated GTTreeEntry objects only provide a name and don’t know what subdirectory they are in.

Upvotes: 1

Views: 1000

Answers (1)

Ben Straub
Ben Straub

Reputation: 5776

enumerateContentsWithOptions takes a block with this signature:

typedef int(^GTTreeEnumerationBlock)(NSString *root, GTTreeEntry *entry);

root is the path to the directory that entry is in.

Upvotes: 2

Related Questions