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

[PATCH 1/3] remote: add a test for extra arguments, according to docs

From
Thomas Rast <trast@inf.ethz.ch>
Date
Apr 24, 2013, 13:54 UTC
Message-ID
<372aa93e4a7a3583730c02543583ce93e095ec64.1366811347.git.trast@inf.ethz.ch>
In-Reply-To
<cover.1366811347.git.trast@inf.ethz.ch>

This adds one test or comment for each subcommand of git-remote according to its current documentation. All but 'set-branches' and 'update' are listed as taking only a fixed number of arguments; for those we can write a test with one more (bogus) argument, and see if the command notices that.

They fail on several counts: 'add' does not check for extra arguments, and 'show' and 'prune' actually iterate over remotes (i.e., take any number of args). We'll fix them in the next two patches.

The -f machinery is only there to make the tests readable while still ensuring they pass as a whole, and will be removed in the final patch.

Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
---
 t/t5505-remote.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 6579a86..764ee97 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -1003,4 +1003,31 @@ test_expect_success 'remote set-url --delete baz' '
 	cmp expect actual
 '
 
+test_expect_success 'extra args: setup' '
+	# add a dummy origin so that this does not trigger failure
+	git remote add origin .
+'
+
+test_extra_arg () {
+	expect="success"
+	if test "z$1" = "z-f"; then
+		expect=failure
+		shift
+	fi
+	test_expect_$expect "extra args: $*" "
+		test_must_fail git remote $* bogus_extra_arg 2>actual &&
+		grep '^usage:' actual
+	"
+}
+
+test_extra_arg -f add nick url
+test_extra_arg rename origin newname
+test_extra_arg remove origin
+test_extra_arg set-head origin master
+# set-branches takes any number of args
+test_extra_arg set-url origin newurl oldurl
+test_extra_arg -f show origin
+test_extra_arg -f prune origin
+# update takes any number of args
+
 test_done
-- 
1.8.2.1.931.g0116868
Previous: Thomas RastNext: Junio C Hamano
Message 2 of 7 in “git remote with superfluous arguments”
  1. 0/3 git remote with superfluous argumentsThomas Rast, Apr 24, 2013
  2. 1/3 remote: add a test for extra arguments, according to docsThomas Rast, Apr 24, 2013
  3. Junio C HamanoApr 24, 2013
  4. Thomas RastApr 25, 2013
  5. Junio C HamanoApr 25, 2013
  6. 2/3 remote: check for superfluous arguments in 'git remote add'Thomas Rast, Apr 24, 2013
  7. 3/3 remote: 'show' and 'prune' take more than one remoteThomas Rast, Apr 24, 2013

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.