doc/SubmittingPatches: show how to get a CLI commit summary
[gitweb.git] / setup.c
diff --git a/setup.c b/setup.c
index 4605fd3c3c4e06255eb5afc23fe47e1db80d075f..6b48cb91ff2bdde1d02b2696b5b38a64cc663161 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -486,6 +486,30 @@ int verify_repository_format(const struct repository_format *format,
        return 0;
 }
 
+void read_gitfile_error_die(int error_code, const char *path, const char *dir)
+{
+       switch (error_code) {
+       case READ_GITFILE_ERR_STAT_FAILED:
+       case READ_GITFILE_ERR_NOT_A_FILE:
+               /* non-fatal; follow return path */
+               break;
+       case READ_GITFILE_ERR_OPEN_FAILED:
+               die_errno("Error opening '%s'", path);
+       case READ_GITFILE_ERR_TOO_LARGE:
+               die("Too large to be a .git file: '%s'", path);
+       case READ_GITFILE_ERR_READ_FAILED:
+               die("Error reading %s", path);
+       case READ_GITFILE_ERR_INVALID_FORMAT:
+               die("Invalid gitfile format: %s", path);
+       case READ_GITFILE_ERR_NO_PATH:
+               die("No path in gitfile: %s", path);
+       case READ_GITFILE_ERR_NOT_A_REPO:
+               die("Not a git repository: %s", dir);
+       default:
+               die("BUG: unknown error code");
+       }
+}
+
 /*
  * Try to read the location of the git directory from the .git file,
  * return path to git directory if found.
@@ -559,28 +583,8 @@ const char *read_gitfile_gently(const char *path, int *return_error_code)
 cleanup_return:
        if (return_error_code)
                *return_error_code = error_code;
-       else if (error_code) {
-               switch (error_code) {
-               case READ_GITFILE_ERR_STAT_FAILED:
-               case READ_GITFILE_ERR_NOT_A_FILE:
-                       /* non-fatal; follow return path */
-                       break;
-               case READ_GITFILE_ERR_OPEN_FAILED:
-                       die_errno("Error opening '%s'", path);
-               case READ_GITFILE_ERR_TOO_LARGE:
-                       die("Too large to be a .git file: '%s'", path);
-               case READ_GITFILE_ERR_READ_FAILED:
-                       die("Error reading %s", path);
-               case READ_GITFILE_ERR_INVALID_FORMAT:
-                       die("Invalid gitfile format: %s", path);
-               case READ_GITFILE_ERR_NO_PATH:
-                       die("No path in gitfile: %s", path);
-               case READ_GITFILE_ERR_NOT_A_REPO:
-                       die("Not a git repository: %s", dir);
-               default:
-                       assert(0);
-               }
-       }
+       else if (error_code)
+               read_gitfile_error_die(error_code, path, dir);
 
        free(buf);
        return error_code ? NULL : path;
@@ -694,7 +698,7 @@ static const char *setup_discovered_git_dir(const char *gitdir,
        /* --work-tree is set without --git-dir; use discovered one */
        if (getenv(GIT_WORK_TREE_ENVIRONMENT) || git_work_tree_cfg) {
                if (offset != cwd->len && !is_absolute_path(gitdir))
-                       gitdir = real_pathdup(gitdir);
+                       gitdir = real_pathdup(gitdir, 1);
                if (chdir(cwd->buf))
                        die_errno("Could not come back to cwd");
                return setup_explicit_git_dir(gitdir, cwd, nongit_ok);
@@ -802,7 +806,7 @@ static int canonicalize_ceiling_entry(struct string_list_item *item,
                /* Keep entry but do not canonicalize it */
                return 1;
        } else {
-               char *real_path = real_pathdup(ceil);
+               char *real_path = real_pathdup(ceil, 0);
                if (!real_path) {
                        return 0;
                }