{"thread":{"id":"31906","subject":"[PATCH] git-submodule add: Record branch name in .gitmodules","startedAt":"2012-10-22T16:34:43Z","lastAt":"2012-10-26T13:37:42Z","messageCount":12,"participants":["W. Trevor King","Nahor","Jens Lehmann","Phil Hord","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"201705","messageId":"61a31f6bc61d4df322a097e32ba472390c583a81.1350923683.git.wking@tremily.us","threadId":"31906","inReplyTo":null,"subject":"[PATCH] git-submodule add: Record branch name in .gitmodules","fromName":"W. Trevor King","fromEmail":"wking@tremily.us","sentAt":"2012-10-22T16:34:43Z","receivedAt":"2012-10-22T16:34:43Z","isPatch":true,"sender":{"key":"wking@tremily.us","avatar":"https://avatars.githubusercontent.com/u/209920?v=4"},"body":"From: \"W. Trevor King\" <wking@tremily.us>\n\nThis removes a configuration step if you're trying to setup Ævar's\n\n  $ git submodule foreach 'git checkout $(git config --file $toplevel/.gitmodules submodule.$name.branch) && git pull'\n\nworkflow from\n\n  commit f030c96d8643fa0a1a9b2bd9c2f36a77721fb61f\n  Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n  Date:   Fri May 21 16:10:10 2010 +0000\n\n    git-submodule foreach: Add $toplevel variable\n\nIf you're not using that workflow, I see no harm in recording the\nbranch used to determine the original submodule commit.\n\nSigned-off-by: W. Trevor King <wking@tremily.us>\n---\n Documentation/git-submodule.txt | 3 ++-\n git-submodule.sh                | 4 ++++\n t/t7400-submodule-basic.sh      | 1 +\n 3 files changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex b4683bb..b9f437f 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -207,7 +207,8 @@ OPTIONS\n \n -b::\n --branch::\n-\tBranch of repository to add as submodule.\n+\tBranch of repository to add as submodule.  The branch name is\n+\trecorded in .gitmodules for future reference.\n \n -f::\n --force::\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex ab6b110..fd15a54 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -366,6 +366,10 @@ Use -f if you really want to add it.\" >&2\n \n \tgit config -f .gitmodules submodule.\"$sm_path\".path \"$sm_path\" &&\n \tgit config -f .gitmodules submodule.\"$sm_path\".url \"$repo\" &&\n+\tif test -n \"$branch\"\n+\tthen\n+\t\tgit config -f .gitmodules submodule.\"$sm_path\".branch \"$branch\"\n+\tfi &&\n \tgit add --force .gitmodules ||\n \tdie \"$(eval_gettext \"Failed to register submodule '\\$sm_path'\")\"\n }\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 5397037..5031e2a 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -133,6 +133,7 @@ test_expect_success 'submodule add --branch' '\n \t(\n \t\tcd addtest &&\n \t\tgit submodule add -b initial \"$submodurl\" submod-branch &&\n+\t\ttest \"$(git config -f .gitmodules submodule.submod-branch.branch)\" = initial &&\n \t\tgit submodule init\n \t) &&\n \n-- \n1.8.0.2.g09b91ca\n"},{"id":"201834","messageId":"20121022225546.GO23101@odin.tremily.us","threadId":"31906","inReplyTo":"CABURp0pqg7XC6makK2OcundMabV9AtcBNGNK6Q0TMZfJbt3anw@mail.gmail.com","subject":"Re: [PATCH] git-submodule add: Record branch name in .gitmodules","fromName":"W. Trevor King","fromEmail":"wking@tremily.us","sentAt":"2012-10-22T22:55:46Z","receivedAt":"2012-10-22T22:55:46Z","isPatch":true,"sender":{"key":"wking@tremily.us","avatar":"https://avatars.githubusercontent.com/u/209920?v=4"},"body":"On Mon, Oct 22, 2012 at 06:03:53PM -0400, Phil Hord wrote:\n> Some projects now use the 'branch' config value to record the tracking\n> branch for the submodule.  Some ascribe different meaning to the\n> configuration if the value is given vs. undefined.  For example, see\n> the Gerrit submodule-subscription mechanism.  This change will cause\n> those workflows to behave differently than they do now.\n\nFor those to lazy to hunt down a reference, Gerrit uses\nsubmodule.$name.branch to\n\n  “indicate the branch of a submodule project that when updated will\n  trigger automatic update of its registered gitlink.” [1]\n\nThey also have some extra sauce:\n\n  “The branch value could be '.' if the submodule project branch has\n  the same name as the destination branch of the commit having\n  gitlinks/.gitmodules file.\n  …\n  Any git submodules which are added and not have the branch field\n  available in the .gitmodules file will not be subscribed by Gerrit\n  to automatically update the superproject.”\n\n> I do like the idea, but I wish it had a different name for the\n> recording.  Maybe --record-branch=${BRANCH} as an extra switch so the\n> action is explicitly requested.\n> \n>   git submodule add --branch=master --record-branch=master foo bar\n\nUgh, I don't want to retype the branch name whenever I do this.\n\n<brainstorming>\n\nHow about -r/--record, with the recorded name being optional?\n\n  --record-branch[=<recorded_name>]\n\nThis would satisfy Gerrit users that wanted to use '.', but also\nsatisfy me with:\n\n  git submodule add -rb=master foo bar\n\nHowever, there is a change that people would see that, and then use\n\n  git submodule add -r -b=master foo bar\n\nwhich would checkout the HEAD from foo and store `-b=master` in\nsubmodule.$name.branch.\n\nA more verbose, but less dangerous, option would be a boolean\n-r/--record that enables the recording of whatever was passed to\n-b/--branch.  This looses the flexibility of running something like\n\n  git submodule add --branch=master --record-branch=. foo bar\n\nbut the Gerrit folks have gotten along OK without any branch recording\nso far ;).  They can keep setting '.' the same way they always have.\n\n</brainstorming>\n\nOn a tangentially related note, it would be nice to set environment\nvariables for each of the settings in submodule.$name during a foreach\ncall.  Then you could use\n\n  git submodule foreach 'git checkout $branch && git pull'\n\nPerhaps you'd want to blacklist/whitelist or downcase settings names\nto avoid things like\n\n  [submodule \"foo\"]\n        PATH = /my/rootkit/\n\nbut the update line is much cleaner.\n\nCheers,\nTrevor\n\n[1]: https://gerrit.googlesource.com/gerrit/+/master/Documentation/user-submodules.txt\n\n-- \nThis email may be signed or encrypted with GnuPG (http://www.gnupg.org).\nFor more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy\n"},{"id":"201745","messageId":"5086ED06.5020406@gmail.com","threadId":"31906","inReplyTo":"61a31f6bc61d4df322a097e32ba472390c583a81.1350923683.git.wking@tremily.us","subject":"Re: [PATCH] git-submodule add: Record branch name in .gitmodules","fromName":"Nahor","fromEmail":"nahor.j+gmane@gmail.com","sentAt":"2012-10-23T19:16:22Z","receivedAt":"2012-10-23T19:16:22Z","isPatch":true,"sender":{"key":"nahor.j+gmane@gmail.com","avatar":null},"body":"On 2012-10-22 09:34, W. Trevor King wrote:\n> From: \"W. Trevor King\" <wking@tremily.us>\n>\n> This removes a configuration step if you're trying to setup Ævar's\n>\n>    $ git submodule foreach 'git checkout $(git config --file $toplevel/.gitmodules submodule.$name.branch) && git pull'\n>\n> workflow from\n>\n>    commit f030c96d8643fa0a1a9b2bd9c2f36a77721fb61f\n>    Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>    Date:   Fri May 21 16:10:10 2010 +0000\n>\n>      git-submodule foreach: Add $toplevel variable\n>\n> If you're not using that workflow, I see no harm in recording the\n> branch used to determine the original submodule commit.\n\nIMHO, the problem is that this works only for a very specific workflow. \nNormal git usage can very easily break this feature.\n\nFor instance, the module may later be updated to a commit in branch B \ninstead of branch A. Unless you remember to also update .gitmodule, you \nhave then inconsistent information.\n\nA similar issue arises if branch A is deleted from the module later (for \ninstance because it has been merged in the master branch and is not \nuseful anymore). Then .gitmodule points to a non-existant branch.\nSame thing if a branch is renamed.\n\nLast issue, the branch that exists in your local repository may not \nexist in someone else's repository, either because the branch is purely \nlocal, or because it has a different name on the remote repo.\n\n\nI think a better place to store that kind of information is using \ngit-notes. That way, if the branch is renamed or deleted, you can easily \nupdate the old notes to use the new name instead.\n\n\n\tNahor\n"},{"id":"201751","messageId":"20121023194436.GD28592@odin.tremily.us","threadId":"31906","inReplyTo":"5086ED06.5020406@gmail.com","subject":"Re: [PATCH] git-submodule add: Record branch name in .gitmodules","fromName":"W. Trevor King","fromEmail":"wking@tremily.us","sentAt":"2012-10-23T19:44:36Z","receivedAt":"2012-10-23T19:44:36Z","isPatch":true,"sender":{"key":"wking@tremily.us","avatar":"https://avatars.githubusercontent.com/u/209920?v=4"},"body":"On Tue, Oct 23, 2012 at 12:16:22PM -0700, Nahor wrote:\n> On 2012-10-22 09:34, W. Trevor King wrote:\n> For instance, the module may later be updated to a commit in branch B \n> instead of branch A. Unless you remember to also update .gitmodule, you \n> have then inconsistent information.\n\nBut you're explicitly *using* the configured setting in\n\n  git config --file $toplevel/.gitmodules submodule.$name.branch\n\nThat should be a reminder that the configuration is important, and\nyou'll remember to change it.  Plus, the text from git-pull should\nclearly display the branch you are pulling, which gives you a second\nchange to notice if something is going wrong.\n\n> A similar issue arises if branch A is deleted from the module later (for \n> instance because it has been merged in the master branch and is not \n> useful anymore). Then .gitmodule points to a non-existant branch.\n> Same thing if a branch is renamed.\n\nAll of these are possible, and all would reqire manual intervention to\npick out a new branch to follow.  Plus, this patch is not even about\nthe auto-pull application, it's about storing the initially cloned\nbranch name.  What you do with that name afterwards is up to you ;).\n\n> I think a better place to store that kind of information is using \n> git-notes. That way, if the branch is renamed or deleted, you can easily \n> update the old notes to use the new name instead.\n\nInteresting.  What would you attach the note too?\n\nTrevor\n\n-- \nThis email may be signed or encrypted with GnuPG (http://www.gnupg.org).\nFor more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy\n"},{"id":"201748","messageId":"5086FFDC.2050700@web.de","threadId":"31906","inReplyTo":"5086ED06.5020406@gmail.com","subject":"Re: [PATCH] git-submodule add: Record branch name in .gitmodules","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-10-23T20:36:44Z","receivedAt":"2012-10-23T20:36:44Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 23.10.2012 21:16, schrieb Nahor:\n> On 2012-10-22 09:34, W. Trevor King wrote:\n>> From: \"W. Trevor King\" <wking@tremily.us>\n>>\n>> This removes a configuration step if you're trying to setup Ævar's\n>>\n>>    $ git submodule foreach 'git checkout $(git config --file $toplevel/.gitmodules submodule.$name.branch) && git pull'\n>>\n>> workflow from\n>>\n>>    commit f030c96d8643fa0a1a9b2bd9c2f36a77721fb61f\n>>    Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>>    Date:   Fri May 21 16:10:10 2010 +0000\n>>\n>>      git-submodule foreach: Add $toplevel variable\n>>\n>> If you're not using that workflow, I see no harm in recording the\n>> branch used to determine the original submodule commit.\n\nExcept recording the branch name might raise expectations about what git\nwill do with it. And as far as this patch goes, git won't do anything\nwith it (yet).\n\n> IMHO, the problem is that this works only for a very specific workflow. Normal git usage can very easily break this feature.\n> \n> For instance, the module may later be updated to a commit in branch B instead of branch A. Unless you remember to also update .gitmodule, you have then inconsistent information.\n> \n> A similar issue arises if branch A is deleted from the module later (for instance because it has been merged in the master branch and is not useful anymore). Then .gitmodule points to a non-existant branch.\n> Same thing if a branch is renamed.\n\nThose are valid points. The next \"git submodule update\" will leave the\nsubmodule with a detached HEAD, making the branch configuration rather\nmeaningless (except for your \"git submodule foreach ...\" use case of\ncourse).\n\n> Last issue, the branch that exists in your local repository may not exist in someone else's repository, either because the branch is purely local, or because it has a different name on the remote repo.\n\nYou'll always face this kind of problems with commits too when using\nsubmodules, so I don't see that as a problem here.\n\n> I think a better place to store that kind of information is using git-notes. That way, if the branch is renamed or deleted, you can easily update the old notes to use the new name instead.\n\nI can't comment on that, as I have never been using notes so far.\n\nBut I'd rather see a patch series properly implementing the always-tip\nmode Ævar mentions in f030c96d86 (and which is requested by some users),\nespecially the interesting parts: What should git record as commit in\nthat case and how are \"git status\" and \"git diff\" going to handle\nsubmodules which shall follow a specific branch. I assume \"git submodule\nupdate\" is the right point in time to fetch that branch again and check\nout a newer branch tip if necessary, but should that commit be added to\nthe superproject for that submodule automagically or not? This patch\nfalls short of this, as it does the easy part but not the interesting\nones ;-)\n"},{"id":"201762","messageId":"20121023205524.GF28592@odin.tremily.us","threadId":"31906","inReplyTo":"5086FFDC.2050700@web.de","subject":"Re: [PATCH] git-submodule add: Record branch name in .gitmodules","fromName":"W. Trevor King","fromEmail":"wking@tremily.us","sentAt":"2012-10-23T20:55:24Z","receivedAt":"2012-10-23T20:55:24Z","isPatch":true,"sender":{"key":"wking@tremily.us","avatar":"https://avatars.githubusercontent.com/u/209920?v=4"},"body":"On Tue, Oct 23, 2012 at 10:36:44PM +0200, Jens Lehmann wrote:\n> Except recording the branch name might raise expectations about what git\n> will do with it. And as far as this patch goes, git won't do anything\n> with it (yet).\n\nAs Phil pointed out, doing anything with this variable is ambiguous:\n\nOn Mon, Oct 22, 2012 at 06:03:53PM -0400, Phil Hord wrote:\n> Some projects now use the 'branch' config value to record the tracking\n> branch for the submodule.  Some ascribe different meaning to the\n> configuration if the value is given vs. undefined.  For example, see\n> the Gerrit submodule-subscription mechanism.  This change will cause\n> those workflows to behave differently than they do now.\n\nOn Tue, Oct 23, 2012 at 10:36:44PM +0200, Jens Lehmann wrote:\n> But I'd rather see a patch series properly implementing the always-tip\n> mode Ævar mentions in f030c96d86 (and which is requested by some users),\n> especially the interesting parts: What should git record as commit in\n> that case and how are \"git status\" and \"git diff\" going to handle\n> submodules which shall follow a specific branch. I assume \"git submodule\n> update\" is the right point in time to fetch that branch again and check\n> out a newer branch tip if necessary, but should that commit be added to\n> the superproject for that submodule automagically or not? This patch\n> falls short of this, as it does the easy part but not the interesting\n> ones ;-)\n\nI agree that I'm not working on always-tip.  I'm just making that\neasier.  For people that aren't interested in always-tip submodules\n(e.g. Gerrit folks), this patch is still useful.  It would certainly\nbe possible to build an always-tip implementation on top of\nsubmodule.$name.branch (as Ævar's one-liner does), but that would be\nanother patch series.\n\nPersonally, I think truly updates should be made explicitly, with a\nhand written commit message about why the updates are occuring.  I\nalso think that setting up and running auto-updates should be easy\none-liners, not long, complicated ones ;).\n\n-- \nThis email may be signed or encrypted with GnuPG (http://www.gnupg.org).\nFor more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy\n"},{"id":"201760","messageId":"50871014.9060000@gmail.com","threadId":"31906","inReplyTo":"20121023194436.GD28592@odin.tremily.us","subject":"Re: [PATCH] git-submodule add: Record branch name in .gitmodules","fromName":"Nahor","fromEmail":"nahor.j+gmane@gmail.com","sentAt":"2012-10-23T21:45:56Z","receivedAt":"2012-10-23T21:45:56Z","isPatch":true,"sender":{"key":"nahor.j+gmane@gmail.com","avatar":null},"body":"On 2012-10-23 12:44, W. Trevor King wrote:\n> On Tue, Oct 23, 2012 at 12:16:22PM -0700, Nahor wrote:\n>> On 2012-10-22 09:34, W. Trevor King wrote:\n>> For instance, the module may later be updated to a commit in branch B\n>> instead of branch A. Unless you remember to also update .gitmodule, you\n>> have then inconsistent information.\n>\n> But you're explicitly *using* the configured setting in\n>\n>    git config --file $toplevel/.gitmodules submodule.$name.branch\n>\n> That should be a reminder that the configuration is important, and\n> you'll remember to change it.\n\n From my experience with my colleagues at work, that's not going to \nhappen. People are very good at forgetting to do something ;)\n\n\n> Plus, the text from git-pull should\n> clearly display the branch you are pulling, which gives you a second\n> change to notice if something is going wrong.\n\nThat's assuming that the user knows the branch that should be pulled and \nthat he's paying attention to the output and not just quick-scanning for \nerrors/warnings.\nAgain, from my experience, that's not going to be the case.\n\nPlus, there isn't always a human being behind a git-pull, e.g. build bots.\n\n\n>> I think a better place to store that kind of information is using\n>> git-notes. That way, if the branch is renamed or deleted, you can easily\n>> update the old notes to use the new name instead.\n>\n> Interesting.  What would you attach the note too?\n\nTo the commits in the super-repo where a module branch is selected, i.e.:\n- where a module was added\n- where the module changed branch\n- where a super-branch was merged and there was a conflict on the \nmodule's branch name\n"},{"id":"201764","messageId":"508713DE.7040801@gmail.com","threadId":"31906","inReplyTo":"5086FFDC.2050700@web.de","subject":"Re: [PATCH] git-submodule add: Record branch name in .gitmodules","fromName":"Nahor","fromEmail":"nahor.j+gmane@gmail.com","sentAt":"2012-10-23T22:02:06Z","receivedAt":"2012-10-23T22:02:06Z","isPatch":true,"sender":{"key":"nahor.j+gmane@gmail.com","avatar":null},"body":"On 2012-10-23 13:36, Jens Lehmann wrote:\n> Am 23.10.2012 21:16, schrieb Nahor:\n>> Last issue, the branch that exists in your local repository may not\n >> exist in someone else's repository, either because the branch is\n >> purely local, or because it has a different name on the remote repo.\n>\n> You'll always face this kind of problems with commits too when using\n> submodules, so I don't see that as a problem here.\n\nCommits can't change or disappear during \"normal\" git operation (i.e. \nwithout using \"git push -f\" or \"git branch -D\").\nA commit also has the same id in all the clones repository so there is \nno issue of a different name between the local and the remote repositories.\n"},{"id":"201817","messageId":"CABURp0rpPqeTJMYXmgMG2CmU=SzzvCMeX46rnMVB0EeB_LXPiA@mail.gmail.com","threadId":"31906","inReplyTo":"20121022225546.GO23101@odin.tremily.us","subject":"Re: [PATCH] git-submodule add: Record branch name in .gitmodules","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2012-10-24T18:12:18Z","receivedAt":"2012-10-24T18:12:18Z","isPatch":true,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"On Mon, Oct 22, 2012 at 6:55 PM, W. Trevor King <wking@tremily.us> wrote:\n> On a tangentially related note, it would be nice to set environment\n> variables for each of the settings in submodule.$name during a foreach\n> call.  Then you could use\n>\n>   git submodule foreach 'git checkout $branch && git pull'\n>\n> Perhaps you'd want to blacklist/whitelist or downcase settings names\n> to avoid things like\n>\n>   [submodule \"foo\"]\n>         PATH = /my/rootkit/\n>\n> but the update line is much cleaner.\n\nThis is ugly as can be, but it works in my meagre testing.  It defines\n\"submodule_path=/my/rootkit/\" for the above bit of .gitmodules.  That\nis, it adds definitions for 'submodule_<var-name>' for each <var-name>\nin .gitmodules in submodule.$name.<var-name>, but <var-name> is\nlowercased and defanged (everything that's not already [a-z0-9] is\nreplaced with underscore).  For example,\n\n  git submodule foreach 'echo $submodule_url'\n\n--- >8 ---\ndiff --git c/git-submodule.sh i/git-submodule.sh\nindex 6dd2338..79b3467 100755\n--- c/git-submodule.sh\n+++ i/git-submodule.sh\n@@ -416,7 +416,15 @@ cmd_foreach()\n                                prefix=\"$prefix$sm_path/\"\n                                clear_local_git_env\n                                # we make $path available to scripts ...\n                                path=$sm_path\n+\n+                               # make all submodule variables\navailable to scripts\n+                               eval $(git config -f .gitmodules\n--get-regexp \"^submodule\\.${name}\\..*\" |\n+                               sed -e \"s|^submodule\\.${name}\\.||\" |\n+                               while read VAR_NAME VAR_VALUE ; do\n+                                       VAR_NAME=$(printf '%s'\n\"$VAR_NAME\" | tr A-Z a-z | sed -e 's/^[^a-z]/_/' -e 's/[^a-z0-9]/_/g')\n+                                       printf 'submodule_%s=%s;\\n'\n\"$VAR_NAME\" \"'$VAR_VALUE'\"\n+                               done)\n                                cd \"$sm_path\" &&\n                                eval \"$@\" &&\n                                if test -n \"$recursive\"\n"},{"id":"201820","messageId":"50883D31.6080705@web.de","threadId":"31906","inReplyTo":"508713DE.7040801@gmail.com","subject":"Re: [PATCH] git-submodule add: Record branch name in .gitmodules","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-10-24T19:10:41Z","receivedAt":"2012-10-24T19:10:41Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 24.10.2012 00:02, schrieb Nahor:\n> On 2012-10-23 13:36, Jens Lehmann wrote:\n>> Am 23.10.2012 21:16, schrieb Nahor:\n>>> Last issue, the branch that exists in your local repository may not\n>>> exist in someone else's repository, either because the branch is\n>>> purely local, or because it has a different name on the remote repo.\n>>\n>> You'll always face this kind of problems with commits too when using\n>> submodules, so I don't see that as a problem here.\n> \n> Commits can't change or disappear during \"normal\" git operation (i.e. without using \"git push -f\" or \"git branch -D\").\n> A commit also has the same id in all the clones repository so there is no issue of a different name between the local and the remote repositories.\n\nBut if you forget to push a submodule commit it won't exist in someone\nelse's repository and so he won't be able to update the submodule after\nchecking out a commit in the superproject that records that unpushed\nsubmodule commit.\n"},{"id":"201835","messageId":"20121025011227.GH801@odin.tremily.us","threadId":"31906","inReplyTo":"CABURp0rpPqeTJMYXmgMG2CmU=SzzvCMeX46rnMVB0EeB_LXPiA@mail.gmail.com","subject":"Re: [PATCH] git-submodule add: Record branch name in .gitmodules","fromName":"W. Trevor King","fromEmail":"wking@tremily.us","sentAt":"2012-10-25T01:12:27Z","receivedAt":"2012-10-25T01:12:27Z","isPatch":true,"sender":{"key":"wking@tremily.us","avatar":"https://avatars.githubusercontent.com/u/209920?v=4"},"body":"On Wed, Oct 24, 2012 at 02:12:18PM -0400, Phil Hord wrote:\n> +                                       VAR_NAME=$(printf '%s'\n> \"$VAR_NAME\" | tr A-Z a-z | sed -e 's/^[^a-z]/_/' -e 's/[^a-z0-9]/_/g')\n\nIs there a reason why you use printf instead of echo?\n\nAlso, this sort of name cleaning should probably live in a new\nfunction:\n\n  clean_environment_variable()\n\nor some such.  Is there a git-utility-functions.sh library hiding\nsomewhere in the source? ;)\n\n-- \nThis email may be signed or encrypted with GnuPG (http://www.gnupg.org).\nFor more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy\n"},{"id":"201945","messageId":"20121026133742.GA10829@sigill.intra.peff.net","threadId":"31906","inReplyTo":"20121025011227.GH801@odin.tremily.us","subject":"Re: [PATCH] git-submodule add: Record branch name in .gitmodules","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-10-26T13:37:42Z","receivedAt":"2012-10-26T13:37:42Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Oct 24, 2012 at 09:12:27PM -0400, W. Trevor King wrote:\n\n> On Wed, Oct 24, 2012 at 02:12:18PM -0400, Phil Hord wrote:\n> > +                                       VAR_NAME=$(printf '%s'\n> > \"$VAR_NAME\" | tr A-Z a-z | sed -e 's/^[^a-z]/_/' -e 's/[^a-z0-9]/_/g')\n> \n> Is there a reason why you use printf instead of echo?\n\nSadly, echo is not entirely portable for arbitrary content. We have run\ninto problems with backslashes being interpreted differently (bash\nrequires \"echo -e\" to interpret them, dash will always do it, and POSIX\nleaves it vague).\n\n> Also, this sort of name cleaning should probably live in a new\n> function:\n> \n>   clean_environment_variable()\n> \n> or some such.  Is there a git-utility-functions.sh library hiding\n> somewhere in the source? ;)\n\ngit-sh-setup?\n\n-Peff\n"}]}