Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b1914c3

Browse files
committed
Minor fixes for warnings and error propagation
1 parent 7bcced4 commit b1914c3

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

include/git2/repository.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,11 @@ GIT_EXTERN(int) git_repository_config(git_config **out, git_repository *repo);
418418
* Get a snapshot of the repository's configuration
419419
*
420420
* Convenience function to take a snapshot from the repository's
421-
* configuration.
421+
* configuration. The contents of this snapshot will not change,
422+
* even if the underlying config files are modified.
423+
*
424+
* The configuration file must be freed once it's no longer
425+
* being used by the user.
422426
*
423427
* @param out Pointer to store the loaded configuration
424428
* @param repo the repository

src/config_file.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,15 @@ static int refcounted_strmap_alloc(refcounted_strmap **out)
247247
int error;
248248

249249
map = git__calloc(1, sizeof(refcounted_strmap));
250-
if (!map) {
251-
giterr_set_oom();
252-
return -1;
253-
}
250+
GITERR_CHECK_ALLOC(map);
254251

255252
git_atomic_set(&map->refcount, 1);
256-
if ((error = git_strmap_alloc(&map->values)) < 0) {
253+
254+
if ((error = git_strmap_alloc(&map->values)) < 0)
257255
git__free(map);
258-
return error;
259-
}
256+
else
257+
*out = map;
260258

261-
*out = map;
262259
return error;
263260
}
264261

src/diff_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static int git_diff_driver_load(
219219
git_diff_driver *drv = NULL;
220220
size_t namelen = strlen(driver_name);
221221
khiter_t pos;
222-
git_config *cfg, *repo_cfg;
222+
git_config *cfg;
223223
git_buf name = GIT_BUF_INIT;
224224
const git_config_entry *ce;
225225
bool found_driver = false;

src/repository.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,10 +627,11 @@ int git_repository_config(git_config **out, git_repository *repo)
627627

628628
int git_repository_config_snapshot(git_config **out, git_repository *repo)
629629
{
630+
int error;
630631
git_config *weak;
631632

632-
if (git_repository_config__weakptr(&weak, repo) < 0)
633-
return -1;
633+
if ((error = git_repository_config__weakptr(&weak, repo)) < 0)
634+
return error;
634635

635636
return git_config_snapshot(out, weak);
636637
}

0 commit comments

Comments
 (0)