Avoid using va_copy in fast-import: it seems to be unportable.
[gitweb.git] / builtin-ls-files.c
index f7c066b24b7a6a728fd2f0bf4a92a31fb4a695dd..d36181a75541df10c5dc1595ccca5a6fc429591f 100644 (file)
@@ -117,7 +117,7 @@ static void show_other_files(struct dir_struct *dir)
                if (0 <= pos)
                        continue;       /* exact match */
                pos = -pos - 1;
-               if (pos < active_nr) { 
+               if (pos < active_nr) {
                        ce = active_cache[pos];
                        if (ce_namelen(ce) == len &&
                            !memcmp(ce->name, ent->name, len))
@@ -469,9 +469,11 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
                break;
        }
 
-       if (require_work_tree &&
-                       (is_bare_repository() || is_inside_git_dir()))
-               die("This operation must be run in a work tree");
+       if (require_work_tree && !is_inside_work_tree()) {
+               const char *work_tree = get_git_work_tree();
+               if (!work_tree || chdir(work_tree))
+                       die("This operation must be run in a work tree");
+       }
 
        pathspec = get_pathspec(prefix, argv + i);