{"thread":{"id":"58863","subject":"making use of $sm_path @ git submodule foreach —recursive","startedAt":"2022-11-27T23:03:05Z","lastAt":"2022-11-28T14:19:16Z","messageCount":3,"participants":["signal@dynax.at","Ævar Arnfjörð Bjarmason"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"468053","messageId":"70ED2ECF-DAF1-4CCB-9E05-2599211F3569@dynax.at","threadId":"58863","inReplyTo":null,"subject":"making use of $sm_path @ git submodule foreach —recursive","fromName":"signal@dynax.at","fromEmail":"signal@dynax.at","sentAt":"2022-11-27T22:53:50Z","receivedAt":"2022-11-27T23:03:05Z","isPatch":false,"sender":{"key":"signal@dynax.at","avatar":null},"body":"Hi,\n\nwhen using \ngit submodule foreach —recursive [..] \n$sm_path contains only the relative part of the latest recursion. Since the command has no generic way of knowing from which recursion level it is executed any $sm_path of deeper recursion level is useless unless there is a way for the command to find out from which recursion it is called.\n\nI suggest $sm_path should be extended to be relative to the repo from where the submodule recursion started or another variable should contain the recursive part.\n\nViele Grüße/Cheers,\nHagen.\n"},{"id":"468081","messageId":"221128.86r0xnkzyw.gmgdl@evledraar.gmail.com","threadId":"58863","inReplyTo":"70ED2ECF-DAF1-4CCB-9E05-2599211F3569@dynax.at","subject":"Re: making use of $sm_path @ git submodule foreach —recursive","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-11-28T12:43:08Z","receivedAt":"2022-11-28T12:47:51Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Sun, Nov 27 2022, signal@dynax.at wrote:\n\n> Hi,\n>\n> when using \n> git submodule foreach —recursive [..] \n> $sm_path contains only the relative part of the latest\n> recursion. Since the command has no generic way of knowing from which\n> recursion level it is executed any $sm_path of deeper recursion level\n> is useless unless there is a way for the command to find out from\n> which recursion it is called.\n>\n> I suggest $sm_path should be extended to be relative to the repo from where the submodule recursion started or another variable should contain the recursive part.\n>\n> Viele Grüße/Cheers,\n> Hagen.\n\nI think it might be sensible to have a $super_prefix_sm_path or\nsomething which does what you suggest here.\n\nBut the current \"$sm_path\" is far from useless, it's just not useful for\nwhat you're trying to do.\n\nWhen we run a command in sub1/sub2 or whatever the \"$sm_path\" will be\n\"sub1\", then as we cd to \"sub1\" it'll be \"sub2\".\n\nYou want \"sub1/sub2\" there, but a \"sub2\" is still useful, because we've\nchdir()'d to the \"sub1\" at that point.\n\nSo you can e.g. run 'git -C \"$sm_path\" log' in your 'foreach', or\nanother command that expects to get the *relative* submodule path.\n\nIf we simply changed how \"$sm_path\" works that would break, and if we\n\"fixed\" that by not chdir()-ing from the super-project we'd break even\nmore things, as e.g.:\n\n\tgit submodule foreach 'git pull'\n\nOr whatever wouldn't behave as you'd expect.\n"},{"id":"468102","messageId":"DEE63B3B-95B2-469B-AC02-CAC1B5FCAC67@dynax.at","threadId":"58863","inReplyTo":"221128.86r0xnkzyw.gmgdl@evledraar.gmail.com","subject":"Re: making use of $sm_path @ git submodule foreach —recursive","fromName":"signal@dynax.at","fromEmail":"signal@dynax.at","sentAt":"2022-11-28T14:18:57Z","receivedAt":"2022-11-28T14:19:16Z","isPatch":false,"sender":{"key":"signal@dynax.at","avatar":null},"body":"Oh, thanks! I didn’t notice that it chdir’ed into the submodule folder! Then clearly this is the relation I was looking for!\nThanks! sorry for the noise!\n\n> On 28.11.2022, at 13:43, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> \n> \n> On Sun, Nov 27 2022, signal@dynax.at wrote:\n> \n>> Hi,\n>> \n>> when using \n>> git submodule foreach —recursive [..] \n>> $sm_path contains only the relative part of the latest\n>> recursion. Since the command has no generic way of knowing from which\n>> recursion level it is executed any $sm_path of deeper recursion level\n>> is useless unless there is a way for the command to find out from\n>> which recursion it is called.\n>> \n>> I suggest $sm_path should be extended to be relative to the repo from where the submodule recursion started or another variable should contain the recursive part.\n>> \n>> Viele Grüße/Cheers,\n>> Hagen.\n> \n> I think it might be sensible to have a $super_prefix_sm_path or\n> something which does what you suggest here.\n> \n> But the current \"$sm_path\" is far from useless, it's just not useful for\n> what you're trying to do.\n> \n> When we run a command in sub1/sub2 or whatever the \"$sm_path\" will be\n> \"sub1\", then as we cd to \"sub1\" it'll be \"sub2\".\n> \n> You want \"sub1/sub2\" there, but a \"sub2\" is still useful, because we've\n> chdir()'d to the \"sub1\" at that point.\n> \n> So you can e.g. run 'git -C \"$sm_path\" log' in your 'foreach', or\n> another command that expects to get the *relative* submodule path.\n> \n> If we simply changed how \"$sm_path\" works that would break, and if we\n> \"fixed\" that by not chdir()-ing from the super-project we'd break even\n> more things, as e.g.:\n> \n> \tgit submodule foreach 'git pull'\n> \n> Or whatever wouldn't behave as you'd expect.\n\n"}]}