{"thread":{"id":"13231","subject":"[PATCH] clone: detect and fail on excess parameters","startedAt":"2008-04-23T17:53:47Z","lastAt":"2008-04-28T21:09:55Z","messageCount":3,"participants":["Junio C Hamano","SZEDER Gábor","Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"75080","messageId":"7vfxtcsbis.fsf@gitster.siamese.dyndns.org","threadId":"13231","inReplyTo":null,"subject":"[PATCH] clone: detect and fail on excess parameters","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-04-23T17:53:47Z","receivedAt":"2008-04-23T17:53:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"git clone [options] $src $dst excess-garbage\" simply ignored\nexcess-garbage without giving any diagnostic message.  Fix it.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * I noticed it while trying \"git clone --reference $there $src $dst\" with\n   various combinations of options, and in one case I errorneously removed\n   \"--reference\" without removing $there.  It happily created a clone of\n   the reference repository under a funnily named directory whose name\n   looked like a URL.\n\n git-clone.sh     |    1 +\n t/t5601-clone.sh |   26 ++++++++++++++++++++++++++\n 2 files changed, 27 insertions(+), 0 deletions(-)\n\ndiff --git a/git-clone.sh b/git-clone.sh\nindex 2636159..9e433c0 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -219,6 +219,7 @@ fi\n if test -n \"$2\"\n then\n \tdir=\"$2\"\n+\ttest $# == 2 || die \"excess parameter to git-clone\"\n else\n \t# Derive one from the repository name\n \t# Try using \"humanish\" part of source repo if user didn't specify one\ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nnew file mode 100755\nindex 0000000..dc9d63d\n--- /dev/null\n+++ b/t/t5601-clone.sh\n@@ -0,0 +1,26 @@\n+#!/bin/sh\n+\n+test_description=clone\n+\n+. ./test-lib.sh\n+\n+test_expect_success setup '\n+\n+\trm -fr .git &&\n+\ttest_create_repo src &&\n+\t(\n+\t\tcd src\n+\t\t>file\n+\t\tgit add file\n+\t\tgit commit -m initial\n+\t)\n+\n+'\n+\n+test_expect_success 'clone with excess parameters' '\n+\n+\ttest_must_fail git clone -n \"file://$(pwd)/src\" dst junk\n+\n+'\n+\n+test_done\n"},{"id":"75400","messageId":"20080428163642.GA22790@neumann","threadId":"13231","inReplyTo":"7vfxtcsbis.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] clone: detect and fail on excess parameters","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2008-04-28T16:36:42Z","receivedAt":"2008-04-28T16:36:42Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\nOn Wed, Apr 23, 2008 at 10:53:47AM -0700, Junio C Hamano wrote:\n> \"git clone [options] $src $dst excess-garbage\" simply ignored\n> excess-garbage without giving any diagnostic message.  Fix it.\n> \n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> [...]\n> --- a/git-clone.sh\n> +++ b/git-clone.sh\n> @@ -219,6 +219,7 @@ fi\n>  if test -n \"$2\"\n>  then\n>  \tdir=\"$2\"\n> +\ttest $# == 2 || die \"excess parameter to git-clone\"\n                ^^\nI think you mean:\n\n    test $# = 2 || die \"excess parameter to git-clone\"\n\nI just noticed because it broke t1020-subdirectory at me.\n\n\nBest,\nGábor\n"},{"id":"75456","messageId":"20080428210955.GB10600@steel.home","threadId":"13231","inReplyTo":"20080428163642.GA22790@neumann","subject":"[PATCH] Use \"=\" instead of \"==\" in condition as it is more portable","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-04-28T21:09:55Z","receivedAt":"2008-04-28T21:09:55Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"At least the dash from Ubuntu's /bin/sh says:\n\n    test: 233: ==: unexpected operator\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\nSZEDER Gábor, Mon, Apr 28, 2008 18:36:42 +0200:\n> On Wed, Apr 23, 2008 at 10:53:47AM -0700, Junio C Hamano wrote:\n> > \"git clone [options] $src $dst excess-garbage\" simply ignored\n> > excess-garbage without giving any diagnostic message.  Fix it.\n> > \n> >  \tdir=\"$2\"\n> > +\ttest $# == 2 || die \"excess parameter to git-clone\"\n>                 ^^\n> I think you mean:\n> \n>     test $# = 2 || die \"excess parameter to git-clone\"\n> \n> I just noticed because it broke t1020-subdirectory at me.\n\nAnd me. Almost every test which uses git-clone (I expect some don't\ntest its exit code in setup routines).\n\n git-clone.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-clone.sh b/git-clone.sh\nindex 9e433c0..8c7fc7f 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -219,7 +219,7 @@ fi\n if test -n \"$2\"\n then\n \tdir=\"$2\"\n-\ttest $# == 2 || die \"excess parameter to git-clone\"\n+\ttest $# = 2 || die \"excess parameter to git-clone\"\n else\n \t# Derive one from the repository name\n \t# Try using \"humanish\" part of source repo if user didn't specify one\n-- \n1.5.5.1.118.g6dd1b6.dirty\n"}]}