git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] clone: detect and fail on excess parameters

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 23, 2008, 17:53 UTC
Message-ID
<7vfxtcsbis.fsf@gitster.siamese.dyndns.org>

"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
Next: SZEDER Gábor
Message 1 of 3 in “clone: detect and fail on excess parameters”
  1. clone: detect and fail on excess parametersJunio C Hamano, Apr 23, 2008
  2. SZEDER GáborApr 28, 2008
  3. Use "=" instead of "==" in condition as it is more portableAlex Riesen, Apr 28, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.