Pergunta

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.

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top