]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/ls-files.c
pull: don't warn if pull.ff has been set
[thirdparty/git.git] / builtin / ls-files.c
index c70a9c71588a76b2ef04689fc6cd805cee4ae0b8..30a4c10334982e9ea34729a979a83027fa83c940 100644 (file)
@@ -5,7 +5,6 @@
  *
  * Copyright (C) Linus Torvalds, 2005
  */
-#define NO_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
 #include "repository.h"
 #include "config.h"
@@ -113,11 +112,11 @@ static void print_debug(const struct cache_entry *ce)
        if (debug_mode) {
                const struct stat_data *sd = &ce->ce_stat_data;
 
-               printf("  ctime: %d:%d\n", sd->sd_ctime.sec, sd->sd_ctime.nsec);
-               printf("  mtime: %d:%d\n", sd->sd_mtime.sec, sd->sd_mtime.nsec);
-               printf("  dev: %d\tino: %d\n", sd->sd_dev, sd->sd_ino);
-               printf("  uid: %d\tgid: %d\n", sd->sd_uid, sd->sd_gid);
-               printf("  size: %d\tflags: %x\n", sd->sd_size, ce->ce_flags);
+               printf("  ctime: %u:%u\n", sd->sd_ctime.sec, sd->sd_ctime.nsec);
+               printf("  mtime: %u:%u\n", sd->sd_mtime.sec, sd->sd_mtime.nsec);
+               printf("  dev: %u\tino: %u\n", sd->sd_dev, sd->sd_ino);
+               printf("  uid: %u\tgid: %u\n", sd->sd_uid, sd->sd_gid);
+               printf("  size: %u\tflags: %x\n", sd->sd_size, ce->ce_flags);
        }
 }
 
@@ -129,8 +128,9 @@ static void show_dir_entry(const struct index_state *istate,
        if (len > ent->len)
                die("git ls-files: internal error - directory entry not superset of prefix");
 
-       if (!dir_path_match(istate, ent, &pathspec, len, ps_matched))
-               return;
+       /* If ps_matches is non-NULL, figure out which pathspec(s) match. */
+       if (ps_matched)
+               dir_path_match(istate, ent, &pathspec, len, ps_matched);
 
        fputs(tag, stdout);
        write_eolinfo(istate, NULL, ent->name);
@@ -206,17 +206,19 @@ static void show_files(struct repository *repo, struct dir_struct *dir);
 static void show_submodule(struct repository *superproject,
                           struct dir_struct *dir, const char *path)
 {
-       struct repository submodule;
+       struct repository subrepo;
+       const struct submodule *sub = submodule_from_path(superproject,
+                                                         &null_oid, path);
 
-       if (repo_submodule_init(&submodule, superproject, path))
+       if (repo_submodule_init(&subrepo, superproject, sub))
                return;
 
-       if (repo_read_index(&submodule) < 0)
+       if (repo_read_index(&subrepo) < 0)
                die("index file corrupt");
 
-       show_files(&submodule, dir);
+       show_files(&subrepo, dir);
 
-       repo_clear(&submodule);
+       repo_clear(&subrepo);
 }
 
 static void show_ce(struct repository *repo, struct dir_struct *dir,
@@ -372,7 +374,7 @@ static void prune_index(struct index_state *istate,
        first = pos;
        last = istate->cache_nr;
        while (last > first) {
-               int next = (last + first) >> 1;
+               int next = first + ((last - first) >> 1);
                const struct cache_entry *ce = istate->cache[next];
                if (!strncmp(ce->name, prefix, prefixlen)) {
                        first = next+1;
@@ -441,7 +443,7 @@ void overlay_tree_on_index(struct index_state *istate,
                               PATHSPEC_PREFER_CWD, prefix, matchbuf);
        } else
                memset(&pathspec, 0, sizeof(pathspec));
-       if (read_tree(tree, 1, &pathspec, istate))
+       if (read_tree(the_repository, tree, 1, &pathspec, istate))
                die("unable to read tree entries %s", tree_name);
 
        for (i = 0; i < istate->cache_nr; i++) {
@@ -491,7 +493,7 @@ static int option_parse_exclude_from(const struct option *opt,
        BUG_ON_OPT_NEG(unset);
 
        exc_given = 1;
-       add_excludes_from_file(dir, arg);
+       add_patterns_from_file(dir, arg);
 
        return 0;
 }
@@ -515,7 +517,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
        int require_work_tree = 0, show_tag = 0, i;
        const char *max_prefix;
        struct dir_struct dir;
-       struct exclude_list *el;
+       struct pattern_list *pl;
        struct string_list exclude_list = STRING_LIST_INIT_NODUP;
        struct option builtin_ls_files_options[] = {
                /* Think twice before adding "--nul" synonym to this */
@@ -553,18 +555,18 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
                        N_("show unmerged files in the output")),
                OPT_BOOL(0, "resolve-undo", &show_resolve_undo,
                            N_("show resolve-undo information")),
-               { OPTION_CALLBACK, 'x', "exclude", &exclude_list, N_("pattern"),
+               OPT_CALLBACK_F('x', "exclude", &exclude_list, N_("pattern"),
                        N_("skip files matching pattern"),
-                       PARSE_OPT_NONEG, option_parse_exclude },
-               { OPTION_CALLBACK, 'X', "exclude-from", &dir, N_("file"),
+                       PARSE_OPT_NONEG, option_parse_exclude),
+               OPT_CALLBACK_F('X', "exclude-from", &dir, N_("file"),
                        N_("exclude patterns are read from <file>"),
-                       PARSE_OPT_NONEG, option_parse_exclude_from },
+                       PARSE_OPT_NONEG, option_parse_exclude_from),
                OPT_STRING(0, "exclude-per-directory", &dir.exclude_per_dir, N_("file"),
                        N_("read additional per-directory exclude patterns in <file>")),
-               { OPTION_CALLBACK, 0, "exclude-standard", &dir, NULL,
+               OPT_CALLBACK_F(0, "exclude-standard", &dir, NULL,
                        N_("add the standard git exclusions"),
                        PARSE_OPT_NOARG | PARSE_OPT_NONEG,
-                       option_parse_exclude_standard },
+                       option_parse_exclude_standard),
                OPT_SET_INT_F(0, "full-name", &prefix_len,
                              N_("make the output relative to the project top directory"),
                              0, PARSE_OPT_NONEG),
@@ -593,9 +595,9 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
 
        argc = parse_options(argc, argv, prefix, builtin_ls_files_options,
                        ls_files_usage, 0);
-       el = add_exclude_list(&dir, EXC_CMDL, "--exclude option");
+       pl = add_pattern_list(&dir, EXC_CMDL, "--exclude option");
        for (i = 0; i < exclude_list.nr; i++) {
-               add_exclude(exclude_list.items[i].string, "", 0, el, --exclude_args);
+               add_pattern(exclude_list.items[i].string, "", 0, pl, --exclude_args);
        }
        if (show_tag || show_valid_bit || show_fsmonitor_bit) {
                tag_cached = "H ";
@@ -679,7 +681,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
 
        if (ps_matched) {
                int bad;
-               bad = report_path_error(ps_matched, &pathspec, prefix);
+               bad = report_path_error(ps_matched, &pathspec);
                if (bad)
                        fprintf(stderr, "Did you forget to 'git add'?\n");