Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- setup.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/setup.c b/setup.c index 43f56fb..dfe9d08 100644 --- a/setup.c +++ b/setup.c @@ -388,16 +388,13 @@ static const char *setup_explicit_git_dir(const char *gitdirenv, if (!is_git_directory(gitdirenv)) { if (nongit_ok) { *nongit_ok = 1; - free(gitfile); - return NULL; + goto done_null; } die("Not a git repository: '%s'", gitdirenv); } - if (check_repository_format_gently(gitdirenv, nongit_ok)) { - free(gitfile); - return NULL; - } + if (check_repository_format_gently(gitdirenv, nongit_ok)) + goto done_null; /* #3, #7, #11, #15, #19, #23, #27, #31 (see t1510) */ if (work_tree_env) @@ -408,8 +405,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv, /* #18, #26 */ set_git_dir(gitdirenv); - free(gitfile); - return NULL; + goto done_null; } else if (git_work_tree_cfg) { /* #6, #14 */ if (is_absolute_path(git_work_tree_cfg)) @@ -430,8 +426,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv, else if (!git_env_bool(GIT_IMPLICIT_WORK_TREE_ENVIRONMENT, 1)) { /* #16d */ set_git_dir(gitdirenv); - free(gitfile); - return NULL; + goto done_null; } else /* #2, #10 */ set_git_work_tree("."); @@ -442,8 +437,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv, /* both get_git_work_tree() and cwd are already normalized */ if (!strcmp(cwd, worktree)) { /* cwd == worktree */ set_git_dir(gitdirenv); - free(gitfile); - return NULL; + goto done_null; } offset = dir_inside_of(cwd, worktree); @@ -459,6 +453,8 @@ static const char *setup_explicit_git_dir(const char *gitdirenv, /* cwd outside worktree */ set_git_dir(gitdirenv); + +done_null: free(gitfile); return NULL; } -- 1.8.5.1.77.g42c48fa -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html