All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH] clone: detect and fail on excess parameters
Date: Wed, 23 Apr 2008 10:53:47 -0700	[thread overview]
Message-ID: <7vfxtcsbis.fsf@gitster.siamese.dyndns.org> (raw)

"git clone [options] $src $dst excess-garbage" simply ignored
excess-garbage without giving any diagnostic message.  Fix it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * 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(-)

diff --git a/git-clone.sh b/git-clone.sh
index 2636159..9e433c0 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -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
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
new file mode 100755
index 0000000..dc9d63d
--- /dev/null
+++ b/t/t5601-clone.sh
@@ -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

             reply	other threads:[~2008-04-23 17:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-23 17:53 Junio C Hamano [this message]
2008-04-28 16:36 ` [PATCH] clone: detect and fail on excess parameters SZEDER Gábor
2008-04-28 21:09   ` [PATCH] Use "=" instead of "==" in condition as it is more portable Alex Riesen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vfxtcsbis.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.