Fix type-mismatch compiler warning from diff_populate_filespec()
[gitweb.git] / setup.c
diff --git a/setup.c b/setup.c
index 6cf909463d4ad3681a2f35269db9dc944f4389c2..833ced2269ae45b08f381fb2644b74f47cf50d1a 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -110,9 +110,7 @@ const char *prefix_path(const char *prefix, int len, const char *path)
                if (strncmp(sanitized, work_tree, len) ||
                    (sanitized[len] != '\0' && sanitized[len] != '/')) {
                error_out:
-                       error("'%s' is outside repository", orig);
-                       free(sanitized);
-                       return NULL;
+                       die("'%s' is outside repository", orig);
                }
                if (sanitized[len] == '/')
                        len++;
@@ -216,10 +214,7 @@ const char **get_pathspec(const char *prefix, const char **pathspec)
        prefixlen = prefix ? strlen(prefix) : 0;
        while (*src) {
                const char *p = prefix_path(prefix, prefixlen, *src);
-               if (p)
-                       *(dst++) = p;
-               else
-                       exit(128); /* error message already given */
+               *(dst++) = p;
                src++;
        }
        *dst = NULL;
@@ -475,7 +470,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
                        }
                        die("Not a git repository");
                }
-               chdir("..");
+               if (chdir(".."))
+                       die("Cannot change to %s/..: %s", cwd, strerror(errno));
        }
 
        inside_git_dir = 0;
@@ -581,6 +577,8 @@ const char *setup_git_directory(void)
                if (retval && chdir(retval))
                        die ("Could not jump back into original cwd");
                rel = get_relative_cwd(buffer, PATH_MAX, get_git_work_tree());
+               if (rel && *rel && chdir(get_git_work_tree()))
+                       die ("Could not jump to working directory");
                return rel && *rel ? strcat(rel, "/") : NULL;
        }