{"thread":{"id":"29576","subject":"[PATCH 0/2] submodules: Use relative paths to gitdir and work tree","startedAt":"2012-02-08T22:08:18Z","lastAt":"2012-02-28T19:33:25Z","messageCount":21,"participants":["Jens Lehmann","Junio C Hamano","Johannes Sixt","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"184205","messageId":"4F32F252.7050105@web.de","threadId":"29576","inReplyTo":null,"subject":"[PATCH 0/2] submodules: Use relative paths to gitdir and work tree","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-02-08T22:08:18Z","receivedAt":"2012-02-08T22:08:18Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"This patch series replaces all absolute paths pointing from submodule work\ntrees to its gitdir and back with relative paths as discussed in $gmane/187785.\n\nThe motivation is to make superprojects movable again. They lost this ability\nwith the move of the git directory of submodules into the .git/modules directory\nof the superproject. While fixing that a bug which would hit when moving the\nsubmodule inside the superproject was also fixed.\n\nJens Lehmann (2):\n  submodules: always use a relative path to gitdir\n  submodules: always use a relative path from gitdir to work tree\n\n git-submodule.sh           |   23 ++++++++++++++++-------\n t/t7400-submodule-basic.sh |   22 ++++++++++++++++++++++\n 2 files changed, 38 insertions(+), 7 deletions(-)\n\n-- \n1.7.9.190.gb17a42.dirty\n"},{"id":"184206","messageId":"4F32F2F6.6040006@web.de","threadId":"29576","inReplyTo":"4F32F252.7050105@web.de","subject":"[PATCH 1/2] submodules: always use a relative path to gitdir","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-02-08T22:11:02Z","receivedAt":"2012-02-08T22:11:02Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Since recently a submodule with name <name> has its git directory in the\n.git/modules/<name> directory of the superproject while the work tree\ncontains a gitfile pointing there. When the submodule git directory needs\nto be cloned because it is not found in .git/modules/<name> the clone\ncommand will write an absolute path into the gitfile. When no clone is\nnecessary the git directory will be reactivated by the git-submodule.sh\nscript by writing a relative path into the gitfile.\n\nThis is inconsistent, as the behavior depends on the submodule having been\ncloned before into the .git/modules of the superproject. A relative path\nis preferable here because it allows the superproject to be moved around\nwithout invalidating the gitfile. We do that by always writing the\nrelative path into the gitfile, which overwrites the absolute path the\nclone command may have written there.\n\nThis is only the first step to make superprojects movable again like they\nwere before the separate-git-dir approach was introduced. The second step\nis to use a relative path in core.worktree too.\n\nEnhance t7400 to ensure that future versions won't re-add absolute paths\nby accident.\n\nWhile at it also replace an if/else construct evaluating the presence\nof the 'reference' option with a single line of bash code.\n\nReported-by: Antony Male <antony.male@gmail.com>\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n git-submodule.sh           |   11 ++++-------\n t/t7400-submodule-basic.sh |    2 ++\n 2 files changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 9bb2e13..2a93c61 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -160,18 +160,15 @@ module_clone()\n     if test -d \"$gitdir\"\n     then\n         mkdir -p \"$path\"\n-        echo \"gitdir: $rel_gitdir\" >\"$path/.git\"\n         rm -f \"$gitdir/index\"\n     else\n         mkdir -p \"$gitdir_base\"\n-        if test -n \"$reference\"\n-        then\n-            git-clone $quiet \"$reference\" -n \"$url\" \"$path\" --separate-git-dir \"$gitdir\"\n-        else\n-            git-clone $quiet -n \"$url\" \"$path\" --separate-git-dir \"$gitdir\"\n-        fi ||\n+        git clone $quiet -n ${reference:+\"$reference\"} \\\n+            --separate-git-dir \"$gitdir\" \"$url\" \"$path\" ||\n         die \"$(eval_gettext \"Clone of '\\$url' into submodule path '\\$path' failed\")\"\n     fi\n+\n+    echo \"gitdir: $rel_gitdir\" >\"$path/.git\"\n }\n \n #\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 695f7af..2b70b22 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -79,6 +79,8 @@ test_expect_success 'submodule add' '\n         cd addtest &&\n         git submodule add -q \"$submodurl\" submod >actual &&\n         test ! -s actual &&\n+        echo \"gitdir: ../.git/modules/submod\" >expect &&\n+        test_cmp expect submod/.git &&\n         git submodule init\n     ) &&\n \n-- \n1.7.9.190.gb17a42.dirty\n"},{"id":"184208","messageId":"4F32F465.7090401@web.de","threadId":"29576","inReplyTo":"4F32F252.7050105@web.de","subject":"[PATCH 2/2] submodules: always use a relative path from gitdir to work tree","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-02-08T22:17:09Z","receivedAt":"2012-02-08T22:17:09Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Since recently a submodule with name <name> has its git directory in the\n.git/modules/<name> directory of the superproject while the work tree\ncontains a gitfile pointing there. To make that work the git directory has\nthe core.worktree configuration set in its config file to point back to\nthe work tree.\n\nThat core.worktree is an absolute path set by the initial clone of the\nsubmodule. A relative path is preferable here because it allows the\nsuperproject to be moved around without invalidating that setting, so\ncompute and set that relative path after cloning or reactivating the\nsubmodule.\n\nThis also fixes a bug when moving a submodule around inside the\nsuperproject, as the current code forgot to update the setting to the new\nsubmodule work tree location.\n\nEnhance t7400 to ensure that future versions won't re-add absolute paths\nby accident and that moving a superproject won't break submodules.\n\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n git-submodule.sh           |    9 +++++++++\n t/t7400-submodule-basic.sh |   20 ++++++++++++++++++++\n 2 files changed, 29 insertions(+), 0 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 2a93c61..3463d6d 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -169,6 +169,15 @@ module_clone()\n     fi\n \n     echo \"gitdir: $rel_gitdir\" >\"$path/.git\"\n+\n+    a=$(cd \"$gitdir\" && pwd)\n+    b=$(cd \"$path\" && pwd)\n+    while [ \"$b\" ] && [ \"${a%%/*}\" = \"${b%%/*}\" ]\n+    do\n+        a=${a#*/} b=${b#*/};\n+    done\n+    rel=$(echo $a | sed -e 's|[^/]*|..|g')\n+    (clear_local_git_env; cd \"$path\" && git config core.worktree \"$rel/$b\")\n }\n \n #\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 2b70b22..b377a7a 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -81,6 +81,13 @@ test_expect_success 'submodule add' '\n         test ! -s actual &&\n         echo \"gitdir: ../.git/modules/submod\" >expect &&\n         test_cmp expect submod/.git &&\n+        (\n+            cd submod &&\n+            git config core.worktree >actual &&\n+            echo \"../../../submod\" >expect &&\n+            test_cmp expect actual &&\n+            rm -f actual expect\n+        ) &&\n         git submodule init\n     ) &&\n \n@@ -500,4 +507,17 @@ test_expect_success 'relative path works with user@host:path' '\n     )\n '\n \n+test_expect_success 'moving the superproject does not break submodules' '\n+    (\n+        cd addtest &&\n+        git submodule status >expect\n+    )\n+    mv addtest addtest2 &&\n+    (\n+        cd addtest2 &&\n+        git submodule status >actual &&\n+        test_cmp expect actual\n+    )\n+'\n+\n test_done\n-- \n1.7.9.190.gf8e73.dirty\n"},{"id":"184224","messageId":"4F33814E.7050404@web.de","threadId":"29576","inReplyTo":"4F32F2F6.6040006@web.de","subject":"[PATCH v2 1/2] submodules: always use a relative path to gitdir","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-02-09T08:18:22Z","receivedAt":"2012-02-09T08:18:22Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Since recently a submodule with name <name> has its git directory in the\n.git/modules/<name> directory of the superproject while the work tree\ncontains a gitfile pointing there. When the submodule git directory needs\nto be cloned because it is not found in .git/modules/<name> the clone\ncommand will write an absolute path into the gitfile. When no clone is\nnecessary the git directory will be reactivated by the git-submodule.sh\nscript by writing a relative path into the gitfile.\n\nThis is inconsistent, as the behavior depends on the submodule having been\ncloned before into the .git/modules of the superproject. A relative path\nis preferable here because it allows the superproject to be moved around\nwithout invalidating the gitfile. We do that by always writing the\nrelative path into the gitfile, which overwrites the absolute path the\nclone command may have written there.\n\nThis is only the first step to make superprojects movable again like they\nwere before the separate-git-dir approach was introduced. The second step\nis to use a relative path in core.worktree too.\n\nEnhance t7400 to ensure that future versions won't re-add absolute paths\nby accident.\n\nWhile at it also replace an if/else construct evaluating the presence\nof the 'reference' option with a single line of bash code.\n\nReported-by: Antony Male <antony.male@gmail.com>\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n\nThe first version was whitespace damaged, please use this one instead.\n\n git-submodule.sh           |   11 ++++-------\n t/t7400-submodule-basic.sh |    2 ++\n 2 files changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 9bb2e13..2a93c61 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -160,18 +160,15 @@ module_clone()\n \tif test -d \"$gitdir\"\n \tthen\n \t\tmkdir -p \"$path\"\n-\t\techo \"gitdir: $rel_gitdir\" >\"$path/.git\"\n \t\trm -f \"$gitdir/index\"\n \telse\n \t\tmkdir -p \"$gitdir_base\"\n-\t\tif test -n \"$reference\"\n-\t\tthen\n-\t\t\tgit-clone $quiet \"$reference\" -n \"$url\" \"$path\" --separate-git-dir \"$gitdir\"\n-\t\telse\n-\t\t\tgit-clone $quiet -n \"$url\" \"$path\" --separate-git-dir \"$gitdir\"\n-\t\tfi ||\n+\t\tgit clone $quiet -n ${reference:+\"$reference\"} \\\n+\t\t\t--separate-git-dir \"$gitdir\" \"$url\" \"$path\" ||\n \t\tdie \"$(eval_gettext \"Clone of '\\$url' into submodule path '\\$path' failed\")\"\n \tfi\n+\n+\techo \"gitdir: $rel_gitdir\" >\"$path/.git\"\n }\n\n #\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 695f7af..2b70b22 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -79,6 +79,8 @@ test_expect_success 'submodule add' '\n \t\tcd addtest &&\n \t\tgit submodule add -q \"$submodurl\" submod >actual &&\n \t\ttest ! -s actual &&\n+\t\techo \"gitdir: ../.git/modules/submod\" >expect &&\n+\t\ttest_cmp expect submod/.git &&\n \t\tgit submodule init\n \t) &&\n\n-- \n1.7.9.190.g0a6c2\n"},{"id":"184225","messageId":"4F338156.9090507@web.de","threadId":"29576","inReplyTo":"4F32F465.7090401@web.de","subject":"[PATCH v2 2/2] submodules: always use a relative path from gitdir to work tree","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-02-09T08:18:30Z","receivedAt":"2012-02-09T08:18:30Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Since recently a submodule with name <name> has its git directory in the\n.git/modules/<name> directory of the superproject while the work tree\ncontains a gitfile pointing there. To make that work the git directory has\nthe core.worktree configuration set in its config file to point back to\nthe work tree.\n\nThat core.worktree is an absolute path set by the initial clone of the\nsubmodule. A relative path is preferable here because it allows the\nsuperproject to be moved around without invalidating that setting, so\ncompute and set that relative path after cloning or reactivating the\nsubmodule.\n\nThis also fixes a bug when moving a submodule around inside the\nsuperproject, as the current code forgot to update the setting to the new\nsubmodule work tree location.\n\nEnhance t7400 to ensure that future versions won't re-add absolute paths\nby accident and that moving a superproject won't break submodules.\n\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n\nThe first version was whitespace damaged, please use this instead.\n\n git-submodule.sh           |    9 +++++++++\n t/t7400-submodule-basic.sh |   20 ++++++++++++++++++++\n 2 files changed, 29 insertions(+), 0 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 2a93c61..3463d6d 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -169,6 +169,15 @@ module_clone()\n \tfi\n\n \techo \"gitdir: $rel_gitdir\" >\"$path/.git\"\n+\n+\ta=$(cd \"$gitdir\" && pwd)\n+\tb=$(cd \"$path\" && pwd)\n+\twhile [ \"$b\" ] && [ \"${a%%/*}\" = \"${b%%/*}\" ]\n+\tdo\n+\t\ta=${a#*/} b=${b#*/};\n+\tdone\n+\trel=$(echo $a | sed -e 's|[^/]*|..|g')\n+\t(clear_local_git_env; cd \"$path\" && git config core.worktree \"$rel/$b\")\n }\n\n #\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 2b70b22..b377a7a 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -81,6 +81,13 @@ test_expect_success 'submodule add' '\n \t\ttest ! -s actual &&\n \t\techo \"gitdir: ../.git/modules/submod\" >expect &&\n \t\ttest_cmp expect submod/.git &&\n+\t\t(\n+\t\t\tcd submod &&\n+\t\t\tgit config core.worktree >actual &&\n+\t\t\techo \"../../../submod\" >expect &&\n+\t\t\ttest_cmp expect actual &&\n+\t\t\trm -f actual expect\n+\t\t) &&\n \t\tgit submodule init\n \t) &&\n\n@@ -500,4 +507,17 @@ test_expect_success 'relative path works with user@host:path' '\n \t)\n '\n\n+test_expect_success 'moving the superproject does not break submodules' '\n+\t(\n+\t\tcd addtest &&\n+\t\tgit submodule status >expect\n+\t)\n+\tmv addtest addtest2 &&\n+\t(\n+\t\tcd addtest2 &&\n+\t\tgit submodule status >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n test_done\n-- \n1.7.9.190.g0a6c2\n"},{"id":"184255","messageId":"7vd39nx0br.fsf@alter.siamese.dyndns.org","threadId":"29576","inReplyTo":"4F33814E.7050404@web.de","subject":"Re: [PATCH v2 1/2] submodules: always use a relative path to gitdir","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-09T19:40:08Z","receivedAt":"2012-02-09T19:40:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jens Lehmann <Jens.Lehmann@web.de> writes:\n\n> Since recently a submodule with name <name> has its git directory in the\n\nI understand that \"recently\" refers to efc5fb6a77 and this is potentially\na maint material for v1.7.8.X; am I correct?\n\n> The first version was whitespace damaged, please use this one instead.\n\nThanks. \n\nWhen applied to v1.7.8.x maintenance track, this failed the first step in\nt5526, but with the earlier jl/submodule-re-add topic everything seems to\npass just fine.\n"},{"id":"184258","messageId":"7v8vkbwzqp.fsf@alter.siamese.dyndns.org","threadId":"29576","inReplyTo":"7vd39nx0br.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 1/2] submodules: always use a relative path to gitdir","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-09T19:52:46Z","receivedAt":"2012-02-09T19:52:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> When applied to v1.7.8.x maintenance track, this failed the first step in\n> t5526, but with the earlier jl/submodule-re-add topic everything seems to\n> pass just fine.\n\nWhat I meant to say is that \"this and the other topic need to be merged to\nthat maintenance track together\"; I didn't mean to say there is any\nbreakage in this patch.\n\nSorry for a potentially confusing statement.\n"},{"id":"184261","messageId":"4F3428D9.7080906@web.de","threadId":"29576","inReplyTo":"7vd39nx0br.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 1/2] submodules: always use a relative path to gitdir","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-02-09T20:13:13Z","receivedAt":"2012-02-09T20:13:13Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 09.02.2012 20:40, schrieb Junio C Hamano:\n> Jens Lehmann <Jens.Lehmann@web.de> writes:\n> \n>> Since recently a submodule with name <name> has its git directory in the\n> \n> I understand that \"recently\" refers to efc5fb6a77 and this is potentially\n> a maint material for v1.7.8.X; am I correct?\n\nThat's correct.\n\n>> The first version was whitespace damaged, please use this one instead.\n> \n> Thanks. \n> \n> When applied to v1.7.8.x maintenance track, this failed the first step in\n> t5526, but with the earlier jl/submodule-re-add topic everything seems to\n> pass just fine.\n\nAh, I only tested these patches on current master. But you are right,\nthis belongs on top of jl/submodule-re-add for maint.\n"},{"id":"184592","messageId":"7vlio6ec7q.fsf@alter.siamese.dyndns.org","threadId":"29576","inReplyTo":"4F338156.9090507@web.de","subject":"Re: [PATCH v2 2/2] submodules: always use a relative path from gitdir to work tree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-13T19:59:37Z","receivedAt":"2012-02-13T19:59:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jens Lehmann <Jens.Lehmann@web.de> writes:\n\n> The first version was whitespace damaged, please use this instead.\n\nThanks.  This one looks somewhat iffy (1/2 looked perfectly fine, though).\n\n> +\ta=$(cd \"$gitdir\" && pwd)\n> +\tb=$(cd \"$path\" && pwd)\n> +\twhile [ \"$b\" ] && [ \"${a%%/*}\" = \"${b%%/*}\" ]\n> +\tdo\n> +\t\ta=${a#*/} b=${b#*/};\n> +\tdone\n> +\trel=$(echo $a | sed -e 's|[^/]*|..|g')\n> +\t(clear_local_git_env; cd \"$path\" && git config core.worktree \"$rel/$b\")\n>  }\n\n\nThe style ([ \"$b\" ] vs \"test -n \"$b\") aside, it strikes me odd that you\nonly check $b; it is unclear what guarantees that \"$a\" is always longer.\nMaybe there is a reason but then a one-line comment here would not hurt?\n"},{"id":"184681","messageId":"4F3A9B98.6040908@web.de","threadId":"29576","inReplyTo":"7vlio6ec7q.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 2/2] submodules: always use a relative path from gitdir to work tree","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-02-14T17:36:24Z","receivedAt":"2012-02-14T17:36:24Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 13.02.2012 20:59, schrieb Junio C Hamano:\n> Jens Lehmann <Jens.Lehmann@web.de> writes:\n>> +\ta=$(cd \"$gitdir\" && pwd)\n>> +\tb=$(cd \"$path\" && pwd)\n>> +\twhile [ \"$b\" ] && [ \"${a%%/*}\" = \"${b%%/*}\" ]\n>> +\tdo\n>> +\t\ta=${a#*/} b=${b#*/};\n>> +\tdone\n>> +\trel=$(echo $a | sed -e 's|[^/]*|..|g')\n>> +\t(clear_local_git_env; cd \"$path\" && git config core.worktree \"$rel/$b\")\n>>  }\n> \n> \n> The style ([ \"$b\" ] vs \"test -n \"$b\") aside, it strikes me odd that you\n> only check $b; it is unclear what guarantees that \"$a\" is always longer.\n> Maybe there is a reason but then a one-line comment here would not hurt?\n\nI just copied that while loop from a few lines up, but you are right\nabout the style and logic issues (Will send a cleanup patch for the\nother loop too when we agree on how to write this one).\n\nAfter adding a comment, using test instead of [], testing both $a and\n$b and assigning each variable on it's own line I get the following\ninterdiff. Does that make more sense?\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 3463d6d..ed76ce2 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -172,9 +172,11 @@ module_clone()\n\n        a=$(cd \"$gitdir\" && pwd)\n        b=$(cd \"$path\" && pwd)\n-       while [ \"$b\" ] && [ \"${a%%/*}\" = \"${b%%/*}\" ]\n+       # Remove all common leading directories\n+       while test -n \"$a\" && test -n \"$b\" && test \"${a%%/*}\" = \"${b%%/*}\"\n        do\n-               a=${a#*/} b=${b#*/};\n+               a=${a#*/}\n+               b=${b#*/}\n        done\n        rel=$(echo $a | sed -e 's|[^/]*|..|g')\n        (clear_local_git_env; cd \"$path\" && git config core.worktree \"$rel/$b\")\n"},{"id":"184683","messageId":"7v4nut6u4s.fsf@alter.siamese.dyndns.org","threadId":"29576","inReplyTo":"4F3A9B98.6040908@web.de","subject":"Re: [PATCH v2 2/2] submodules: always use a relative path from gitdir to work tree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-14T20:24:19Z","receivedAt":"2012-02-14T20:24:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jens Lehmann <Jens.Lehmann@web.de> writes:\n\n> After adding a comment, using test instead of [], testing both $a and\n> $b and assigning each variable on it's own line I get the following\n> interdiff. Does that make more sense?\n\nMy earlier request for comment was to say\n\n\t# $a is always longer than $b for such and such reasons\n\nto explain why testing $b without testing $a was sufficient.\n\nIt is obvious (at least to me) that the loop continues as long as $a and\n$b begin with the same string before their first '/' and removes that\ncommon segment from both of them, so I do not think the new comment is\nabsolutely necessary, but it would not hurt to have it, especially it is\nshort enough and to the point.\n\nThanks.\n\n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index 3463d6d..ed76ce2 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -172,9 +172,11 @@ module_clone()\n>\n>         a=$(cd \"$gitdir\" && pwd)\n>         b=$(cd \"$path\" && pwd)\n> -       while [ \"$b\" ] && [ \"${a%%/*}\" = \"${b%%/*}\" ]\n> +       # Remove all common leading directories\n> +       while test -n \"$a\" && test -n \"$b\" && test \"${a%%/*}\" = \"${b%%/*}\"\n>         do\n> -               a=${a#*/} b=${b#*/};\n> +               a=${a#*/}\n> +               b=${b#*/}\n>         done\n>         rel=$(echo $a | sed -e 's|[^/]*|..|g')\n>         (clear_local_git_env; cd \"$path\" && git config core.worktree \"$rel/$b\")\n"},{"id":"184687","messageId":"7vzkcl5f37.fsf@alter.siamese.dyndns.org","threadId":"29576","inReplyTo":"7v4nut6u4s.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 2/2] submodules: always use a relative path from gitdir to work tree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-14T20:34:36Z","receivedAt":"2012-02-14T20:34:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Jens Lehmann <Jens.Lehmann@web.de> writes:\n>\n>> After adding a comment, using test instead of [], testing both $a and\n>> $b and assigning each variable on it's own line I get the following\n>> interdiff. Does that make more sense?\n>\n> My earlier request for comment was to say\n>\n> \t# $a is always longer than $b for such and such reasons\n>\n> to explain why testing $b without testing $a was sufficient.\n\nHeh, after I follow the entire module_clone, $gitdir is defined in earlier\nparts of the function to be \"$(rev-parse --git-dir)/modules/$path\", so it\nis clear that it is longer than $path.  Unless \"cd $there && pwd\" does not\nresult in a funny situation (such as $something/modules is a symbolic link\nto another place that is much closer to the root of the filesystem), that\nis.\n\nAnd in such a case, the prefix part of $a and $b would be different from\nthe very beginning hopefully.\n\n> It is obvious (at least to me) that the loop continues as long as $a and\n> $b begin with the same string before their first '/' and removes that\n> common segment from both of them, so I do not think the new comment is\n> absolutely necessary, but it would not hurt to have it, especially it is\n> short enough and to the point.\n>\n> Thanks.\n>\n>> diff --git a/git-submodule.sh b/git-submodule.sh\n>> index 3463d6d..ed76ce2 100755\n>> --- a/git-submodule.sh\n>> +++ b/git-submodule.sh\n>> @@ -172,9 +172,11 @@ module_clone()\n>>\n>>         a=$(cd \"$gitdir\" && pwd)\n>>         b=$(cd \"$path\" && pwd)\n>> -       while [ \"$b\" ] && [ \"${a%%/*}\" = \"${b%%/*}\" ]\n>> +       # Remove all common leading directories\n>> +       while test -n \"$a\" && test -n \"$b\" && test \"${a%%/*}\" = \"${b%%/*}\"\n>>         do\n>> -               a=${a#*/} b=${b#*/};\n>> +               a=${a#*/}\n>> +               b=${b#*/}\n>>         done\n>>         rel=$(echo $a | sed -e 's|[^/]*|..|g')\n\nPerhaps aseert that $a never becomes empty before this line (or set it\nexplicitly to \".\" when $a is empty), as otherwise\n\n>>         (clear_local_git_env; cd \"$path\" && git config core.worktree \"$rel/$b\")\n\nthis will refer to \"/$b\" from the root?\n"},{"id":"184794","messageId":"4F3C2F3F.7000203@web.de","threadId":"29576","inReplyTo":"7vzkcl5f37.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 2/2] submodules: always use a relative path from gitdir to work tree","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-02-15T22:18:39Z","receivedAt":"2012-02-15T22:18:39Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 14.02.2012 21:34, schrieb Junio C Hamano:\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n>> Jens Lehmann <Jens.Lehmann@web.de> writes:\n>>\n>>> After adding a comment, using test instead of [], testing both $a and\n>>> $b and assigning each variable on it's own line I get the following\n>>> interdiff. Does that make more sense?\n>>\n>> My earlier request for comment was to say\n>>\n>> \t# $a is always longer than $b for such and such reasons\n>>\n>> to explain why testing $b without testing $a was sufficient.\n> \n> Heh, after I follow the entire module_clone, $gitdir is defined in earlier\n> parts of the function to be \"$(rev-parse --git-dir)/modules/$path\", so it\n> is clear that it is longer than $path.\n\nUnfortunately only by accident. The usage of $path is not correct here,\n$name should be used instead (I have a patch in the making to correct that,\nbut as that hits the same code area as these fixes I'll post that later\ntogether with some tests moving submodules around inside a superproject).\nThen the result of \"$(rev-parse --git-dir)/modules/$name\" can be shorter\nthan \"$path\" when a submodule is renamed into a higher directory level.\n\n> Unless \"cd $there && pwd\" does not\n> result in a funny situation (such as $something/modules is a symbolic link\n> to another place that is much closer to the root of the filesystem), that\n> is.\n> \n> And in such a case, the prefix part of $a and $b would be different from\n> the very beginning hopefully.\n\nYes, they should differ somewhere in any sane setup I can imagine.\n\n>> It is obvious (at least to me) that the loop continues as long as $a and\n>> $b begin with the same string before their first '/' and removes that\n>> common segment from both of them, so I do not think the new comment is\n>> absolutely necessary, but it would not hurt to have it, especially it is\n>> short enough and to the point.\n>>\n>> Thanks.\n>>\n>>> diff --git a/git-submodule.sh b/git-submodule.sh\n>>> index 3463d6d..ed76ce2 100755\n>>> --- a/git-submodule.sh\n>>> +++ b/git-submodule.sh\n>>> @@ -172,9 +172,11 @@ module_clone()\n>>>\n>>>         a=$(cd \"$gitdir\" && pwd)\n>>>         b=$(cd \"$path\" && pwd)\n>>> -       while [ \"$b\" ] && [ \"${a%%/*}\" = \"${b%%/*}\" ]\n>>> +       # Remove all common leading directories\n>>> +       while test -n \"$a\" && test -n \"$b\" && test \"${a%%/*}\" = \"${b%%/*}\"\n>>>         do\n>>> -               a=${a#*/} b=${b#*/};\n>>> +               a=${a#*/}\n>>> +               b=${b#*/}\n>>>         done\n>>>         rel=$(echo $a | sed -e 's|[^/]*|..|g')\n> \n> Perhaps aseert that $a never becomes empty before this line (or set it\n> explicitly to \".\" when $a is empty), as otherwise\n> \n>>>         (clear_local_git_env; cd \"$path\" && git config core.worktree \"$rel/$b\")\n> \n> this will refer to \"/$b\" from the root?\n\nI think neither $a nor $b should be empty after that. But thinking deeper\nabout that while loop I suspect the real problem here is doing \"a=${a#*/}\"\nor \"b=${b#*/}\" on a string that doesn't contain a slash anymore. We'll\nhappily remove a leading directory on the other path while the one without\nslash will stay untouched, leading to a bogus result which is off by one\ndirectory level.\n\nAFAICS that will only happen when one path is a prefix of the other, which\nis a pretty pathological case. So I'll whip up a new version asserting\nthat beforehand and dropping the -n test in the while loop, ok?\n"},{"id":"185462","messageId":"4F4A6DFA.5080709@kdbg.org","threadId":"29576","inReplyTo":"4F32F252.7050105@web.de","subject":"Re: [PATCH 0/2] submodules: Use relative paths to gitdir and work tree","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2012-02-26T17:38:02Z","receivedAt":"2012-02-26T17:38:02Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 08.02.2012 23:08, schrieb Jens Lehmann:\n> This patch series replaces all absolute paths pointing from submodule work\n> trees to its gitdir and back with relative paths as discussed in $gmane/187785.\n> \n> The motivation is to make superprojects movable again. They lost this ability\n> with the move of the git directory of submodules into the .git/modules directory\n> of the superproject. While fixing that a bug which would hit when moving the\n> submodule inside the superproject was also fixed.\n> \n> Jens Lehmann (2):\n>   submodules: always use a relative path to gitdir\n>   submodules: always use a relative path from gitdir to work tree\n\nThis series, with the tip at e3307adaba in Junio's repo causes major\nheadaches on Windows.\n\nFirst, a check for an absolute path must be extended to take\nWindows-style paths into account.\n\nSecond, the a's and b's are filled with different forms of absolute\npaths (/c/there vs. c:/there), and as a consequence the subsequent loops\ndo not find a suitable relative path.\n\nThe below is a minimal hack that passes all t/*submod* tests, but it\nworks only on Windows, where the pwd utility has an option -W that\nprints a Windows style absolute path.\n\nHow would you have this solved? One option would be to introduce a function\n\n  pwd() { builtin pwd -W \"$@\"; }\n\nin git-sh-setup conditionally on Windows (but that would affect other\nshell scripts, too).\n\nAny other ideas?\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 3463d6d..f37745e 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -139,8 +139,8 @@ module_clone()\n \tgitdir=\"$gitdir/modules/$path\"\n\n \tcase $gitdir in\n-\t/*)\n-\t\ta=\"$(cd_to_toplevel && pwd)/\"\n+\t/* | [a-z]:/*)\n+\t\ta=\"$(cd_to_toplevel && pwd -W)/\"\n \t\tb=$gitdir\n \t\twhile [ \"$b\" ] && [ \"${a%%/*}\" = \"${b%%/*}\" ]\n \t\tdo\n@@ -170,8 +170,8 @@ module_clone()\n\n \techo \"gitdir: $rel_gitdir\" >\"$path/.git\"\n\n-\ta=$(cd \"$gitdir\" && pwd)\n-\tb=$(cd \"$path\" && pwd)\n+\ta=$(cd \"$gitdir\" && pwd -W)\n+\tb=$(cd \"$path\" && pwd -W)\n \twhile [ \"$b\" ] && [ \"${a%%/*}\" = \"${b%%/*}\" ]\n \tdo\n \t\ta=${a#*/} b=${b#*/};\n-- \n1.7.8.216.g2e426\n"},{"id":"185467","messageId":"4F4A8EF2.3020901@web.de","threadId":"29576","inReplyTo":"4F4A6DFA.5080709@kdbg.org","subject":"Re: [PATCH 0/2] submodules: Use relative paths to gitdir and work tree","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-02-26T19:58:42Z","receivedAt":"2012-02-26T19:58:42Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 26.02.2012 18:38, schrieb Johannes Sixt:\n> Am 08.02.2012 23:08, schrieb Jens Lehmann:\n>> This patch series replaces all absolute paths pointing from submodule work\n>> trees to its gitdir and back with relative paths as discussed in $gmane/187785.\n>>\n>> The motivation is to make superprojects movable again. They lost this ability\n>> with the move of the git directory of submodules into the .git/modules directory\n>> of the superproject. While fixing that a bug which would hit when moving the\n>> submodule inside the superproject was also fixed.\n>>\n>> Jens Lehmann (2):\n>>   submodules: always use a relative path to gitdir\n>>   submodules: always use a relative path from gitdir to work tree\n> \n> This series, with the tip at e3307adaba in Junio's repo causes major\n> headaches on Windows.\n>\n> First, a check for an absolute path must be extended to take\n> Windows-style paths into account.\n\nOkay, but that check is not part of my series (it was introduced by 501770e1\n\"Move git-dir for submodules\", which is in Git since 1.7.8), so that looks\nlike it would need to be fixed for msysgit even without my patches, right?\n\nBut I'm not so happy about the two code paths there anyway, so I prepared a\npatch to replace them with a single code path based upon the paths computed\nin the last patch of this series. Please see the always-use-relative-gitdir\nbranch in my github repo https://github.com/jlehmann/git-submod-enhancements\n\n> Second, the a's and b's are filled with different forms of absolute\n> paths (/c/there vs. c:/there), and as a consequence the subsequent loops\n> do not find a suitable relative path.\n> \n> The below is a minimal hack that passes all t/*submod* tests, but it\n> works only on Windows, where the pwd utility has an option -W that\n> prints a Windows style absolute path.\n> \n> How would you have this solved? One option would be to introduce a function\n> \n>   pwd() { builtin pwd -W \"$@\"; }\n> \n> in git-sh-setup conditionally on Windows (but that would affect other\n> shell scripts, too).\n\nI suspect other shell scripts might be less affected when non-Windows\npaths are forced (at least when they aren't developed under Windows\nonly). What about something like this:\n\n  pwd() { builtin pwd -W \"$@\" | sed -e 's,^\\([a-z]\\):/,/\\1/,'; }\n\n> Any other ideas?\n> \n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index 3463d6d..f37745e 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -139,8 +139,8 @@ module_clone()\n>  \tgitdir=\"$gitdir/modules/$path\"\n>\n>  \tcase $gitdir in\n> -\t/*)\n> -\t\ta=\"$(cd_to_toplevel && pwd)/\"\n> +\t/* | [a-z]:/*)\n> +\t\ta=\"$(cd_to_toplevel && pwd -W)/\"\n>  \t\tb=$gitdir\n>  \t\twhile [ \"$b\" ] && [ \"${a%%/*}\" = \"${b%%/*}\" ]\n>  \t\tdo\n\nHmm, here the path which starts with \"c:/\" is returned by the \"git\nrev-parse --git-dir\" which is used to initialize the $gitdir variable\na few lines up.\n\n> @@ -170,8 +170,8 @@ module_clone()\n>\n>  \techo \"gitdir: $rel_gitdir\" >\"$path/.git\"\n>\n> -\ta=$(cd \"$gitdir\" && pwd)\n> -\tb=$(cd \"$path\" && pwd)\n> +\ta=$(cd \"$gitdir\" && pwd -W)\n> +\tb=$(cd \"$path\" && pwd -W)\n>  \twhile [ \"$b\" ] && [ \"${a%%/*}\" = \"${b%%/*}\" ]\n>  \tdo\n>  \t\ta=${a#*/} b=${b#*/};\n\nI don't understand why you need this. Does \"pwd\" sometimes return a\npath starting with \"c:/\" and sometimes \"/c/\" depending on what form\nyou use when you cd into that directory? If not, does the following\nhelp you on windows? (If that is the case, you might need the pwd\nredefinition too to make that work)\n\n-----------------8<--------------------\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 5deabf6..5bb8109 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -134,7 +134,7 @@ module_clone()\n        test -n \"$name\" || name=\"$path\"\n        base_path=$(dirname \"$path\")\n\n-       gitdir=$(git rev-parse --git-dir)\n+       gitdir=$(git rev-parse --git-dir | sed -e 's,^\\([a-z]\\):/,/\\1/,')\n        gitdir_base=\"$gitdir/modules/$base_path\"\n        gitdir=\"$gitdir/modules/$path\"\n"},{"id":"185563","messageId":"4F4BF357.8020407@kdbg.org","threadId":"29576","inReplyTo":"4F4A8EF2.3020901@web.de","subject":"Re: [PATCH 0/2] submodules: Use relative paths to gitdir and work tree","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2012-02-27T21:19:19Z","receivedAt":"2012-02-27T21:19:19Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 26.02.2012 20:58, schrieb Jens Lehmann:\n> Am 26.02.2012 18:38, schrieb Johannes Sixt:\n>> -\ta=$(cd \"$gitdir\" && pwd)\n>> -\tb=$(cd \"$path\" && pwd)\n>> +\ta=$(cd \"$gitdir\" && pwd -W)\n>> +\tb=$(cd \"$path\" && pwd -W)\n>>  \twhile [ \"$b\" ] && [ \"${a%%/*}\" = \"${b%%/*}\" ]\n>>  \tdo\n>>  \t\ta=${a#*/} b=${b#*/};\n> \n> I don't understand why you need this. Does \"pwd\" sometimes return a\n> path starting with \"c:/\" and sometimes \"/c/\" depending on what form\n> you use when you cd into that directory?\n\nIt looks like this is the case. I was surprised as well. I hoped that\npwd -P would fix it, but it makes no difference. I should have tested\npwd -L as well, but I forgot.\n\n> -       gitdir=$(git rev-parse --git-dir)\n> +       gitdir=$(git rev-parse --git-dir | sed -e 's,^\\([a-z]\\):/,/\\1/,')\n\nI don't like pipelines of this kind because they fork yet another\nprocess. But it looks like there are not that many alternatives...\n\n-- Hannes\n"},{"id":"185569","messageId":"alpine.DEB.1.00.1202271538230.3340@s15462909.onlinehome-server.info","threadId":"29576","inReplyTo":"4F4BF357.8020407@kdbg.org","subject":"Re: [msysGit] Re: [PATCH 0/2] submodules: Use relative paths to gitdir and work tree","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2012-02-27T21:41:52Z","receivedAt":"2012-02-27T21:41:52Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 27 Feb 2012, Johannes Sixt wrote:\n\n> Am 26.02.2012 20:58, schrieb Jens Lehmann:\n> \n> > -       gitdir=$(git rev-parse --git-dir)\n> > +       gitdir=$(git rev-parse --git-dir | sed -e 's,^\\([a-z]\\):/,/\\1/,')\n> \n> I don't like pipelines of this kind because they fork yet another\n> process. But it looks like there are not that many alternatives...\n\nNot many, but some rather straight-forward ones. E.g.\n\n\t# quoted to preserve tabs & newslines (Windows users are creative)\n\tgitdir=\"$(git rev-parse --git-dir)\"\n\tcase \"$gitdir\" in\n\t[A-Za-z]:*)\n\t\tgitdir=\"/${gitdir%%:*}${gitdir#?:}\"\n\t\t;;\n\tesac\n\nNote: untested.\n\nNote2: I did not add error handling, either.\n\nNote3: yes, ${...} is available in bash and it does not fork. Neither does\n       case ... esac\n\nCiao,\nJohannes\n"},{"id":"185649","messageId":"4F4D23D8.1050208@kdbg.org","threadId":"29576","inReplyTo":"4F4BF357.8020407@kdbg.org","subject":"Re: [msysGit] Re: [PATCH 0/2] submodules: Use relative paths to gitdir and work tree","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2012-02-28T18:58:32Z","receivedAt":"2012-02-28T18:58:32Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 27.02.2012 22:19, schrieb Johannes Sixt:\n> Am 26.02.2012 20:58, schrieb Jens Lehmann:\n>> I don't understand why you need this. Does \"pwd\" sometimes return a\n>> path starting with \"c:/\" and sometimes \"/c/\" depending on what form\n>> you use when you cd into that directory?\n> \n> It looks like this is the case. I was surprised as well. I hoped that\n> pwd -P would fix it, but it makes no difference. I should have tested\n> pwd -L as well, but I forgot.\n\npwd -L doesn't make a difference, either.\n\n>> -       gitdir=$(git rev-parse --git-dir)\n>> +       gitdir=$(git rev-parse --git-dir | sed -e 's,^\\([a-z]\\):/,/\\1/,')\n> \n> I don't like pipelines of this kind because they fork yet another\n> process. But it looks like there are not that many alternatives...\n\nWith the following patch on top of your always-use-relative-gitdir branch\nfrom https://github.com/jlehmann/git-submod-enhancements the tests pass\non Windows.\n\nThanks, Dscho, for pointing out the obvious.\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex e1984e0..953ca5e 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -151,6 +151,9 @@ module_clone()\n \n \ta=$(cd \"$gitdir\" && pwd)\n \tb=$(cd \"$path\" && pwd)\n+\t# normalize Windows-style absolute paths to POSIX-style absolute paths\n+\tcase $a in [a-zA-Z]:/*) a=/${a%%:*}${a#*:} esac\n+\tcase $b in [a-zA-Z]:/*) b=/${b%%:*}${b#*:} esac\n \t# Remove all common leading directories\n \twhile test -n \"$a\" && test -n \"$b\" && test \"${a%%/*}\" = \"${b%%/*}\"\n \tdo\n"},{"id":"185655","messageId":"7vehtezs6q.fsf@alter.siamese.dyndns.org","threadId":"29576","inReplyTo":"4F4D23D8.1050208@kdbg.org","subject":"Re: [msysGit] Re: [PATCH 0/2] submodules: Use relative paths to gitdir and work tree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-28T19:14:21Z","receivedAt":"2012-02-28T19:14:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> With the following patch on top of your always-use-relative-gitdir branch\n> from https://github.com/jlehmann/git-submod-enhancements the tests pass\n> on Windows.\n>\n> Thanks, Dscho, for pointing out the obvious.\n\nThe patch looks unintrusive and sane.\n\nThanks all three of you for looking into this.  Should I wait for a patch\nwith nice write-up from one of you, or should I just come up with a random\nmessage and apply it locally avoiding roundtrip cost?\n\n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index e1984e0..953ca5e 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -151,6 +151,9 @@ module_clone()\n>  \n>  \ta=$(cd \"$gitdir\" && pwd)\n>  \tb=$(cd \"$path\" && pwd)\n> +\t# normalize Windows-style absolute paths to POSIX-style absolute paths\n> +\tcase $a in [a-zA-Z]:/*) a=/${a%%:*}${a#*:} esac\n> +\tcase $b in [a-zA-Z]:/*) b=/${b%%:*}${b#*:} esac\n>  \t# Remove all common leading directories\n>  \twhile test -n \"$a\" && test -n \"$b\" && test \"${a%%/*}\" = \"${b%%/*}\"\n>  \tdo\n"},{"id":"185658","messageId":"4F4D291D.6000200@web.de","threadId":"29576","inReplyTo":"4F4D23D8.1050208@kdbg.org","subject":"Re: [msysGit] Re: [PATCH 0/2] submodules: Use relative paths to gitdir and work tree","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-02-28T19:21:01Z","receivedAt":"2012-02-28T19:21:01Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 28.02.2012 19:58, schrieb Johannes Sixt:\n> Am 27.02.2012 22:19, schrieb Johannes Sixt:\n>> Am 26.02.2012 20:58, schrieb Jens Lehmann:\n>>> -       gitdir=$(git rev-parse --git-dir)\n>>> +       gitdir=$(git rev-parse --git-dir | sed -e 's,^\\([a-z]\\):/,/\\1/,')\n>>\n>> I don't like pipelines of this kind because they fork yet another\n>> process. But it looks like there are not that many alternatives...\n> \n> With the following patch on top of your always-use-relative-gitdir branch\n> from https://github.com/jlehmann/git-submod-enhancements the tests pass\n> on Windows.\n> \n> Thanks, Dscho, for pointing out the obvious.\n\nThanks for helping to test and fix that on the Windows side. Do you want\nto post a commit based on the the interdiff below so I can apply it on\ntop of my branch? Then I would make this a four patch series in the next\nround.\n\n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index e1984e0..953ca5e 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -151,6 +151,9 @@ module_clone()\n>  \n>  \ta=$(cd \"$gitdir\" && pwd)\n>  \tb=$(cd \"$path\" && pwd)\n> +\t# normalize Windows-style absolute paths to POSIX-style absolute paths\n> +\tcase $a in [a-zA-Z]:/*) a=/${a%%:*}${a#*:} esac\n> +\tcase $b in [a-zA-Z]:/*) b=/${b%%:*}${b#*:} esac\n>  \t# Remove all common leading directories\n>  \twhile test -n \"$a\" && test -n \"$b\" && test \"${a%%/*}\" = \"${b%%/*}\"\n>  \tdo\n> \n"},{"id":"185662","messageId":"4F4D2C05.5070901@web.de","threadId":"29576","inReplyTo":"7vehtezs6q.fsf@alter.siamese.dyndns.org","subject":"Re: [msysGit] Re: [PATCH 0/2] submodules: Use relative paths to gitdir and work tree","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-02-28T19:33:25Z","receivedAt":"2012-02-28T19:33:25Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 28.02.2012 20:14, schrieb Junio C Hamano:\n> Johannes Sixt <j6t@kdbg.org> writes:\n> \n>> With the following patch on top of your always-use-relative-gitdir branch\n>> from https://github.com/jlehmann/git-submod-enhancements the tests pass\n>> on Windows.\n>>\n>> Thanks, Dscho, for pointing out the obvious.\n> \n> The patch looks unintrusive and sane.\n> \n> Thanks all three of you for looking into this.  Should I wait for a patch\n> with nice write-up from one of you, or should I just come up with a random\n> message and apply it locally avoiding roundtrip cost?\n\nThanks, but that interdiff needs all three patches from my branch to work\nproperly, while I only posted the first two here so far (without the third\none the gitfile still might contain the \"c:/\" notation even with J6t's diff\napplied). I still need to remove the iffiness of my 2/2 patch and the third\none needs a test case too before I can repost that series.\n\n>> diff --git a/git-submodule.sh b/git-submodule.sh\n>> index e1984e0..953ca5e 100755\n>> --- a/git-submodule.sh\n>> +++ b/git-submodule.sh\n>> @@ -151,6 +151,9 @@ module_clone()\n>>  \n>>  \ta=$(cd \"$gitdir\" && pwd)\n>>  \tb=$(cd \"$path\" && pwd)\n>> +\t# normalize Windows-style absolute paths to POSIX-style absolute paths\n>> +\tcase $a in [a-zA-Z]:/*) a=/${a%%:*}${a#*:} esac\n>> +\tcase $b in [a-zA-Z]:/*) b=/${b%%:*}${b#*:} esac\n>>  \t# Remove all common leading directories\n>>  \twhile test -n \"$a\" && test -n \"$b\" && test \"${a%%/*}\" = \"${b%%/*}\"\n>>  \tdo\n> \n"}]}