clone: detect and fail on excess parameters
PATCH 1/1 clone: detect and fail on excess parameters
"git clone [options] $src $dst excess-garbage" simply ignored excess-garbage without giving any diagnostic message. Fix it.
---
* I noticed it while trying "git clone --reference $there $src $dst" with various combinations of options, and in one case I errorneously removed "--reference" without removing $there. It happily created a clone of the reference repository under a funnily named directory whose name looked like a URL.
git-clone.sh | 1 + t/t5601-clone.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 0 deletions(-)
git-clone.sh +1 -0
@@ -219,6 +219,7 @@ fi if test -n "$2" then dir="$2" + test $# == 2 || die "excess parameter to git-clone" else # Derive one from the repository name # Try using "humanish" part of source repo if user didn't specify one
t/t5601-clone.sh new file +26 -0
@@ -0,0 +1,26 @@ +#!/bin/sh + +test_description=clone + +. ./test-lib.sh + +test_expect_success setup ' + + rm -fr .git && + test_create_repo src && + ( + cd src + >file + git add file + git commit -m initial + ) + +' + +test_expect_success 'clone with excess parameters' ' + + test_must_fail git clone -n "file://$(pwd)/src" dst junk + +' + +test_done
Hi,
git-clone.sh fi · line 222
Quoted 12 lines · Junio C Hamano
"git clone [options] $src $dst excess-garbage" simply ignored excess-garbage without giving any diagnostic message. Fix it.
Signed-off-by Junio C Hamano <[email protected]>[...]git-clone.sh +1
-0@@ -219,6 +219,7 @@ fi if test -n "$2" then dir="$2" + test $# == 2 || die "excess parameter to git-clone"
^^
I think you mean:
test $# = 2 || die "excess parameter to git-clone"
I just noticed because it broke t1020-subdirectory at me.
Best,
Gábor
PATCH 1/1 Use "=" instead of "==" in condition as it is more portable
At least the dash from Ubuntu's /bin/sh says:
test: 233: ==: unexpected operator
---
SZEDER Gábor, Mon, Apr 28, 2008 18:36:42 +0200:
Quoted 12 lines · Junio C Hamano
Review
Quoted 5 lines
"git clone [options] $src $dst excess-garbage" simply ignored excess-garbage without giving any diagnostic message. Fix it.
(quoted diff) +1
-0dir="$2" + test $# == 2 || die "excess parameter to git-clone"^^I think you mean:
test $# = 2 || die "excess parameter to git-clone"I just noticed because it broke t1020-subdirectory at me.
And me. Almost every test which uses git-clone (I expect some don't test its exit code in setup routines).
git-clone.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
git-clone.sh +1 -1
@@ -219,7 +219,7 @@ fi if test -n "$2" then dir="$2" - test $# == 2 || die "excess parameter to git-clone" + test $# = 2 || die "excess parameter to git-clone" else # Derive one from the repository name # Try using "humanish" part of source repo if user didn't specify one
Signature · 1 line
1.5.5.1.118.g6dd1b6.dirty