git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: bartbogaerts@gmail.com
Cc: git@vger.kernel.org, Stefan Beller <sbeller@google.com>
Subject: [PATCHv2] submodule: test moving recursive submodule
Date: Tue, 28 Jun 2016 11:24:19 -0700	[thread overview]
Message-ID: <20160628182419.8023-1-sbeller@google.com> (raw)

This reproduces the error as pointed out in [1], but the fix is not easy,
so punt on it for now and just document what needs to be done.

[1] http://stackoverflow.com/questions/32782382/git-moving-submodules-recursively-nested-submodules

Signed-off-by: Stefan Beller <sbeller@google.com>
---

  Bart,
  
  I don't have the time fixing this properly,
  so this is the best I can come up with for now. 
  
  Thanks,
  Stefan

 builtin/mv.c  |  4 ++++
 t/t7001-mv.sh | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/builtin/mv.c b/builtin/mv.c
index a201426..36dd2fd 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -264,6 +264,10 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 				connect_work_tree_and_git_dir(dst, submodule_gitfile[i]);
 			if (!update_path_in_gitmodules(src, dst))
 				gitmodules_modified = 1;
+			/**
+			 * NEEDSWORK: We need to recurse into the submodule
+			 * and fix the nested submodules as well.
+			 */
 		}
 
 		if (mode == WORKING_DIRECTORY)
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index 4a2570e..fe933f1 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -295,6 +295,28 @@ test_expect_success 'setup submodule' '
 	mkdir -p deep/directory/hierachy &&
 	git submodule add ./. deep/directory/hierachy/sub &&
 	git commit -m "added another submodule" &&
+	mkdir inner_sub &&
+	(
+		cd inner_sub &&
+		git init &&
+		test_commit initial
+	) &&
+	mkdir outer_sub &&
+	(
+		cd outer_sub &&
+		git init &&
+		test_commit initial &&
+		git submodule add ../inner_sub &&
+		git commit -a -m "add an inner submodule"
+	) &&
+	git submodule add ./outer_sub ./deep/outer_sub &&
+	git commit -a -m "add outer sub" &&
+	git -C deep ls-tree HEAD |cut -f 2 >actual &&
+	cat >expect <<-EOF &&
+	directory
+	outer_sub
+	EOF
+	test_cmp expect actual &&
 	git branch submodule
 '
 
@@ -488,6 +510,18 @@ test_expect_success 'moving a submodule in nested directories' '
 		git config -f ../.gitmodules submodule.deep/directory/hierachy/sub.path >../actual &&
 		echo "directory/hierachy/sub" >../expect
 	) &&
+	test_cmp actual expect &&
+	git commit -a -m "mv a submodule in nested dir"
+'
+
+test_expect_failure 'moving a submodule with a nested submodule' '
+	git submodule update --init --recursive &&
+	git mv deep/outer_sub outer_sub_moved &&
+	# git status would fail if the update of linking git dir to
+	# work dir of the submodule failed.
+	git status &&
+	git config -f .gitmodules submodule.deep/outer_sub.path >actual &&
+	echo "outer_sub_moved" >expect &&
 	test_cmp actual expect
 '
 
-- 
2.9.0.138.g8a4fcb8.dirty


                 reply	other threads:[~2016-06-28 18:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20160628182419.8023-1-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=bartbogaerts@gmail.com \
    --cc=git@vger.kernel.org \
    /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).