Merge branch 'jk/maint-1.6.3-ls-files-i' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 16 Nov 2009 07:07:32 +0000 (23:07 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Nov 2009 07:07:32 +0000 (23:07 -0800)
* jk/maint-1.6.3-ls-files-i:
ls-files: unbreak "ls-files -i"

1  2 
Documentation/git-ls-files.txt
builtin-ls-files.c
index 021066e95d88624d2ec6c90a9218a4fd70ec17b7,89859153f3efec4f63c45e539cc5091ebf2d9dc9..625723e41fa072523fa850e37534677cfe8af631
@@@ -44,12 -44,14 +44,14 @@@ OPTION
  
  -o::
  --others::
 -      Show other files in the output
 +      Show other (i.e. untracked) files in the output
  
  -i::
  --ignored::
-       Show ignored files in the output.
-       Note that this also reverses any exclude list present.
+       Show only ignored files in the output. When showing files in the
+       index, print only those matched by an exclude pattern. When
+       showing "other" files, show only those matched by an exclude
+       pattern.
  
  -s::
  --stage::
diff --combined builtin-ls-files.c
index c5c0407b0b824327b0bbc6ae50ae1a030761b2b9,e458a491c7f7f2a6a05d4e76baf3911813b64e3c..c9a03e5427bbf1390aeefb9d48b4e362ca6a8e1b
@@@ -161,7 -161,12 +161,7 @@@ static void show_files(struct dir_struc
  
        /* 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)
        if (show_cached | show_stage) {
                for (i = 0; i < active_nr; i++) {
                        struct cache_entry *ce = active_cache[i];
+                       int dtype = ce_to_dtype(ce);
+                       if (dir->flags & DIR_SHOW_IGNORED &&
+                           !excluded(dir, ce->name, &dtype))
+                               continue;
                        if (show_unmerged && !ce_stage(ce))
                                continue;
                        if (ce->ce_flags & CE_UPDATE)
                        struct cache_entry *ce = active_cache[i];
                        struct stat st;
                        int err;
+                       int dtype = ce_to_dtype(ce);
+                       if (dir->flags & DIR_SHOW_IGNORED &&
+                           !excluded(dir, ce->name, &dtype))
+                               continue;
                        if (ce->ce_flags & CE_UPDATE)
                                continue;
                        err = lstat(ce->name, &st);
@@@ -441,7 -454,7 +449,7 @@@ int cmd_ls_files(int argc, const char *
                OPT_BIT(0, "directory", &dir.flags,
                        "show 'other' directories' name only",
                        DIR_SHOW_OTHER_DIRECTORIES),
 -              OPT_BIT(0, "no-empty-directory", &dir.flags,
 +              OPT_NEGBIT(0, "empty-directory", &dir.flags,
                        "don't show empty directories",
                        DIR_HIDE_EMPTY_DIRECTORIES),
                OPT_BOOLEAN('u', "unmerged", &show_unmerged,
                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 ";
                ps_matched = xcalloc(1, num);
        }
  
 -      if ((dir.flags & DIR_SHOW_IGNORED) && !exc_given) {
 -              fprintf(stderr, "%s: --ignored needs some exclude pattern\n",
 -                      argv[0]);
 -              exit(1);
 -      }
 +      if ((dir.flags & DIR_SHOW_IGNORED) && !exc_given)
 +              die("ls-files --ignored needs some exclude pattern");
  
        /* With no flags, we default to showing the cached files */
        if (!(show_stage | show_deleted | show_others | show_unmerged |