{"thread":{"id":"31213","subject":"Bug with git-submodule and IFS","startedAt":"2012-08-08T18:21:23Z","lastAt":"2012-08-08T19:08:17Z","messageCount":2,"participants":["Andrew Dranse","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"196682","messageId":"1844267106.216233.1344450083762.JavaMail.root@sms-zimbra-message-store-03.sms.scalar.ca","threadId":"31213","inReplyTo":"1496197024.216188.1344449732940.JavaMail.root@sms-zimbra-message-store-03.sms.scalar.ca","subject":"Bug with git-submodule and IFS","fromName":"Andrew Dranse","fromEmail":"adranse@oanda.com","sentAt":"2012-08-08T18:21:23Z","receivedAt":"2012-08-08T18:21:23Z","isPatch":false,"sender":{"key":"adranse@oanda.com","avatar":null},"body":"Hi there,\n\nI ran into an interesting bug with git submodules today.  It appears that if your IFS is not set to what git-submodule expects it to be (i.e. the standard IFS), it will break in a fun way.\n\nExample:\n\n$ git init\nInitialized empty Git repository in /home/adranse/test/.git/\n$ git submodule add github:/repos/perf\nCloning into 'perf'...\nremote: Counting objects: 5744, done.\nremote: Compressing objects: 100% (4627/4627), done.\nremote: Total 5744 (delta 2400), reused 1579 (delta 343)\nReceiving objects: 100% (5744/5744), 28.78 MiB | 4.56 MiB/s, done.\nResolving deltas: 100% (2400/2400), done.\n$ export IFS=\"\n> \"\n$ git submodule update --init --recursive\nNo submodule mapping found in .gitmodules for path ''\n$ unset IFS\n$ git submodule update --init --recursive\nSubmodule 'perf' () registered for path 'perf'\n\nAs a solution, I would suggest setting IFS to the expected value before calling the git-submodule shell script.\n\nThanks,\n\nAndrew Dranse\nOANDA Corporation\nadranse@oanda.com\n"},{"id":"196689","messageId":"7v628ttd5q.fsf@alter.siamese.dyndns.org","threadId":"31213","inReplyTo":"1844267106.216233.1344450083762.JavaMail.root@sms-zimbra-message-store-03.sms.scalar.ca","subject":"Re: Bug with git-submodule and IFS","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-08T19:08:17Z","receivedAt":"2012-08-08T19:08:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andrew Dranse <adranse@oanda.com> writes:\n\n> Hi there,\n>\n> I ran into an interesting bug with git submodules today.  It\n> appears that if your IFS is not set to what git-submodule expects\n> it to be (i.e. the standard IFS), it will break in a fun way.\n>\n> Example:\n>\n> $ git init\n> Initialized empty Git repository in /home/adranse/test/.git/\n> $ git submodule add github:/repos/perf\n> Cloning into 'perf'...\n> remote: Counting objects: 5744, done.\n> remote: Compressing objects: 100% (4627/4627), done.\n> remote: Total 5744 (delta 2400), reused 1579 (delta 343)\n> Receiving objects: 100% (5744/5744), 28.78 MiB | 4.56 MiB/s, done.\n> Resolving deltas: 100% (2400/2400), done.\n> $ export IFS=\"\n>> \"\n> $ git submodule update --init --recursive\n> No submodule mapping found in .gitmodules for path ''\n\nI do not think it is limited to \"git submodule\", and shell scripts\ngenerally, not limited to shell scripted Porcelain commands from the\nGit suite, assume that they can rely safely on words split at SP and\nHT.\n\nPerhaps something like this is a good solution for it.\n\n git-sh-setup.sh | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 770a86e..ee0e0bc 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -9,8 +9,12 @@\n # you would cause \"cd\" to be taken to unexpected places.  If you\n # like CDPATH, define it for your interactive shell sessions without\n # exporting it.\n+# But we protect ourselves from such a user mistake nevertheless.\n unset CDPATH\n \n+# Similarly for IFS\n+unset IFS\n+\n git_broken_path_fix () {\n \tcase \":$PATH:\" in\n \t*:$1:*) : ok ;;\n"}]}