All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Tan <jonathantanmy@google.com>
To: git@vger.kernel.org
Cc: Jonathan Tan <jonathantanmy@google.com>, gitster@pobox.com
Subject: [PATCH v2 1/3] submodule: remove unnecessary unabsorbed fallback
Date: Thu,  9 Sep 2021 11:47:27 -0700	[thread overview]
Message-ID: <a71965545d940f57cb82cac925d5c937959ddf64.1631212893.git.jonathantanmy@google.com> (raw)
In-Reply-To: <cover.1631212893.git.jonathantanmy@google.com>

In get_submodule_repo_for(), there is a fallback code path for the case
in which a submodule has an unabsorbed gitdir. (See the documentation
for "git submodule absorbgitdirs" for more information about absorbed
and unabsorbed gitdirs.) However, this code path is unnecessary, because
such submodules are already handled: when the fetch_task is created in
fetch_task_create(), it will create its own struct submodule with a path
and name, and repo_submodule_init() can handle such a struct.

This fallback was introduced in 26f80ccfc1 ("submodule: migrate
get_next_submodule to use repository structs", 2018-12-05). It was
unnecessary even then, but perhaps it escaped notice because its parent
commit d5498e0871 ("repository: repo_submodule_init to take a submodule
struct", 2018-12-05) was the one that taught repo_submodule_init() to
handle such created structs. Before, it took a path and always checked
.gitmodules, so it truly would have failed if there were no entry in
.gitmodules.

(Note to reviewers: in 26f80ccfc1, the "own struct submodule" I
mentioned is in get_next_submodule(), not fetch_task_create().)

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
---
 submodule.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/submodule.c b/submodule.c
index 8de1aecaeb..3af3da5b5e 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1409,19 +1409,8 @@ static struct repository *get_submodule_repo_for(struct repository *r,
 	struct repository *ret = xmalloc(sizeof(*ret));
 
 	if (repo_submodule_init(ret, r, sub)) {
-		/*
-		 * No entry in .gitmodules? Technically not a submodule,
-		 * but historically we supported repositories that happen to be
-		 * in-place where a gitlink is. Keep supporting them.
-		 */
-		struct strbuf gitdir = STRBUF_INIT;
-		strbuf_repo_worktree_path(&gitdir, r, "%s/.git", sub->path);
-		if (repo_init(ret, gitdir.buf, NULL)) {
-			strbuf_release(&gitdir);
-			free(ret);
-			return NULL;
-		}
-		strbuf_release(&gitdir);
+		free(ret);
+		return NULL;
 	}
 
 	return ret;
-- 
2.33.0.309.g3052b89438-goog


  reply	other threads:[~2021-09-09 18:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08 18:18 [PATCH 0/3] More add_submodule_odb() cleanup in merge code Jonathan Tan
2021-09-08 18:18 ` [PATCH 1/3] t6437: run absorbgitdirs on repos Jonathan Tan
2021-09-08 22:02   ` Jonathan Tan
2021-09-08 22:20   ` Junio C Hamano
2021-09-09 17:47     ` Jonathan Tan
2021-09-08 18:18 ` [PATCH 2/3] revision: remove "submodule" from opt struct Jonathan Tan
2021-09-08 18:18 ` [PATCH 3/3] DO NOT SUBMIT commit-reach,revision: verify non-mixing Jonathan Tan
2021-09-09 15:26 ` [PATCH 0/3] More add_submodule_odb() cleanup in merge code Elijah Newren
2021-09-09 17:51   ` Jonathan Tan
2021-09-09 18:47 ` [PATCH v2 " Jonathan Tan
2021-09-09 18:47   ` Jonathan Tan [this message]
2021-09-09 18:47   ` [PATCH v2 2/3] repository: support unabsorbed in repo_submodule_init Jonathan Tan
2021-09-09 18:47   ` [PATCH v2 3/3] revision: remove "submodule" from opt struct Jonathan Tan
2021-09-14  1:31   ` [PATCH v2 0/3] More add_submodule_odb() cleanup in merge code Elijah Newren

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=a71965545d940f57cb82cac925d5c937959ddf64.1631212893.git.jonathantanmy@google.com \
    --to=jonathantanmy@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.