Skip to content

Commit ed2b1c7

Browse files
committed
examples: general: display config only if it was found
1 parent 5aa1010 commit ed2b1c7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

examples/general.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ static void config_files(const char *repo_path, git_repository* repo)
698698
{
699699
const char *email;
700700
char config_path[256];
701-
int32_t j;
701+
int32_t autocorrect;
702702
git_config *cfg;
703703
git_config *snap_cfg;
704704

@@ -710,8 +710,8 @@ static void config_files(const char *repo_path, git_repository* repo)
710710
sprintf(config_path, "%s/config", repo_path);
711711
check_error(git_config_open_ondisk(&cfg, config_path), "opening config");
712712

713-
git_config_get_int32(&j, cfg, "help.autocorrect");
714-
printf("Autocorrect: %d\n", j);
713+
if (git_config_get_int32(&autocorrect, cfg, "help.autocorrect") == 0)
714+
printf("Autocorrect: %d\n", autocorrect);
715715

716716
check_error(git_repository_config_snapshot(&snap_cfg, repo), "config snapshot");
717717
git_config_get_string(&email, snap_cfg, "user.email");

0 commit comments

Comments
 (0)