Signed-off-by: Nguyễn Thái Ngọc Duy <pclo...@gmail.com>
---
 setup.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/setup.c b/setup.c
index 01fe89a..397eecc 100644
--- a/setup.c
+++ b/setup.c
@@ -406,16 +406,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)
@@ -426,8 +423,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))
@@ -448,8 +444,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(".");
@@ -460,8 +455,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);
@@ -477,6 +471,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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to