]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin-ls-files.c
Teach Git to respect skip-worktree bit (reading part)
[thirdparty/git.git] / builtin-ls-files.c
index 3d59b0e140ca199997704ffcf59fbc2138345168..ad7e44784f1b067f79333f22232e52e20642ab95 100644 (file)
@@ -37,6 +37,7 @@ static const char *tag_removed = "";
 static const char *tag_other = "";
 static const char *tag_killed = "";
 static const char *tag_modified = "";
+static const char *tag_skip_worktree = "";
 
 static void show_dir_entry(const char *tag, struct dir_entry *ent)
 {
@@ -161,12 +162,7 @@ static void show_files(struct dir_struct *dir, const char *prefix)
 
        /* For cached/deleted files we don't need to even do the readdir */
        if (show_others || show_killed) {
-               const char *path = ".", *base = "";
-               int baselen = prefix_len;
-
-               if (baselen)
-                       path = base = prefix;
-               read_directory(dir, path, base, baselen, pathspec);
+               fill_directory(dir, pathspec);
                if (show_others)
                        show_other_files(dir);
                if (show_killed)
@@ -183,7 +179,8 @@ static void show_files(struct dir_struct *dir, const char *prefix)
                                continue;
                        if (ce->ce_flags & CE_UPDATE)
                                continue;
-                       show_ce_entry(ce_stage(ce) ? tag_unmerged : tag_cached, ce);
+                       show_ce_entry(ce_stage(ce) ? tag_unmerged :
+                               (ce_skip_worktree(ce) ? tag_skip_worktree : tag_cached), ce);
                }
        }
        if (show_deleted | show_modified) {
@@ -197,6 +194,8 @@ static void show_files(struct dir_struct *dir, const char *prefix)
                                continue;
                        if (ce->ce_flags & CE_UPDATE)
                                continue;
+                       if (ce_skip_worktree(ce))
+                               continue;
                        err = lstat(ce->name, &st);
                        if (show_deleted && err)
                                show_ce_entry(tag_removed, ce);
@@ -486,7 +485,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
                prefix_offset = strlen(prefix);
        git_config(git_default_config, NULL);
 
-       argc = parse_options(argc, argv, builtin_ls_files_options,
+       argc = parse_options(argc, argv, prefix, builtin_ls_files_options,
                        ls_files_usage, 0);
        if (show_tag || show_valid_bit) {
                tag_cached = "H ";
@@ -495,6 +494,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
                tag_modified = "C ";
                tag_other = "? ";
                tag_killed = "K ";
+               tag_skip_worktree = "S ";
        }
        if (show_modified || show_others || show_deleted || (dir.flags & DIR_SHOW_IGNORED) || show_killed)
                require_work_tree = 1;