1919 * This example demonstrates the libgit2 index APIs to roughly
2020 * simulate the output of `git ls-files`.
2121 * `git ls-files` has many options and this currently does not show them.
22- *
22+ *
2323 * `git ls-files` base command shows all paths in the index at that time.
2424 * This includes staged and committed files, but unstaged files will not display.
25- *
25+ *
2626 * This currently supports:
2727 * - The --error-unmatch paramter with the same output as the git cli
2828 * - default ls-files behavior
29- *
29+ *
3030 * This currently does not support:
3131 * - anything else
32- *
32+ *
3333 */
3434
3535typedef struct {
@@ -84,7 +84,7 @@ static int parse_options(ls_options *opts, int argc, char *argv[])
8484 return 0 ;
8585}
8686
87- static int print_paths (ls_options * opts , git_index * index )
87+ static int print_paths (ls_options * opts , git_index * index )
8888{
8989 int i ;
9090 const git_index_entry * entry ;
@@ -109,8 +109,8 @@ static int print_paths(ls_options *opts, git_index *index)
109109int main (int argc , char * argv [])
110110{
111111 ls_options opts ;
112- git_repository * repo ;
113- git_index * index ;
112+ git_repository * repo = NULL ;
113+ git_index * index = NULL ;
114114 const git_index_entry * entry ;
115115 size_t entry_count ;
116116 size_t i = 0 ;
@@ -121,10 +121,10 @@ int main(int argc, char *argv[])
121121
122122 git_libgit2_init ();
123123
124- if ((error = git_repository_open_ext (& repo , "." , 0 , NULL )) != 0 )
124+ if ((error = git_repository_open_ext (& repo , "." , 0 , NULL )) < 0 )
125125 goto cleanup ;
126126
127- if ((error = git_repository_index (& index , repo )) != 0 )
127+ if ((error = git_repository_index (& index , repo )) < 0 )
128128 goto cleanup ;
129129
130130 /* if there are files explicitly listed by the user, we need to treat this command differently */
0 commit comments