git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Lars Hoss <lars@woeye.net>
Cc: Johannes Sixt <j.sixt@viscovery.net>,
	Pedro Melo <melo@simplicidade.org>,
	Pieter de Bie <pdebie@ai.rug.nl>,
	Git Mailinglist <git@vger.kernel.org>
Subject: Re: [BUG] git status doesn't handle submodules properly on OSX
Date: Thu, 16 Oct 2008 10:18:13 -0400	[thread overview]
Message-ID: <20081016141812.GA30026@sigill.intra.peff.net> (raw)
In-Reply-To: <8199b7ae4c441c4311045141ddaaa36f.squirrel@webmail.highteq.net>

On Thu, Oct 16, 2008 at 02:30:00PM +0200, Lars Hoss wrote:

> The commit was on Jun 5, 14:47:50 by Marius Storm-Olsen and the relevant
> file is wt-status.c.
> 
> Ok, I think I found the issue. I enabled showUntrackedFiles in my gitconfig:
> 
> status.showUntrackedFiles = all

Ah, OK. I see what is going on. All code paths call the read_directory
infrastructure to find untracked files. If status.showUntrackedFiles is
"normal", then we set dir.show_other_directories, to indicate that we
want to see the directories, but not their constituent files.

If status.showuntrackedfiles is set to "all", then we don't set the
show_other_directories flag, because we want each file. But the code in
dir.c:treat_directory uses the "show_other_directories" flag to say "oh,
we're just interested in untracked files" and decide whether to ignore
gitlinks.

Meaning that we must still filter the results of read_directory based on
the cache. And indeed, this is what "git ls-files -o" does, as explained
in 5698454e (Fix some "git ls-files -o" fallout from gitlinks). It's
also what the code in wt_status_print_untracked is _supposed_ to do, but
it was never updated to handle this case when git-ls-files was. Which is
probably my fault a long time ago for cutting and pasting the 5 lines of
"is this thing in the cache" when writing wt-status.c.

So the quick fix is to re-cut-and-paste the code:

diff --git a/wt-status.c b/wt-status.c
index d2eac36..792d5f1 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -280,10 +280,14 @@ static void wt_status_print_untracked(struct wt_status *s)
 		/* check for matching entry, which is unmerged; lifted from
 		 * builtin-ls-files:show_other_files */
 		struct dir_entry *ent = dir.entries[i];
-		int pos = cache_name_pos(ent->name, ent->len);
+		int len, pos;
+		len = ent->len;
+		if (len && ent->name[len-1] == '/')
+			len--;
+		pos = cache_name_pos(ent->name, len);
 		struct cache_entry *ce;
 		if (0 <= pos)
-			die("bug in wt_status_print_untracked");
+			continue;
 		pos = -pos - 1;
 		if (pos < active_nr) {
 			ce = active_cache[pos];

But the right solution is to refactor this so the code isn't duplicated.
And I'll post a patch for that in a second.

I do have to wonder, though, whether an even better solution would be to
more explicitly tell read_directory "I'm interested only in 'other'
files" rather than relying on guessing based on
dir.show_other_directories. Then we could just avoid ever passing these
gitlinks back to ls-files and status in the first place.

-Peff

  reply	other threads:[~2008-10-16 14:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-15 12:07 [BUG] git status doesn't handle submodules properly on OSX Lars Hoss
2008-10-15 12:49 ` Jeff King
2008-10-15 14:30   ` Lars Hoss
2008-10-15 14:38 ` Pieter de Bie
2008-10-15 14:51   ` Lars Hoss
2008-10-15 14:59     ` Pieter de Bie
2008-10-15 15:14       ` Lars Hoss
2008-10-15 15:01     ` Richard Bubel
2008-10-15 15:21       ` Lars Hoss
2008-10-16  9:49         ` Pedro Melo
2008-10-16  9:48     ` Pedro Melo
2008-10-16 10:30       ` Lars Hoss
2008-10-16 11:23       ` Lars Hoss
2008-10-16 11:39         ` Johannes Sixt
2008-10-16 11:53           ` Lars Hoss
2008-10-16 12:30           ` Lars Hoss
2008-10-16 14:18             ` Jeff King [this message]
2008-10-16 14:59               ` [PATCH] refactor handling of "other" files in ls-files and status Jeff King
2008-10-16 15:07                 ` Jeff King
2008-10-17 23:58                 ` Junio C Hamano
2008-10-16  9:43 ` [BUG] git status doesn't handle submodules properly on OSX Pedro Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081016141812.GA30026@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=j.sixt@viscovery.net \
    --cc=lars@woeye.net \
    --cc=melo@simplicidade.org \
    --cc=pdebie@ai.rug.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).