tree-diff: allow diff_tree_sha1 to accept NULL sha1
[gitweb.git] / setup.c
diff --git a/setup.c b/setup.c
index f08dd649761f4d53abef66da052340a3c78d0fe5..6c3f85ff7a7935ed6f05ab5ab376a2d6c5ca2d46 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -82,7 +82,7 @@ int check_filename(const char *prefix, const char *arg)
        const char *name;
        struct stat st;
 
-       if (!prefixcmp(arg, ":/")) {
+       if (starts_with(arg, ":/")) {
                if (arg[2] == '\0') /* ":/" is root dir, always exists */
                        return 1;
                name = arg + 2;
@@ -227,7 +227,6 @@ int is_inside_work_tree(void)
 
 void setup_work_tree(void)
 {
-       struct strbuf sb = STRBUF_INIT;
        const char *work_tree, *git_dir;
        static int initialized = 0;
 
@@ -247,10 +246,8 @@ void setup_work_tree(void)
        if (getenv(GIT_WORK_TREE_ENVIRONMENT))
                setenv(GIT_WORK_TREE_ENVIRONMENT, ".", 1);
 
-       set_git_dir(relative_path(git_dir, work_tree, &sb));
+       set_git_dir(remove_leading_path(git_dir, work_tree));
        initialized = 1;
-
-       strbuf_release(&sb);
 }
 
 static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
@@ -307,7 +304,7 @@ const char *read_gitfile(const char *path)
        if (len != st.st_size)
                die("Error reading %s", path);
        buf[len] = '\0';
-       if (prefixcmp(buf, "gitdir: "))
+       if (!starts_with(buf, "gitdir: "))
                die("Invalid gitfile format: %s", path);
        while (buf[len - 1] == '\n' || buf[len - 1] == '\r')
                len--;
@@ -566,7 +563,7 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
 {
        const char *env_ceiling_dirs = getenv(CEILING_DIRECTORIES_ENVIRONMENT);
        struct string_list ceiling_dirs = STRING_LIST_INIT_DUP;
-       static char cwd[PATH_MAX+1];
+       static char cwd[PATH_MAX + 1];
        const char *gitdirenv, *ret;
        char *gitfile;
        int len, offset, offset_parent, ceil_offset = -1;
@@ -581,7 +578,7 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
        if (nongit_ok)
                *nongit_ok = 0;
 
-       if (!getcwd(cwd, sizeof(cwd)-1))
+       if (!getcwd(cwd, sizeof(cwd) - 1))
                die_errno("Unable to read current working directory");
        offset = len = strlen(cwd);