From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Darren Cook <darren@dcook.org>, git@vger.kernel.org
Subject: Re: Bug Report: git add
Date: Thu, 07 Apr 2011 00:28:26 -0700 [thread overview]
Message-ID: <7vlizmfrl1.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20110407014819.GA12730@sigill.intra.peff.net> (Jeff King's message of "Wed, 6 Apr 2011 21:48:19 -0400")
Jeff King <peff@peff.net> writes:
> @@ -139,8 +138,21 @@ static int lstat_cache_matchlen(struct cache_def *cache,
> if (errno == ENOENT)
> *ret_flags |= FL_NOENT;
> } else if (S_ISDIR(st.st_mode)) {
> - last_slash_dir = last_slash;
> - continue;
> + struct stat junk;
> + struct strbuf gitdir = STRBUF_INIT;
> + strbuf_add(&gitdir, cache->path, match_len);
> + strbuf_addstr(&gitdir, "/.git");
> + if (lstat(gitdir.buf, &junk) < 0) {
> + if (errno == ENOENT) {
> + last_slash_dir = last_slash;
> + strbuf_release(&gitdir);
> + continue;
> + }
> + *ret_flags = FL_LSTATERR;
> + }
> + else
> + *ret_flags = FL_GITREPO;
This only checks "does the directory have .git in it?".
It probably is sufficient, but setup.c:is_git_directory() may do a more
appropriate check, I think. That ".git" thing could be a regular file
(i.e. "gitdir: path"), so depending on the junk.st_mode, you may have to
call read_gitfile_gently() on it before checking with is_git_directory().
Alternatively, resolve_gitlink_ref() might be usable, but because it is
primarily meant to deal with a submodule, there is a slight impedance
mismatch with the test we are trying to do. In this codepath, all we care
about is if the subdirectory is controlled by a separate git repository,
and it does not matter if that is an untracked directory from the
superproject's point of view, or if it is bound to the superproject as a
submodule.
Also I suspect resolve_gitlink_ref() may not work for a submodule that
does not have an initial commit but that is a separate issue.
next prev parent reply other threads:[~2011-04-07 7:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-05 23:18 Bug Report: git add Darren Cook
2011-04-06 5:52 ` Ramkumar Ramachandra
2011-04-10 7:48 ` Jakub Narebski
2011-04-10 8:29 ` Ramkumar Ramachandra
2011-04-11 17:55 ` Junio C Hamano
2011-04-11 18:20 ` Jeff King
2011-04-07 0:57 ` Jeff King
2011-04-07 1:09 ` Junio C Hamano
2011-04-07 1:12 ` Jeff King
2011-04-07 1:48 ` Jeff King
2011-04-07 7:28 ` Junio C Hamano [this message]
2011-04-08 19:15 ` Jeff King
2011-04-08 19:46 ` Jeff King
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vlizmfrl1.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=darren@dcook.org \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).