Code

git-sh-setup: make require_clean_work_tree part of the interface
[git.git] / diff-no-index.c
index aae8e7accc1ff955bd76c62b379b37f343f61cc4..ce9e783407437bb1e0efc6d5bc2392af26da5a41 100644 (file)
@@ -26,7 +26,7 @@ static int read_directory(const char *path, struct string_list *list)
 
        while ((e = readdir(dir)))
                if (strcmp(".", e->d_name) && strcmp("..", e->d_name))
-                       string_list_insert(e->d_name, list);
+                       string_list_insert(list, e->d_name);
 
        closedir(dir);
        return 0;
@@ -64,7 +64,8 @@ static int queue_diff(struct diff_options *o,
 
        if (S_ISDIR(mode1) || S_ISDIR(mode2)) {
                char buffer1[PATH_MAX], buffer2[PATH_MAX];
-               struct string_list p1 = {NULL, 0, 0, 1}, p2 = {NULL, 0, 0, 1};
+               struct string_list p1 = STRING_LIST_INIT_DUP;
+               struct string_list p2 = STRING_LIST_INIT_DUP;
                int len1 = 0, len2 = 0, i1, i2, ret = 0;
 
                if (name1 && read_directory(name1, &p1))
@@ -150,16 +151,14 @@ static int queue_diff(struct diff_options *o,
 
 static int path_outside_repo(const char *path)
 {
-       /*
-        * We have already done setup_git_directory_gently() so we
-        * know we are inside a git work tree already.
-        */
        const char *work_tree;
        size_t len;
 
        if (!is_absolute_path(path))
                return 0;
        work_tree = get_git_work_tree();
+       if (!work_tree)
+               return 1;
        len = strlen(work_tree);
        if (strncmp(path, work_tree, len) ||
            (path[len] != '\0' && path[len] != '/'))