From: Duy Nguyen <pclouds@gmail.com>
To: Heiko Voigt <hvoigt@hvoigt.net>
Cc: Brandon Williams <bmwill@google.com>,
Git Mailing List <git@vger.kernel.org>,
Stefan Beller <sbeller@google.com>
Subject: Re: Adding nested repository with slash adds files instead of gitlink
Date: Tue, 19 Jun 2018 18:09:57 +0200 [thread overview]
Message-ID: <20180619160956.GA21384@duynguyen.home> (raw)
In-Reply-To: <CACsJy8DQ-GGEDiV0iA2kTgNgHcT1sSX2Oqb7VZcjyK1nBOFv+A@mail.gmail.com>
On Tue, Jun 19, 2018 at 05:16:17PM +0200, Duy Nguyen wrote:
> No actually, we could do better. Let me see if I can come up with a
> patch or something...
OK. What we currently do is, when we search for potential untracked
paths for adding to the index, we unconditionally ignore anything
inside ".git". For example, if "foo" is a submodule, "git add ." will
visit "foo/.git" then ignore its content completely.
We could do something very similar: when we visit "foo", if "foo/.git"
exists, we ignore it as well. In other words, we extend from "ignore
anything inside a git repository" to "ignore anything inside any other
git worktree".
The following patch basically does that. If you specify "git add
foo/bar". It will still visit "foo" first, realize that it's a
submodule and drop it. At the end, it will not report foo/bar as an
untracked (i.e. add-able) entry, so you can't add it.
I didn't test it extensively to see if it breaks anything though. And
I might need to check how it affects untracked cache...
-- 8< --
diff --git a/dir.c b/dir.c
index fe9bf58e4c..8a1a5d8dd5 100644
--- a/dir.c
+++ b/dir.c
@@ -1672,6 +1672,17 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
if (dtype != DT_DIR && has_path_in_index)
return path_none;
+ if (dtype == DT_DIR) {
+ int path_len = path->len;
+ int is_submodule;
+
+ strbuf_addstr(path, "/.git");
+ is_submodule = is_directory(path->buf);
+ strbuf_setlen(path, path_len);
+ if (is_submodule)
+ return path_none;
+ }
+
/*
* When we are looking at a directory P in the working tree,
* there are three cases:
-- 8< --
next prev parent reply other threads:[~2018-06-19 16:13 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-18 11:19 Adding nested repository with slash adds files instead of gitlink Heiko Voigt
2018-06-18 15:06 ` Duy Nguyen
2018-06-18 18:12 ` Brandon Williams
2018-06-19 10:36 ` Heiko Voigt
2018-06-19 15:16 ` Duy Nguyen
2018-06-19 15:56 ` Junio C Hamano
2018-06-19 16:11 ` Duy Nguyen
2018-06-19 16:09 ` Duy Nguyen [this message]
2018-06-19 16:20 ` Duy Nguyen
2018-06-18 15:55 ` Kevin Daudt
2018-06-19 10:27 ` Heiko Voigt
2018-06-19 22:29 ` Rafael Ascensão
2018-06-20 4:39 ` Kevin Daudt
2018-06-20 11:52 ` Rafael Ascensão
2018-06-20 14:57 ` Duy Nguyen
2018-06-20 16:21 ` Rafael Ascensão
2024-08-08 11:20 ` Phil Sainty
2024-08-08 16:35 ` Junio C Hamano
2024-08-13 12:48 ` Johannes Schindelin
2024-08-13 17:18 ` Junio C Hamano
2024-08-13 23:13 ` Phil Sainty
2024-08-14 12:00 ` Johannes Schindelin
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=20180619160956.GA21384@duynguyen.home \
--to=pclouds@gmail.com \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=hvoigt@hvoigt.net \
--cc=sbeller@google.com \
/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).