Code

add a howto document about corrupted blob recovery
[git.git] / builtin-ls-files.c
index 2e6f43bb9743d6938e9568d2467cff86901fa31f..e0b856f4328a4df945f3dd0c3f0e1dc14020238f 100644 (file)
@@ -273,7 +273,8 @@ static void prune_cache(const char *prefix)
 
        if (pos < 0)
                pos = -pos-1;
-       active_cache += pos;
+       memmove(active_cache, active_cache + pos,
+               (active_nr - pos) * sizeof(struct cache_entry *));
        active_nr -= pos;
        first = 0;
        last = active_nr;
@@ -524,11 +525,8 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
                break;
        }
 
-       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");
-       }
+       if (require_work_tree && !is_inside_work_tree())
+               setup_work_tree();
 
        pathspec = get_pathspec(prefix, argv + i);