ls-files: --others should not say unmerged paths are unknown.
Jon Loeliger noticed that an unmerged path appears as "Untracked" in git-status output, even though we show the same path as updated/changed. Since --others means "we have not told git about that path", we should not show unmerged paths -- obviously, git knows about them; it just does not know what we want to do about them yet. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Nov 6, 2005 at 17:26 UTC
fcbc3083e37f3c025d85d7b2c8a1c53d07a81fac
1 file changed
+24
-2
ls-files.c
+24
-2
@@ -348,6 +348,29 @@ static void show_dir_entry(const char *tag, struct nond_on_fs *ent)
348
putchar(line_terminator);
349
}
350
351
+static void show_other_files(void)
352
+{
353
+ int i;
354
+ for (i = 0; i < nr_dir; i++) {
355
+ /* We should not have a matching entry, but we
356
+ * may have an unmerged entry for this path.
357
+ */
358
+ struct nond_on_fs *ent = dir[i];
359
+ int pos = cache_name_pos(ent->name, ent->len);
360
+ struct cache_entry *ce;
361
+ if (0 <= pos)
362
+ die("bug in show-other-files");
363
+ pos = -pos - 1;
364
+ if (pos < active_nr) {
365
+ ce = active_cache[pos];
366
+ if (ce_namelen(ce) == ent->len &&
367
+ !memcmp(ce->name, ent->name, ent->len))
368
+ continue; /* Yup, this one exists unmerged */
369
+ }
370
+ show_dir_entry(tag_other, ent);
371
+ }
372
+}
373
+
374
static void show_killed_files(void)
375
{
376
int i;
@@ -438,8 +461,7 @@ static void show_files(void)
461
read_directory(path, base, baselen);
462
qsort(dir, nr_dir, sizeof(struct nond_on_fs *), cmp_name);
463
if (show_others)
441
- for (i = 0; i < nr_dir; i++)
442
- show_dir_entry(tag_other, dir[i]);
464
+ show_other_files();
465
if (show_killed)
466
show_killed_files();
467
}