{"thread":{"id":"9369","subject":"git shell scripts flaw wrt dirty env","startedAt":"2007-08-03T20:14:05Z","lastAt":"2007-08-06T23:16:24Z","messageCount":3,"participants":["Pierre Habouzit","Gerrit Pape","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"49622","messageId":"20070803201405.GB12430@artemis.corp","threadId":"9369","inReplyTo":null,"subject":"git shell scripts flaw wrt dirty env","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-08-03T20:14:05Z","receivedAt":"2007-08-03T20:14:05Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"\n  I recently had an issue with git-rebase, and actually git-am, kind of\nhard to track down. After some hassle to understand what was going on,\nit happened that for an idiotic reason (me trying a fancy new login\nmanager for X that didn't cleansed environment before staring X) made\nall my env dirty. In particular it had $resume (in small letters) set to\n/dev/sda5, and git-am happens to use the very same variable, without\ncleansing the environment.\n\n  I'm maybe completely out of luck, and that's the sole unsafe use of\nvariables in git shell scripts, but I don't think so, and maybe some\nkind of failsafe could be used. A crude way is to call:\n\n  unset `env | cut -d= -f1 | grep -v [A-Z]`\n\n  at the beginning of every script, so that every lowercase-only\nvariables are unset, hence can be safely used. But it's completely\ntasteless. Though, as it can really lead to _very_ odd bugs, well, I\njust wanted to share the issue. For the curious, you can read on [0]\nwhat the issue looked like for me...\n\n\n  [0] http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=38;bug=435807#38\n\nCheers,\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"50021","messageId":"20070806141530.10422.qmail@8bd9c2a0b9ecab.315fe32.mid.smarden.org","threadId":"9369","inReplyTo":"20070803201405.GB12430@artemis.corp","subject":"[PATCH] git-am: initialize variable $resume on startup","fromName":"Gerrit Pape","fromEmail":"pape@smarden.org","sentAt":"2007-08-06T14:15:30Z","receivedAt":"2007-08-06T14:15:30Z","isPatch":true,"sender":{"key":"pape@smarden.org","avatar":"https://avatars.githubusercontent.com/u/143170252?v=4"},"body":"git-am expects the variable $resume to be empty or unset, which might not\nbe the case if $resume is set in the user's environment.  So initialize\nit to an empty value on startup.\n\nThe problem was noticed by Pierre Habouzit and reported through\n http://bugs.debian.org/435807\n\nSigned-off-by: Gerrit Pape <pape@smarden.org>\n---\n git-am.sh |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 6cf0eee..b5ed8ca 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -103,7 +103,8 @@ It does not apply to blobs recorded in its index.\"\n }\n \n prec=4\n-dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= resolvemsg=\n+dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary=\n+resolvemsg= resume=\n git_apply_opt=\n \n while case \"$#\" in 0) break;; esac\n-- \n1.5.3.GIT\n"},{"id":"50057","messageId":"7vlkco9ruf.fsf@assigned-by-dhcp.cox.net","threadId":"9369","inReplyTo":"20070806141530.10422.qmail@8bd9c2a0b9ecab.315fe32.mid.smarden.org","subject":"Re: [PATCH] git-am: initialize variable $resume on startup","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-06T23:16:24Z","receivedAt":"2007-08-06T23:16:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.\n"}]}