{"thread":{"id":"28083","subject":"[PATCH v3 0/2] submodule: move gitdir into superproject","startedAt":"2011-08-12T19:55:11Z","lastAt":"2011-08-16T17:34:03Z","messageCount":10,"participants":["Fredrik Gustafsson","Junio C Hamano","Nguyen Thai Ngoc Duy","Heiko Voigt","Marc Branchaud"],"isPatch":true,"patchVersion":3,"patchTotal":2},"messages":[{"id":"173414","messageId":"1313178913-25617-1-git-send-email-iveqy@iveqy.com","threadId":"28083","inReplyTo":null,"subject":"[PATCH v3 0/2] submodule: move gitdir into superproject","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2011-08-12T19:55:11Z","receivedAt":"2011-08-12T19:55:11Z","isPatch":true,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"Move git-dir for submodules into $GIT_DIR/modules/[name_of_submodule] of\nthe superproject. This is a step towards being able to delete submodule\ndirectories without loosing the information from their .git directory\nas that is now stored outside the submodules work tree.\n\nThis is done relying on the already existent .git-file functionality.\nTests that rely on .git being a directory have been fixed.\n\nThis is the third iteration of this patchseries. In this iteration the\ncommit message of the second patch is updated and the fixup-patch from\nJunio squashed with the first commit.\n\nThe first can be found here:\nhttp://thread.gmane.org/gmane.comp.version-control.git/177582\n\nThe second can be found here:\nhttp://thread.gmane.org/gmane.comp.version-control.git/178970/focus=179154\n\n\nFredrik Gustafsson (2):\n  rev-parse: add option --is-well-formed-git-dir [path]\n  Move git-dir for submodules\n\n Documentation/git-rev-parse.txt |    4 ++\n builtin/rev-parse.c             |    8 +++\n cache.h                         |    1 +\n git-submodule.sh                |   49 ++++++++++++++++--\n setup.c                         |    7 +++\n t/t7400-submodule-basic.sh      |    4 +-\n t/t7403-submodule-sync.sh       |    5 +-\n t/t7406-submodule-update.sh     |  107 +++++++++++++++++++++++++++++++++++++++\n t/t7407-submodule-foreach.sh    |  103 +++++++++++++++++++------------------\n t/t7408-submodule-reference.sh  |    4 +-\n 10 files changed, 231 insertions(+), 61 deletions(-)\n\n-- \n1.7.6.403.g1fd2f.dirty\n"},{"id":"173416","messageId":"1313178913-25617-2-git-send-email-iveqy@iveqy.com","threadId":"28083","inReplyTo":"1313178913-25617-1-git-send-email-iveqy@iveqy.com","subject":"[PATCH v3 1/2] rev-parse: add option --is-well-formed-git-dir [path]","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2011-08-12T19:55:12Z","receivedAt":"2011-08-12T19:55:12Z","isPatch":true,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"Check if [path] is a valid git-dir or a valid git-file that points\nto a valid git-dir.\n\nWe want tests to be independent from the fact that a git-dir may\nbe a git-file. Thus we changed tests to use this feature.\n\nSigned-off-by: Fredrik Gustafsson <iveqy@iveqy.com>\nMentored-by: Jens Lehmann <Jens.Lehmann@web.de>\nMentored-by: Heiko Voigt <hvoigt@hvoigt.net>\n---\n Documentation/git-rev-parse.txt |    4 ++\n builtin/rev-parse.c             |    8 +++\n cache.h                         |    1 +\n setup.c                         |    7 +++\n t/t7400-submodule-basic.sh      |    4 +-\n t/t7403-submodule-sync.sh       |    5 +-\n t/t7407-submodule-foreach.sh    |   97 ++++++++++++++++++++-------------------\n 7 files changed, 75 insertions(+), 51 deletions(-)\n\ndiff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt\nindex 42c9676..3ce81c0 100644\n--- a/Documentation/git-rev-parse.txt\n+++ b/Documentation/git-rev-parse.txt\n@@ -180,6 +180,10 @@ print a message to stderr and exit with nonzero status.\n <args>...::\n \tFlags and parameters to be parsed.\n \n+--is-well-formed-git-dir [path]::\n+\tCheck if [path] is a valid git-dir or a git-file pointing to a valid\n+\tgit-dir. If [path] is a valid git-dir the resolved path to git-dir will\n+\tbe printed.\n \n include::revisions.txt[]\n \ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex 4c19f84..21ac43f 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -468,6 +468,14 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\treturn 0;\n \t}\n \n+\tif (argc > 2 && !strcmp(argv[1], \"--is-well-formed-git-dir\")) {\n+\t\tconst char *gitdir = resolve_gitdir(argv[2]);\n+\t\tif (!gitdir)\n+\t\t\tdie(\"not a gitdir '%s'\", argv[2]);\n+\t\tputs(gitdir);\n+\t\treturn 0;\n+\t}\n+\n \tif (argc > 1 && !strcmp(\"-h\", argv[1]))\n \t\tusage(builtin_rev_parse_usage);\n \ndiff --git a/cache.h b/cache.h\nindex 9e12d55..550f632 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -436,6 +436,7 @@ extern char *get_graft_file(void);\n extern int set_git_dir(const char *path);\n extern const char *get_git_work_tree(void);\n extern const char *read_gitfile_gently(const char *path);\n+extern const char *resolve_gitdir(const char *suspect);\n extern void set_git_work_tree(const char *tree);\n \n #define ALTERNATE_DB_ENVIRONMENT \"GIT_ALTERNATE_OBJECT_DIRECTORIES\"\ndiff --git a/setup.c b/setup.c\nindex 5ea5502..efad002 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -808,3 +808,10 @@ const char *setup_git_directory(void)\n {\n \treturn setup_git_directory_gently(NULL);\n }\n+\n+const char *resolve_gitdir(const char *suspect)\n+{\n+\tif (is_git_directory(suspect))\n+\t\treturn suspect;\n+\treturn read_gitfile_gently(suspect);\n+}\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 14dc927..4df53e5 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -360,10 +360,10 @@ test_expect_success 'update --init' '\n \tgit submodule update init > update.out &&\n \tcat update.out &&\n \ttest_i18ngrep \"not initialized\" update.out &&\n-\t! test -d init/.git &&\n+\ttest_must_fail git rev-parse --is-well-formed-git-dir init/.git &&\n \n \tgit submodule update --init init &&\n-\ttest -d init/.git\n+\tgit rev-parse --is-well-formed-git-dir init/.git\n '\n \n test_expect_success 'do not add files from a submodule' '\ndiff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh\nindex 95ffe34..3620215 100755\n--- a/t/t7403-submodule-sync.sh\n+++ b/t/t7403-submodule-sync.sh\n@@ -56,8 +56,9 @@ test_expect_success '\"git submodule sync\" should update submodule URLs' '\n \t git pull --no-recurse-submodules &&\n \t git submodule sync\n \t) &&\n-\ttest -d \"$(git config -f super-clone/submodule/.git/config \\\n-\t                        remote.origin.url)\" &&\n+\ttest -d \"$(cd super-clone/submodule &&\n+\t git config remote.origin.url\n+\t)\" &&\n \t(cd super-clone/submodule &&\n \t git checkout master &&\n \t git pull\ndiff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh\nindex be745fb..1a974e2 100755\n--- a/t/t7407-submodule-foreach.sh\n+++ b/t/t7407-submodule-foreach.sh\n@@ -118,19 +118,19 @@ test_expect_success 'use \"submodule foreach\" to checkout 2nd level submodule' '\n \tgit clone super clone2 &&\n \t(\n \t\tcd clone2 &&\n-\t\ttest ! -d sub1/.git &&\n-\t\ttest ! -d sub2/.git &&\n-\t\ttest ! -d sub3/.git &&\n-\t\ttest ! -d nested1/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir sub1/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir sub2/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir sub3/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir nested1/.git &&\n \t\tgit submodule update --init &&\n-\t\ttest -d sub1/.git &&\n-\t\ttest -d sub2/.git &&\n-\t\ttest -d sub3/.git &&\n-\t\ttest -d nested1/.git &&\n-\t\ttest ! -d nested1/nested2/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir sub1/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir sub2/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir sub3/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir nested1/nested2/.git &&\n \t\tgit submodule foreach \"git submodule update --init\" &&\n-\t\ttest -d nested1/nested2/.git &&\n-\t\ttest ! -d nested1/nested2/nested3/.git\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/nested1/nested2/.git\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir nested1/nested2/nested3/.git\n \t)\n '\n \n@@ -138,8 +138,8 @@ test_expect_success 'use \"foreach --recursive\" to checkout all submodules' '\n \t(\n \t\tcd clone2 &&\n \t\tgit submodule foreach --recursive \"git submodule update --init\" &&\n-\t\ttest -d nested1/nested2/nested3/.git &&\n-\t\ttest -d nested1/nested2/nested3/submodule/.git\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/nested3/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/nested3/submodule/.git\n \t)\n '\n \n@@ -183,18 +183,18 @@ test_expect_success 'use \"update --recursive\" to checkout all submodules' '\n \tgit clone super clone3 &&\n \t(\n \t\tcd clone3 &&\n-\t\ttest ! -d sub1/.git &&\n-\t\ttest ! -d sub2/.git &&\n-\t\ttest ! -d sub3/.git &&\n-\t\ttest ! -d nested1/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir sub1/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir sub2/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir sub3/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir nested1/.git &&\n \t\tgit submodule update --init --recursive &&\n-\t\ttest -d sub1/.git &&\n-\t\ttest -d sub2/.git &&\n-\t\ttest -d sub3/.git &&\n-\t\ttest -d nested1/.git &&\n-\t\ttest -d nested1/nested2/.git &&\n-\t\ttest -d nested1/nested2/nested3/.git &&\n-\t\ttest -d nested1/nested2/nested3/submodule/.git\n+\t\tgit rev-parse --is-well-formed-git-dir sub1/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir sub2/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir sub3/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/nested3/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/nested3/submodule/.git\n \t)\n '\n \n@@ -247,14 +247,17 @@ test_expect_success 'ensure \"status --cached --recursive\" preserves the --cached\n \n test_expect_success 'use \"git clone --recursive\" to checkout all submodules' '\n \tgit clone --recursive super clone4 &&\n-\ttest -d clone4/.git &&\n-\ttest -d clone4/sub1/.git &&\n-\ttest -d clone4/sub2/.git &&\n-\ttest -d clone4/sub3/.git &&\n-\ttest -d clone4/nested1/.git &&\n-\ttest -d clone4/nested1/nested2/.git &&\n-\ttest -d clone4/nested1/nested2/nested3/.git &&\n-\ttest -d clone4/nested1/nested2/nested3/submodule/.git\n+\t(\n+\t\tcd clone4 &&\n+\t\tgit rev-parse --is-well-formed-git-dir .git &&\n+\t\tgit rev-parse --is-well-formed-git-dir sub1/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir sub2/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir sub3/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/nested3/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/nested3/submodule/.git\n+\t)\n '\n \n test_expect_success 'test \"update --recursive\" with a flag with spaces' '\n@@ -262,11 +265,11 @@ test_expect_success 'test \"update --recursive\" with a flag with spaces' '\n \tgit clone super clone5 &&\n \t(\n \t\tcd clone5 &&\n-\t\ttest ! -d nested1/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir d nested1/.git &&\n \t\tgit submodule update --init --recursive --reference=\"$(dirname \"$PWD\")/common objects\" &&\n-\t\ttest -d nested1/.git &&\n-\t\ttest -d nested1/nested2/.git &&\n-\t\ttest -d nested1/nested2/nested3/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/nested3/.git &&\n \t\ttest -f nested1/.git/objects/info/alternates &&\n \t\ttest -f nested1/nested2/.git/objects/info/alternates &&\n \t\ttest -f nested1/nested2/nested3/.git/objects/info/alternates\n@@ -277,18 +280,18 @@ test_expect_success 'use \"update --recursive nested1\" to checkout all submodules\n \tgit clone super clone6 &&\n \t(\n \t\tcd clone6 &&\n-\t\ttest ! -d sub1/.git &&\n-\t\ttest ! -d sub2/.git &&\n-\t\ttest ! -d sub3/.git &&\n-\t\ttest ! -d nested1/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir sub1/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir sub2/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir sub3/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir nested1/.git &&\n \t\tgit submodule update --init --recursive -- nested1 &&\n-\t\ttest ! -d sub1/.git &&\n-\t\ttest ! -d sub2/.git &&\n-\t\ttest ! -d sub3/.git &&\n-\t\ttest -d nested1/.git &&\n-\t\ttest -d nested1/nested2/.git &&\n-\t\ttest -d nested1/nested2/nested3/.git &&\n-\t\ttest -d nested1/nested2/nested3/submodule/.git\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir sub1/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir sub2/.git &&\n+\t\ttest_must_fail git rev-parse --is-well-formed-git-dir sub3/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/nested3/.git &&\n+\t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/nested3/submodule/.git\n \t)\n '\n \n-- \n1.7.6.403.g1fd2f.dirty\n"},{"id":"173415","messageId":"1313178913-25617-3-git-send-email-iveqy@iveqy.com","threadId":"28083","inReplyTo":"1313178913-25617-1-git-send-email-iveqy@iveqy.com","subject":"[PATCH v3 2/2] Move git-dir for submodules","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2011-08-12T19:55:13Z","receivedAt":"2011-08-12T19:55:13Z","isPatch":true,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"Move git-dir for submodules into $GIT_DIR/modules/[name_of_submodule] of\nthe superproject. This is a step towards being able to delete submodule\ndirectories without loosing the information from their .git directory\nas that is now stored outside the submodules work tree.\n\nThis is done relying on the already existent .git-file functionality.\nWhen adding or updating a submodule whose git directory is found under\n$GIT_DIR/modules/[name_of_submodule], don't clone it again but simply\npoint the .git-file to it and remove the now stale index file from it.\nThe index will be recreated by the following checkout.\n\nThis patch will not affect already cloned submodules at all.\n\nTests that rely on .git being a directory have been fixed.\n\nSigned-off-by: Fredrik Gustafsson <iveqy@iveqy.com>\nMentored-by: Jens Lehmann <Jens.Lehmann@web.de>\nMentored-by: Heiko Voigt <hvoigt@hvoigt.net>\n---\n git-submodule.sh               |   49 ++++++++++++++++--\n t/t7406-submodule-update.sh    |  107 ++++++++++++++++++++++++++++++++++++++++\n t/t7407-submodule-foreach.sh   |    6 +-\n t/t7408-submodule-reference.sh |    4 +-\n 4 files changed, 156 insertions(+), 10 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex bc1d3fa..ace6c1d 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -122,14 +122,53 @@ module_clone()\n \tpath=$1\n \turl=$2\n \treference=\"$3\"\n+\tgitdir=\n+\tgitdir_base=\n+\tname=$(module_name \"$path\")\n+\tif test -z \"$name\"\n+\tthen\n+\t\tname=\"$path\"\n+\tfi\n+\tbase_path=$(dirname \"$path\")\n+\n+\tgitdir=$(git rev-parse --git-dir)\n+\tgitdir_base=\"$gitdir/modules/$base_path\"\n+\tgitdir=\"$gitdir/modules/$path\"\n+\n+\tcase $gitdir in\n+\t/*)\n+\t\ta=\"$(cd_to_toplevel && pwd)/\"\n+\t\tb=$gitdir\n+\t\twhile [ \"$b\" ] && [ \"${a%%/*}\" = \"${b%%/*}\" ]\n+\t\tdo\n+\t\t\ta=${a#*/} b=${b#*/};\n+\t\tdone\n+\n+\t\trel=\"$a$name\"\n+\t\trel=`echo $rel | sed -e 's|[^/]*|..|g'`\n+\t\trel_gitdir=\"$rel/$b\"\n+\t\t;;\n+\t*)\n+\t\trel=`echo $name | sed -e 's|[^/]*|..|g'`\n+\t\trel_gitdir=\"$rel/$gitdir\"\n+\t\t;;\n+\tesac\n \n-\tif test -n \"$reference\"\n+\tif test -d \"$gitdir\"\n \tthen\n-\t\tgit-clone \"$reference\" -n \"$url\" \"$path\"\n+\t\tmkdir -p \"$path\"\n+\t\techo \"gitdir: $rel_gitdir\" >\"$path/.git\"\n+\t\trm -f \"$gitdir/index\"\n \telse\n-\t\tgit-clone -n \"$url\" \"$path\"\n-\tfi ||\n-\tdie \"$(eval_gettext \"Clone of '\\$url' into submodule path '\\$path' failed\")\"\n+\t\tmkdir -p \"$gitdir_base\"\n+\t\tif test -n \"$reference\"\n+\t\tthen\n+\t\t\tgit-clone \"$reference\" -n \"$url\" \"$path\" --separate-git-dir \"$gitdir\"\n+\t\telse\n+\t\t\tgit-clone -n \"$url\" \"$path\" --separate-git-dir \"$gitdir\"\n+\t\tfi ||\n+\t\tdie \"$(eval_gettext \"Clone of '\\$url' into submodule path '\\$path' failed\")\"\n+\tfi\n }\n \n #\ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex c679f36..1ae6b4e 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -408,6 +408,7 @@ test_expect_success 'submodule update exit immediately in case of merge conflict\n \t test_cmp expect actual\n \t)\n '\n+\n test_expect_success 'submodule update exit immediately after recursive rebase error' '\n \t(cd super &&\n \t git checkout master &&\n@@ -442,4 +443,110 @@ test_expect_success 'submodule update exit immediately after recursive rebase er\n \t test_cmp expect actual\n \t)\n '\n+\n+test_expect_success 'add different submodules to the same path' '\n+\t(cd super &&\n+\t git submodule add ../submodule s1 &&\n+\t test_must_fail git submodule add ../merging s1\n+\t)\n+'\n+\n+test_expect_success 'submodule add places git-dir in superprojects git-dir' '\n+\t(cd super &&\n+\t mkdir deeper &&\n+\t git submodule add ../submodule deeper/submodule &&\n+\t (cd deeper/submodule &&\n+\t  git log > ../../expected\n+\t ) &&\n+\t (cd .git/modules/deeper/submodule &&\n+\t  git log > ../../../../actual\n+\t ) &&\n+\t test_cmp actual expected\n+\t)\n+'\n+\n+test_expect_success 'submodule update places git-dir in superprojects git-dir' '\n+\t(cd super &&\n+\t git commit -m \"added submodule\"\n+\t) &&\n+\tgit clone super super2 &&\n+\t(cd super2 &&\n+\t git submodule init deeper/submodule &&\n+\t git submodule update &&\n+\t (cd deeper/submodule &&\n+\t  git log > ../../expected\n+\t ) &&\n+\t (cd .git/modules/deeper/submodule &&\n+\t  git log > ../../../../actual\n+\t ) &&\n+\t test_cmp actual expected\n+\t)\n+'\n+\n+test_expect_success 'submodule add places git-dir in superprojects git-dir recursive' '\n+\t(cd super2 &&\n+\t (cd deeper/submodule &&\n+\t  git submodule add ../submodule subsubmodule &&\n+\t  (cd subsubmodule &&\n+\t   git log > ../../../expected\n+\t  ) &&\n+\t  git commit -m \"added subsubmodule\" &&\n+\t  git push\n+\t ) &&\n+\t (cd .git/modules/deeper/submodule/modules/subsubmodule &&\n+\t  git log > ../../../../../actual\n+\t ) &&\n+\t git add deeper/submodule &&\n+\t git commit -m \"update submodule\" &&\n+\t git push &&\n+\t test_cmp actual expected\n+\t)\n+'\n+\n+test_expect_success 'submodule update places git-dir in superprojects git-dir recursive' '\n+\tmkdir super_update_r &&\n+\t(cd super_update_r &&\n+\t git init --bare\n+\t) &&\n+\tmkdir subsuper_update_r &&\n+\t(cd subsuper_update_r &&\n+\t git init --bare\n+\t) &&\n+\tmkdir subsubsuper_update_r &&\n+\t(cd subsubsuper_update_r &&\n+\t git init --bare\n+\t) &&\n+\tgit clone subsubsuper_update_r subsubsuper_update_r2 &&\n+\t(cd subsubsuper_update_r2 &&\n+\t test_commit \"update_subsubsuper\" file &&\n+\t git push origin master\n+\t) &&\n+\tgit clone subsuper_update_r subsuper_update_r2 &&\n+\t(cd subsuper_update_r2 &&\n+\t test_commit \"update_subsuper\" file &&\n+\t git submodule add ../subsubsuper_update_r subsubmodule &&\n+\t git commit -am \"subsubmodule\" &&\n+\t git push origin master\n+\t) &&\n+\tgit clone super_update_r super_update_r2 &&\n+\t(cd super_update_r2 &&\n+\t test_commit \"update_super\" file &&\n+\t git submodule add ../subsuper_update_r submodule &&\n+\t git commit -am \"submodule\" &&\n+\t git push origin master\n+\t) &&\n+\trm -rf super_update_r2 &&\n+\tgit clone super_update_r super_update_r2 &&\n+\t(cd super_update_r2 &&\n+\t git submodule update --init --recursive &&\n+\t (cd submodule/subsubmodule &&\n+\t  git log > ../../expected\n+\t ) &&\n+\t (cd .git/modules/submodule/modules/subsubmodule\n+\t  git log > ../../../../../actual\n+\t )\n+\t test_cmp actual expected\n+\t)\n+'\n+\n test_done\ndiff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh\nindex 1a974e2..e410bd4 100755\n--- a/t/t7407-submodule-foreach.sh\n+++ b/t/t7407-submodule-foreach.sh\n@@ -270,9 +270,9 @@ test_expect_success 'test \"update --recursive\" with a flag with spaces' '\n \t\tgit rev-parse --is-well-formed-git-dir nested1/.git &&\n \t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/.git &&\n \t\tgit rev-parse --is-well-formed-git-dir nested1/nested2/nested3/.git &&\n-\t\ttest -f nested1/.git/objects/info/alternates &&\n-\t\ttest -f nested1/nested2/.git/objects/info/alternates &&\n-\t\ttest -f nested1/nested2/nested3/.git/objects/info/alternates\n+\t\ttest -f .git/modules/nested1/objects/info/alternates &&\n+\t\ttest -f .git/modules/nested1/modules/nested2/objects/info/alternates &&\n+\t\ttest -f .git/modules/nested1/modules/nested2/modules/nested3/objects/info/alternates\n \t)\n '\n \ndiff --git a/t/t7408-submodule-reference.sh b/t/t7408-submodule-reference.sh\nindex cc16d3f..ab37c36 100755\n--- a/t/t7408-submodule-reference.sh\n+++ b/t/t7408-submodule-reference.sh\n@@ -43,7 +43,7 @@ git commit -m B-super-added'\n cd \"$base_dir\"\n \n test_expect_success 'after add: existence of info/alternates' \\\n-'test `wc -l <super/sub/.git/objects/info/alternates` = 1'\n+'test `wc -l <super/.git/modules/sub/objects/info/alternates` = 1'\n \n cd \"$base_dir\"\n \n@@ -66,7 +66,7 @@ test_expect_success 'update with reference' \\\n cd \"$base_dir\"\n \n test_expect_success 'after update: existence of info/alternates' \\\n-'test `wc -l <super-clone/sub/.git/objects/info/alternates` = 1'\n+'test `wc -l <super-clone/.git/modules/sub/objects/info/alternates` = 1'\n \n cd \"$base_dir\"\n \n-- \n1.7.6.403.g1fd2f.dirty\n"},{"id":"173418","messageId":"7vipq2mjpk.fsf@alter.siamese.dyndns.org","threadId":"28083","inReplyTo":"1313178913-25617-2-git-send-email-iveqy@iveqy.com","subject":"Re: [PATCH v3 1/2] rev-parse: add option --is-well-formed-git-dir [path]","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-12T20:57:27Z","receivedAt":"2011-08-12T20:57:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Fredrik Gustafsson <iveqy@iveqy.com> writes:\n\n> Check if [path] is a valid git-dir or a valid git-file that points\n> to a valid git-dir.\n\nOn Subject, here, and in the doc, I do not think you meant \"[path]\" (which\ntypically means \"you do not have to have anything, but you are allowed to\nhave a path, if you do write something here.\"). Perhaps you meant to say\n<path> instead (which is how most if not all of the documentation mark a\nplaceholder in a description)?\n"},{"id":"173440","messageId":"CACsJy8D7W54w3ji6foXySCuvNLLBu=FY70z8+kB5hmJT_-3yCg@mail.gmail.com","threadId":"28083","inReplyTo":"1313178913-25617-2-git-send-email-iveqy@iveqy.com","subject":"Re: [PATCH v3 1/2] rev-parse: add option --is-well-formed-git-dir [path]","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-08-13T02:49:56Z","receivedAt":"2011-08-13T02:49:56Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Aug 13, 2011 at 2:55 AM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:\n\\> +--is-well-formed-git-dir [path]::\n> +       Check if [path] is a valid git-dir or a git-file pointing to a valid\n> +       git-dir. If [path] is a valid git-dir the resolved path to git-dir will\n> +       be printed.\n\nMay I suggest --is-valid-git-dir?\n-- \nDuy\n"},{"id":"173441","messageId":"20110813061342.GA459@book.hvoigt.net","threadId":"28083","inReplyTo":"CACsJy8D7W54w3ji6foXySCuvNLLBu=FY70z8+kB5hmJT_-3yCg@mail.gmail.com","subject":"Re: [PATCH v3 1/2] rev-parse: add option --is-well-formed-git-dir [path]","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2011-08-13T06:13:43Z","receivedAt":"2011-08-13T06:13:43Z","isPatch":true,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"Hi,\n\nOn Sat, Aug 13, 2011 at 09:49:56AM +0700, Nguyen Thai Ngoc Duy wrote:\n> On Sat, Aug 13, 2011 at 2:55 AM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:\n> \\> +--is-well-formed-git-dir [path]::\n> > + ?? ?? ?? Check if [path] is a valid git-dir or a git-file pointing to a valid\n> > + ?? ?? ?? git-dir. If [path] is a valid git-dir the resolved path to git-dir will\n> > + ?? ?? ?? be printed.\n> \n> May I suggest --is-valid-git-dir?\n\nWhile we are talking about names how about:\n\n\t--resolve-git-dir\n\n? Since we had this information already the option prints out the found\nresolved git directory and could be used for that.\n\nCheers Heiko\n"},{"id":"173518","messageId":"7v7h6fn00i.fsf@alter.siamese.dyndns.org","threadId":"28083","inReplyTo":"20110813061342.GA459@book.hvoigt.net","subject":"Re: [PATCH v3 1/2] rev-parse: add option --is-well-formed-git-dir [path]","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-14T21:42:05Z","receivedAt":"2011-08-14T21:42:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Heiko Voigt <hvoigt@hvoigt.net> writes:\n\n> While we are talking about names how about:\n>\n> \t--resolve-git-dir\n>\n> ? Since we had this information already the option prints out the found\n> resolved git directory and could be used for that.\n\nI think we have a winner in the bikeshedding contest.\n"},{"id":"173533","messageId":"4E492D7B.50508@xiplink.com","threadId":"28083","inReplyTo":"1313178913-25617-3-git-send-email-iveqy@iveqy.com","subject":"Re: [PATCH v3 2/2] Move git-dir for submodules","fromName":"Marc Branchaud","fromEmail":"marcnarc@xiplink.com","sentAt":"2011-08-15T14:30:19Z","receivedAt":"2011-08-15T14:30:19Z","isPatch":true,"sender":{"key":"marcnarc@xiplink.com","avatar":"https://avatars.githubusercontent.com/u/14980203?v=4"},"body":"On 11-08-12 03:55 PM, Fredrik Gustafsson wrote:\n> \n> This patch will not affect already cloned submodules at all.\n\nMy question is perhaps a bit beyond the scope of this series...\n\nIs there going to be a way to migrate submodules to the new layout?  If the\neventual goal is to be able to delete & restore submodule working\ndirectories, it would be nice if that could work with submodules cloned by an\nolder git.\n\n\t\tM.\n"},{"id":"173538","messageId":"20110815151435.GA1976@kolya","threadId":"28083","inReplyTo":"4E492D7B.50508@xiplink.com","subject":"Re: [PATCH v3 2/2] Move git-dir for submodules","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2011-08-15T15:14:35Z","receivedAt":"2011-08-15T15:14:35Z","isPatch":true,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"On Mon, Aug 15, 2011 at 10:30:19AM -0400, Marc Branchaud wrote:\n> On 11-08-12 03:55 PM, Fredrik Gustafsson wrote:\n> > \n> > This patch will not affect already cloned submodules at all.\n> \n> My question is perhaps a bit beyond the scope of this series...\n> \n> Is there going to be a way to migrate submodules to the new layout?  If the\n> eventual goal is to be able to delete & restore submodule working\n> directories, it would be nice if that could work with submodules cloned by an\n> older git.\n> \n\nThat's not planned as far as I know. However, a new clone will do that,\n(and of course it's quite easy to do it manually).\n\nWhen git supports to delete and restore submodules that will not be done\nif there isn't a .git-FILE in the submodule.\n\n--\nMed vänliga hälsningar\nFredrik\n"},{"id":"173621","messageId":"7vhb5hi7lg.fsf@alter.siamese.dyndns.org","threadId":"28083","inReplyTo":"1313178913-25617-3-git-send-email-iveqy@iveqy.com","subject":"Re: [PATCH v3 2/2] Move git-dir for submodules","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-16T17:34:03Z","receivedAt":"2011-08-16T17:34:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Fredrik Gustafsson <iveqy@iveqy.com> writes:\n\n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index bc1d3fa..ace6c1d 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -122,14 +122,53 @@ module_clone()\n>  \tpath=$1\n>  \turl=$2\n>  \treference=\"$3\"\n> +\tgitdir=\n> +\tgitdir_base=\n> +\tname=$(module_name \"$path\")\n> +\tif test -z \"$name\"\n> +\tthen\n> +\t\tname=\"$path\"\n> +\tfi\n\nThis conditional is not needed; module_name dies when it cannot find the\nname for the path, as it should.\n\nIf the defaulting to the path itself were a good idea (which I do not\nthink it is), that should be done in module_name so that other callers\nthat tried to find the name for a given path that does not have a named\nmodule would get a consistent result.\n"}]}