threads / patch / 63751

v2, 7 partsmove builtin help test to t1517

Subject: [PATCH v2 0/7] move builtin help test to t1517

## tl;dr

53 messages between Jul 6, 2025 and Aug 30, 2025. Diffs are folded; open one to read it.

replies: 52people: 4as markdown or json

Usman Akinyemi· Jul 6, 2025, 21:41 UTC · lore

In patch series which contain this "[*]: 43a8391977 (builtin/verify-tag: stop using `the_repository`, 2025-03-07)" and some other builtin commands, the help test was added into their respective test files. Since it better fits thats tests that check command behavior outside a repository should be in t/t1517-outside-repo.sh. Patrick suggest moving the test to t/t1517-outside-repo.sh.

This patch series moved the all the test.
Changes since v1:
  - Fix some typo
Usman Akinyemi (7):
  t/t1517: move checkout-index -h test to t1517
  t/t1517: move for-each-ref -h test to t1517
  t/t1517: move ls-files -h test to t1517
  t/t1517: move pack-refs -h test to t1517
  t/t1517: move send-pack -h test to t1517
  t/t1517: move verify-commit -h test to t1517
  t/t1517: move verify-tag -h test to t1517
 t/t0610-reftable-basics.sh      |  7 -----
 t/t1517-outside-repo.sh         | 49 +++++++++++++++++++++++++++++++++
 t/t2006-checkout-index-basic.sh |  7 -----
 t/t3004-ls-files-basic.sh       |  7 -----
 t/t5400-send-pack.sh            |  7 -----
 t/t6300-for-each-ref.sh         |  7 -----
 t/t7030-verify-tag.sh           |  7 -----
 t/t7510-signed-commit.sh        |  7 -----
 8 files changed, 49 insertions(+), 49 deletions(-)
-- 
2.50.0
Usman Akinyemi· Jul 6, 2025, 21:41 UTC · re: Usman Akinyemi · lore

[PATCH v2 1/7] t/t1517: move checkout-index -h test to t1517

The test 'checkout-index does not crash with -h' checks that the command exits cleanly with usage information, both inside and outside of a repository.

Move this test from "t2006-checkout-index-basic.sh" to "t1517-outside-repo.sh" since it better fits with tests that check command behavior outside a repository.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh         | 7 +++++++
 t/t2006-checkout-index-basic.sh | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 2 files +7 −7

t/t1517-outside-repo.sh, t/t2006-checkout-index-basic.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 6824581317..98a453db58 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -114,4 +114,11 @@ test_expect_success 'update-server-info does not crash with -h' '
 	test_grep "[Uu]sage: git update-server-info " usage
 '
 
+test_expect_success 'checkout-index does not crash with -h' '
+	test_expect_code 129 git checkout-index -h >usage &&Add commentMore actions
+	test_grep "[Uu]sage: git checkout-index " usage &&
+	test_expect_code 129 nongit git checkout-index -h >usage &&
+	test_grep "[Uu]sage: git checkout-index " usage
+'
+
 test_done
diff --git a/t/t2006-checkout-index-basic.sh b/t/t2006-checkout-index-basic.sh
index fedd2cc097..bac231b167 100755
--- a/t/t2006-checkout-index-basic.sh
+++ b/t/t2006-checkout-index-basic.sh
@@ -21,13 +21,6 @@ test_expect_success 'checkout-index -h in broken repository' '
 	test_grep "[Uu]sage" broken/usage
 '
 
-test_expect_success 'checkout-index does not crash with -h' '
-	test_expect_code 129 git checkout-index -h >usage &&
-	test_grep "[Uu]sage: git checkout-index " usage &&
-	test_expect_code 129 nongit git checkout-index -h >usage &&
-	test_grep "[Uu]sage: git checkout-index " usage
-'
-
 test_expect_success 'checkout-index reports errors (cmdline)' '
 	test_must_fail git checkout-index -- does-not-exist 2>stderr &&
 	test_grep not.in.the.cache stderr
-- 
2.50.0
Usman Akinyemi· Jul 6, 2025, 21:41 UTC · re: Usman Akinyemi · lore

[PATCH v2 2/7] t/t1517: move for-each-ref -h test to t1517

The test 'for-each-ref does not crash with -h' checks that the command exits cleanly with usage information, both inside and outside of a repository.

Move this test from "t6300-for-each-ref.sh" to "t1517-outside-repo.sh" since it better fits with tests that check command behavior outside a repository.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh | 7 +++++++
 t/t6300-for-each-ref.sh | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 2 files +7 −7

t/t1517-outside-repo.sh, t/t6300-for-each-ref.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 98a453db58..92ad159b58 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -121,4 +121,11 @@ test_expect_success 'checkout-index does not crash with -h' '
 	test_grep "[Uu]sage: git checkout-index " usage
 '
 
+test_expect_success 'for-each-ref does not crash with -h' '
+	test_expect_code 129 git for-each-ref -h >usage &&
+	test_grep "[Uu]sage: git for-each-ref " usage &&
+	test_expect_code 129 nongit git for-each-ref -h >usage &&
+	test_grep "[Uu]sage: git for-each-ref " usage
+'
+
 test_done
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index ce9af79ab1..5db7038c41 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -292,13 +292,6 @@ test_expect_success 'Check invalid atoms names are errors' '
 	test_must_fail git for-each-ref --format="%(INVALID)" refs/heads
 '
 
-test_expect_success 'for-each-ref does not crash with -h' '
-	test_expect_code 129 git for-each-ref -h >usage &&
-	test_grep "[Uu]sage: git for-each-ref " usage &&
-	test_expect_code 129 nongit git for-each-ref -h >usage &&
-	test_grep "[Uu]sage: git for-each-ref " usage
-'
-
 test_expect_success 'Check format specifiers are ignored in naming date atoms' '
 	git for-each-ref --format="%(authordate)" refs/heads &&
 	git for-each-ref --format="%(authordate:default) %(authordate)" refs/heads &&
-- 
2.50.0
Usman Akinyemi· Jul 6, 2025, 21:41 UTC · re: Usman Akinyemi · lore

[PATCH v2 3/7] t/t1517: move ls-files -h test to t1517

The test 'ls-files does not crash with -h' checks that the command exits cleanly with usage information, both inside and outside of a repository.

Move this test from "t3004-ls-files-basic.sh" to "t1517-outside-repo.sh" since it better fits with tests that check command behavior outside a repository.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh   | 7 +++++++
 t/t3004-ls-files-basic.sh | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 2 files +7 −7

t/t1517-outside-repo.sh, t/t3004-ls-files-basic.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 92ad159b58..e04be2d811 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -128,4 +128,11 @@ test_expect_success 'for-each-ref does not crash with -h' '
 	test_grep "[Uu]sage: git for-each-ref " usage
 '
 
+test_expect_success 'ls-files does not crash with -h' '
+	test_expect_code 129 git ls-files -h >usage &&
+	test_grep "[Uu]sage: git ls-files " usage &&
+	test_expect_code 129 nongit git ls-files -h >usage &&
+	test_grep "[Uu]sage: git ls-files " usage
+'
+
 test_done
diff --git a/t/t3004-ls-files-basic.sh b/t/t3004-ls-files-basic.sh
index 4034a5a59f..a1078f8701 100755
--- a/t/t3004-ls-files-basic.sh
+++ b/t/t3004-ls-files-basic.sh
@@ -34,13 +34,6 @@ test_expect_success 'ls-files -h in corrupt repository' '
 	test_grep "[Uu]sage: git ls-files " broken/usage
 '
 
-test_expect_success 'ls-files does not crash with -h' '
-	test_expect_code 129 git ls-files -h >usage &&
-	test_grep "[Uu]sage: git ls-files " usage &&
-	test_expect_code 129 nongit git ls-files -h >usage &&
-	test_grep "[Uu]sage: git ls-files " usage
-'
-
 test_expect_success SYMLINKS 'ls-files with absolute paths to symlinks' '
 	mkdir subs &&
 	ln -s nosuch link &&
-- 
2.50.0
Usman Akinyemi· Jul 6, 2025, 21:41 UTC · re: Usman Akinyemi · lore

[PATCH v2 4/7] t/t1517: move pack-refs -h test to t1517

The test 'pack-refs does not crash with -h' checks that the command exits cleanly with usage information, both inside and outside of a repository.

Move this test from "t0610-reftable-basics.sh" to "t1517-outside-repo.sh" since it better fits with tests that check command behavior outside a repository.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t0610-reftable-basics.sh | 7 -------
 t/t1517-outside-repo.sh    | 7 +++++++
 2 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 2 files +7 −7

t/t0610-reftable-basics.sh, t/t1517-outside-repo.sh

diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh
index 3ea5d51532..ffd8ecc0ce 100755
--- a/t/t0610-reftable-basics.sh
+++ b/t/t0610-reftable-basics.sh
@@ -14,13 +14,6 @@ export GIT_TEST_DEFAULT_REF_FORMAT
 
 INVALID_OID=$(test_oid 001)
 
-test_expect_success 'pack-refs does not crash with -h' '
-	test_expect_code 129 git pack-refs -h >usage &&
-	test_grep "[Uu]sage: git pack-refs " usage &&
-	test_expect_code 129 nongit git pack-refs -h >usage &&
-	test_grep "[Uu]sage: git pack-refs " usage
-'
-
 test_expect_success 'init: creates basic reftable structures' '
 	test_when_finished "rm -rf repo" &&
 	git init repo &&
diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index e04be2d811..5b4373f8cd 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -135,4 +135,11 @@ test_expect_success 'ls-files does not crash with -h' '
 	test_grep "[Uu]sage: git ls-files " usage
 '
 
+test_expect_success 'pack-refs does not crash with -h' '
+	test_expect_code 129 git pack-refs -h >usage &&
+	test_grep "[Uu]sage: git pack-refs " usage &&
+	test_expect_code 129 nongit git pack-refs -h >usage &&
+	test_grep "[Uu]sage: git pack-refs " usage
+'
+
 test_done
-- 
2.50.0
Usman Akinyemi· Jul 6, 2025, 21:41 UTC · re: Usman Akinyemi · lore

[PATCH v2 5/7] t/t1517: move send-pack -h test to t1517

The test 'send-pack does not crash with -h' checks that the command exits cleanly with usage information, both inside and outside of a repository.

Move this test from "t/t5400-send-pack.sh" to "t1517-outside-repo.sh" since it better fits with tests that check command behavior outside a repository.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh | 7 +++++++
 t/t5400-send-pack.sh    | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 2 files +7 −7

t/t1517-outside-repo.sh, t/t5400-send-pack.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 5b4373f8cd..a140b5cc38 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -142,4 +142,11 @@ test_expect_success 'pack-refs does not crash with -h' '
 	test_grep "[Uu]sage: git pack-refs " usage
 '
 
+test_expect_success 'send-pack does not crash with -h' '
+	test_expect_code 129 git send-pack -h >usage &&
+	test_grep "[Uu]sage: git send-pack " usage &&
+	test_expect_code 129 nongit git send-pack -h >usage &&
+	test_grep "[Uu]sage: git send-pack " usage
+'
+
 test_done
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 83b42ff073..571e8f1bc5 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -55,13 +55,6 @@ test_expect_success setup '
 	echo Rebase &&
 	git log'
 
-test_expect_success 'send-pack does not crash with -h' '
-	test_expect_code 129 git send-pack -h >usage &&
-	test_grep "[Uu]sage: git send-pack " usage &&
-	test_expect_code 129 nongit git send-pack -h >usage &&
-	test_grep "[Uu]sage: git send-pack " usage
-'
-
 test_expect_success 'pack the source repository' '
 	git repack -a -d &&
 	git prune
-- 
2.50.0
Usman Akinyemi· Jul 6, 2025, 21:41 UTC · re: Usman Akinyemi · lore

[PATCH v2 6/7] t/t1517: move verify-commit -h test to t1517

The test 'verify-commit does not crash with -h' checks that the command exits cleanly with usage information, both inside and outside of a repository.

Move this test from "t/t7510-signed-commit.sh" to "t1517-outside-repo.sh" since it better fits with tests that check command behavior outside a repository.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh  | 7 +++++++
 t/t7510-signed-commit.sh | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 2 files +7 −7

t/t1517-outside-repo.sh, t/t7510-signed-commit.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index a140b5cc38..42381ef7eb 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -149,4 +149,11 @@ test_expect_success 'send-pack does not crash with -h' '
 	test_grep "[Uu]sage: git send-pack " usage
 '
 
+test_expect_success 'verify-commit does not crash with -h' '
+	test_expect_code 129 git verify-commit -h >usage &&
+	test_grep "[Uu]sage: git verify-commit " usage &&
+	test_expect_code 129 nongit git verify-commit -h >usage &&
+	test_grep "[Uu]sage: git verify-commit " usage
+'
+
 test_done
diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index 39677e859a..0d2dd29fe6 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -8,13 +8,6 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 GNUPGHOME_NOT_USED=$GNUPGHOME
 . "$TEST_DIRECTORY/lib-gpg.sh"
 
-test_expect_success GPG 'verify-commit does not crash with -h' '
-	test_expect_code 129 git verify-commit -h >usage &&
-	test_grep "[Uu]sage: git verify-commit " usage &&
-	test_expect_code 129 nongit git verify-commit -h >usage &&
-	test_grep "[Uu]sage: git verify-commit " usage
-'
-
 test_expect_success GPG 'create signed commits' '
 	test_oid_cache <<-\EOF &&
 	header sha1:gpgsig
-- 
2.50.0
Usman Akinyemi· Jul 6, 2025, 21:41 UTC · re: Usman Akinyemi · lore

[PATCH v2 7/7] t/t1517: move verify-tag -h test to t1517

The test 'verify-tag does not crash with -h' checks that the command exits cleanly with usage information, both inside and outside of a repository.

Move this test from "t/t7030-verify-tag.sh" to "t1517-outside-repo.sh" since it better fits with tests that check command behavior outside a repository.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh | 7 +++++++
 t/t7030-verify-tag.sh   | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 2 files +7 −7

t/t1517-outside-repo.sh, t/t7030-verify-tag.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 42381ef7eb..0755757d86 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -156,4 +156,11 @@ test_expect_success 'verify-commit does not crash with -h' '
 	test_grep "[Uu]sage: git verify-commit " usage
 '
 
+test_expect_success 'verify-tag does not crash with -h' '
+	test_expect_code 129 git verify-tag -h >usage &&
+	test_grep "[Uu]sage: git verify-tag " usage &&
+	test_expect_code 129 nongit git verify-tag -h >usage &&
+	test_grep "[Uu]sage: git verify-tag " usage
+'
+
 test_done
diff --git a/t/t7030-verify-tag.sh b/t/t7030-verify-tag.sh
index 2c147072c1..6f526c37c2 100755
--- a/t/t7030-verify-tag.sh
+++ b/t/t7030-verify-tag.sh
@@ -7,13 +7,6 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 . ./test-lib.sh
 . "$TEST_DIRECTORY/lib-gpg.sh"
 
-test_expect_success GPG 'verify-tag does not crash with -h' '
-	test_expect_code 129 git verify-tag -h >usage &&
-	test_grep "[Uu]sage: git verify-tag " usage &&
-	test_expect_code 129 nongit git verify-tag -h >usage &&
-	test_grep "[Uu]sage: git verify-tag " usage
-'
-
 test_expect_success GPG 'create signed tags' '
 	echo 1 >file && git add file &&
 	test_tick && git commit -m initial &&
-- 
2.50.0
Usman Akinyemi· Jul 6, 2025, 21:50 UTC · re: Usman Akinyemi · lore

In patch series which contain this "[*]: 43a8391977 (builtin/verify-tag: stop using `the_repository`, 2025-03-07)" and some other builtin commands, the help test was added into their respective test files. Since it better fits thats tests that check command behavior outside a repository should be in t/t1517-outside-repo.sh. Patrick suggest moving the test to t/t1517-outside-repo.sh.

This patch series moved the all the test.
Changes since v3:
  - Fix the typo which I thought I was able to fix in v2
Usman Akinyemi (7):
  t/t1517: move checkout-index -h test to t1517
  t/t1517: move for-each-ref -h test to t1517
  t/t1517: move ls-files -h test to t1517
  t/t1517: move pack-refs -h test to t1517
  t/t1517: move send-pack -h test to t1517
  t/t1517: move verify-commit -h test to t1517
  t/t1517: move verify-tag -h test to t1517
 t/t0610-reftable-basics.sh      |  7 -----
 t/t1517-outside-repo.sh         | 49 +++++++++++++++++++++++++++++++++
 t/t2006-checkout-index-basic.sh |  7 -----
 t/t3004-ls-files-basic.sh       |  7 -----
 t/t5400-send-pack.sh            |  7 -----
 t/t6300-for-each-ref.sh         |  7 -----
 t/t7030-verify-tag.sh           |  7 -----
 t/t7510-signed-commit.sh        |  7 -----
 8 files changed, 49 insertions(+), 49 deletions(-)
-- 
2.50.0
Usman Akinyemi· Jul 6, 2025, 21:50 UTC · re: Usman Akinyemi · lore

[PATCH v3 1/7] t/t1517: move checkout-index -h test to t1517

The test 'checkout-index does not crash with -h' checks that the command exits cleanly with usage information, both inside and outside of a repository.

Move this test from "t2006-checkout-index-basic.sh" to "t1517-outside-repo.sh" since it better fits with tests that check command behavior outside a repository.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh         | 7 +++++++
 t/t2006-checkout-index-basic.sh | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 2 files +7 −7

t/t1517-outside-repo.sh, t/t2006-checkout-index-basic.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 6824581317..9e54214725 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -114,4 +114,11 @@ test_expect_success 'update-server-info does not crash with -h' '
 	test_grep "[Uu]sage: git update-server-info " usage
 '
 
+test_expect_success 'checkout-index does not crash with -h' '
+	test_expect_code 129 git checkout-index -h >usage &&
+	test_grep "[Uu]sage: git checkout-index " usage &&
+	test_expect_code 129 nongit git checkout-index -h >usage &&
+	test_grep "[Uu]sage: git checkout-index " usage
+'
+
 test_done
diff --git a/t/t2006-checkout-index-basic.sh b/t/t2006-checkout-index-basic.sh
index fedd2cc097..bac231b167 100755
--- a/t/t2006-checkout-index-basic.sh
+++ b/t/t2006-checkout-index-basic.sh
@@ -21,13 +21,6 @@ test_expect_success 'checkout-index -h in broken repository' '
 	test_grep "[Uu]sage" broken/usage
 '
 
-test_expect_success 'checkout-index does not crash with -h' '
-	test_expect_code 129 git checkout-index -h >usage &&
-	test_grep "[Uu]sage: git checkout-index " usage &&
-	test_expect_code 129 nongit git checkout-index -h >usage &&
-	test_grep "[Uu]sage: git checkout-index " usage
-'
-
 test_expect_success 'checkout-index reports errors (cmdline)' '
 	test_must_fail git checkout-index -- does-not-exist 2>stderr &&
 	test_grep not.in.the.cache stderr
-- 
2.50.0
Usman Akinyemi· Jul 6, 2025, 21:50 UTC · re: Usman Akinyemi · lore

[PATCH v3 2/7] t/t1517: move for-each-ref -h test to t1517

The test 'for-each-ref does not crash with -h' checks that the command exits cleanly with usage information, both inside and outside of a repository.

Move this test from "t6300-for-each-ref.sh" to "t1517-outside-repo.sh" since it better fits with tests that check command behavior outside a repository.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh | 7 +++++++
 t/t6300-for-each-ref.sh | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 2 files +7 −7

t/t1517-outside-repo.sh, t/t6300-for-each-ref.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 9e54214725..d3487acbfc 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -121,4 +121,11 @@ test_expect_success 'checkout-index does not crash with -h' '
 	test_grep "[Uu]sage: git checkout-index " usage
 '
 
+test_expect_success 'for-each-ref does not crash with -h' '
+	test_expect_code 129 git for-each-ref -h >usage &&
+	test_grep "[Uu]sage: git for-each-ref " usage &&
+	test_expect_code 129 nongit git for-each-ref -h >usage &&
+	test_grep "[Uu]sage: git for-each-ref " usage
+'
+
 test_done
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index ce9af79ab1..5db7038c41 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -292,13 +292,6 @@ test_expect_success 'Check invalid atoms names are errors' '
 	test_must_fail git for-each-ref --format="%(INVALID)" refs/heads
 '
 
-test_expect_success 'for-each-ref does not crash with -h' '
-	test_expect_code 129 git for-each-ref -h >usage &&
-	test_grep "[Uu]sage: git for-each-ref " usage &&
-	test_expect_code 129 nongit git for-each-ref -h >usage &&
-	test_grep "[Uu]sage: git for-each-ref " usage
-'
-
 test_expect_success 'Check format specifiers are ignored in naming date atoms' '
 	git for-each-ref --format="%(authordate)" refs/heads &&
 	git for-each-ref --format="%(authordate:default) %(authordate)" refs/heads &&
-- 
2.50.0
Usman Akinyemi· Jul 6, 2025, 21:50 UTC · re: Usman Akinyemi · lore

[PATCH v3 3/7] t/t1517: move ls-files -h test to t1517

The test 'ls-files does not crash with -h' checks that the command exits cleanly with usage information, both inside and outside of a repository.

Move this test from "t3004-ls-files-basic.sh" to "t1517-outside-repo.sh" since it better fits with tests that check command behavior outside a repository.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh   | 7 +++++++
 t/t3004-ls-files-basic.sh | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 2 files +7 −7

t/t1517-outside-repo.sh, t/t3004-ls-files-basic.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index d3487acbfc..206b9e118c 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -128,4 +128,11 @@ test_expect_success 'for-each-ref does not crash with -h' '
 	test_grep "[Uu]sage: git for-each-ref " usage
 '
 
+test_expect_success 'ls-files does not crash with -h' '
+	test_expect_code 129 git ls-files -h >usage &&
+	test_grep "[Uu]sage: git ls-files " usage &&
+	test_expect_code 129 nongit git ls-files -h >usage &&
+	test_grep "[Uu]sage: git ls-files " usage
+'
+
 test_done
diff --git a/t/t3004-ls-files-basic.sh b/t/t3004-ls-files-basic.sh
index 4034a5a59f..a1078f8701 100755
--- a/t/t3004-ls-files-basic.sh
+++ b/t/t3004-ls-files-basic.sh
@@ -34,13 +34,6 @@ test_expect_success 'ls-files -h in corrupt repository' '
 	test_grep "[Uu]sage: git ls-files " broken/usage
 '
 
-test_expect_success 'ls-files does not crash with -h' '
-	test_expect_code 129 git ls-files -h >usage &&
-	test_grep "[Uu]sage: git ls-files " usage &&
-	test_expect_code 129 nongit git ls-files -h >usage &&
-	test_grep "[Uu]sage: git ls-files " usage
-'
-
 test_expect_success SYMLINKS 'ls-files with absolute paths to symlinks' '
 	mkdir subs &&
 	ln -s nosuch link &&
-- 
2.50.0
Usman Akinyemi· Jul 6, 2025, 21:50 UTC · re: Usman Akinyemi · lore

[PATCH v3 4/7] t/t1517: move pack-refs -h test to t1517

The test 'pack-refs does not crash with -h' checks that the command exits cleanly with usage information, both inside and outside of a repository.

Move this test from "t0610-reftable-basics.sh" to "t1517-outside-repo.sh" since it better fits with tests that check command behavior outside a repository.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t0610-reftable-basics.sh | 7 -------
 t/t1517-outside-repo.sh    | 7 +++++++
 2 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 2 files +7 −7

t/t0610-reftable-basics.sh, t/t1517-outside-repo.sh

diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh
index 3ea5d51532..ffd8ecc0ce 100755
--- a/t/t0610-reftable-basics.sh
+++ b/t/t0610-reftable-basics.sh
@@ -14,13 +14,6 @@ export GIT_TEST_DEFAULT_REF_FORMAT
 
 INVALID_OID=$(test_oid 001)
 
-test_expect_success 'pack-refs does not crash with -h' '
-	test_expect_code 129 git pack-refs -h >usage &&
-	test_grep "[Uu]sage: git pack-refs " usage &&
-	test_expect_code 129 nongit git pack-refs -h >usage &&
-	test_grep "[Uu]sage: git pack-refs " usage
-'
-
 test_expect_success 'init: creates basic reftable structures' '
 	test_when_finished "rm -rf repo" &&
 	git init repo &&
diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 206b9e118c..39e7842c9e 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -135,4 +135,11 @@ test_expect_success 'ls-files does not crash with -h' '
 	test_grep "[Uu]sage: git ls-files " usage
 '
 
+test_expect_success 'pack-refs does not crash with -h' '
+	test_expect_code 129 git pack-refs -h >usage &&
+	test_grep "[Uu]sage: git pack-refs " usage &&
+	test_expect_code 129 nongit git pack-refs -h >usage &&
+	test_grep "[Uu]sage: git pack-refs " usage
+'
+
 test_done
-- 
2.50.0
Usman Akinyemi· Jul 6, 2025, 21:50 UTC · re: Usman Akinyemi · lore

[PATCH v3 5/7] t/t1517: move send-pack -h test to t1517

The test 'send-pack does not crash with -h' checks that the command exits cleanly with usage information, both inside and outside of a repository.

Move this test from "t/t5400-send-pack.sh" to "t1517-outside-repo.sh" since it better fits with tests that check command behavior outside a repository.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh | 7 +++++++
 t/t5400-send-pack.sh    | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 2 files +7 −7

t/t1517-outside-repo.sh, t/t5400-send-pack.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 39e7842c9e..2568f8ae0d 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -142,4 +142,11 @@ test_expect_success 'pack-refs does not crash with -h' '
 	test_grep "[Uu]sage: git pack-refs " usage
 '
 
+test_expect_success 'send-pack does not crash with -h' '
+	test_expect_code 129 git send-pack -h >usage &&
+	test_grep "[Uu]sage: git send-pack " usage &&
+	test_expect_code 129 nongit git send-pack -h >usage &&
+	test_grep "[Uu]sage: git send-pack " usage
+'
+
 test_done
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 83b42ff073..571e8f1bc5 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -55,13 +55,6 @@ test_expect_success setup '
 	echo Rebase &&
 	git log'
 
-test_expect_success 'send-pack does not crash with -h' '
-	test_expect_code 129 git send-pack -h >usage &&
-	test_grep "[Uu]sage: git send-pack " usage &&
-	test_expect_code 129 nongit git send-pack -h >usage &&
-	test_grep "[Uu]sage: git send-pack " usage
-'
-
 test_expect_success 'pack the source repository' '
 	git repack -a -d &&
 	git prune
-- 
2.50.0
Usman Akinyemi· Jul 6, 2025, 21:50 UTC · re: Usman Akinyemi · lore

[PATCH v3 6/7] t/t1517: move verify-commit -h test to t1517

The test 'verify-commit does not crash with -h' checks that the command exits cleanly with usage information, both inside and outside of a repository.

Move this test from "t/t7510-signed-commit.sh" to "t1517-outside-repo.sh" since it better fits with tests that check command behavior outside a repository.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh  | 7 +++++++
 t/t7510-signed-commit.sh | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 2 files +7 −7

t/t1517-outside-repo.sh, t/t7510-signed-commit.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 2568f8ae0d..8a46fdfdd1 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -149,4 +149,11 @@ test_expect_success 'send-pack does not crash with -h' '
 	test_grep "[Uu]sage: git send-pack " usage
 '
 
+test_expect_success 'verify-commit does not crash with -h' '
+	test_expect_code 129 git verify-commit -h >usage &&
+	test_grep "[Uu]sage: git verify-commit " usage &&
+	test_expect_code 129 nongit git verify-commit -h >usage &&
+	test_grep "[Uu]sage: git verify-commit " usage
+'
+
 test_done
diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index 39677e859a..0d2dd29fe6 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -8,13 +8,6 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 GNUPGHOME_NOT_USED=$GNUPGHOME
 . "$TEST_DIRECTORY/lib-gpg.sh"
 
-test_expect_success GPG 'verify-commit does not crash with -h' '
-	test_expect_code 129 git verify-commit -h >usage &&
-	test_grep "[Uu]sage: git verify-commit " usage &&
-	test_expect_code 129 nongit git verify-commit -h >usage &&
-	test_grep "[Uu]sage: git verify-commit " usage
-'
-
 test_expect_success GPG 'create signed commits' '
 	test_oid_cache <<-\EOF &&
 	header sha1:gpgsig
-- 
2.50.0
Junio C Hamano· Jul 7, 2025, 16:12 UTC · re: Usman Akinyemi · lore

Re: [PATCH v3 6/7] t/t1517: move verify-commit -h test to t1517

Usman Akinyemi <usmanakinyemi202@gmail.com> writes:
Show 14 quoted lines
> The test 'verify-commit does not crash with -h' checks that
> the command exits cleanly with usage information, both inside and
> outside of a repository.
>
> Move this test from "t/t7510-signed-commit.sh" to
> "t1517-outside-repo.sh" since it better fits with tests that check
> command behavior outside a repository.
>
> Suggested-by: Patrick Steinhardt <ps@pks.im>
> Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
> ---
>  t/t1517-outside-repo.sh  | 7 +++++++
>  t/t7510-signed-commit.sh | 7 -------
>  2 files changed, 7 insertions(+), 7 deletions(-)

My first reaction to this series was "heh, you can cut it both ways; a test to see how a command A works outside a repository can be a test about command A (which is the way how the current test suite looks at) or a test about being outside a repository (which this topic tries to move into).

But this may be an example that shows why it is more error prone to partition across "inside? outside?" axis. These particular ones may be limited to "should exit without crashing and without doing anything fancy when asked to give a short help", so this move may happen to be able to lose the GPG prerequisite without breaking anything.

But in the longer run, we are very much likely that we'd want to test something that needs things that require prerequisites (like "do this only where XYZ is installed") but ought to work outside a repository, which means t1517 would need to pull in things like lib-gpg.sh only because it has a few tests about verify-blah command. These tend to accumulate over time.

So, I dunno.
Usman Akinyemi· Jul 10, 2025, 22:59 UTC · re: Junio C Hamano · lore

Re: [PATCH v3 6/7] t/t1517: move verify-commit -h test to t1517

On Mon, Jul 7, 2025 at 9:42 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 18 quoted lines
>
> Usman Akinyemi <usmanakinyemi202@gmail.com> writes:
>
> > The test 'verify-commit does not crash with -h' checks that
> > the command exits cleanly with usage information, both inside and
> > outside of a repository.
> >
> > Move this test from "t/t7510-signed-commit.sh" to
> > "t1517-outside-repo.sh" since it better fits with tests that check
> > command behavior outside a repository.
> >
> > Suggested-by: Patrick Steinhardt <ps@pks.im>
> > Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
> > ---
> >  t/t1517-outside-repo.sh  | 7 +++++++
> >  t/t7510-signed-commit.sh | 7 -------
> >  2 files changed, 7 insertions(+), 7 deletions(-)
>
Hi Junio,
Show 6 quoted lines
> My first reaction to this series was "heh, you can cut it both ways;
> a test to see how a command A works outside a repository can be a
> test about command A (which is the way how the current test suite
> looks at) or a test about being outside a repository (which this
> topic tries to move into).
>

Actually, I felt the same while trying to create the patch series. I was going to just send a single patch before as an RFC.

Show 13 quoted lines
> But this may be an example that shows why it is more error prone to
> partition across "inside? outside?" axis.  These particular ones may
> be limited to "should exit without crashing and without doing
> anything fancy when asked to give a short help", so this move may
> happen to be able to lose the GPG prerequisite without breaking
> anything.
>
> But in the longer run, we are very much likely that we'd want to
> test something that needs things that require prerequisites (like
> "do this only where XYZ is installed") but ought to work outside a
> repository, which means t1517 would need to pull in things like
> lib-gpg.sh only because it has a few tests about verify-blah
> command.  These tend to accumulate over time.

I understand the concern and I felt we should at least decide where to put the "verify -h" because, right now, we have some of them in the t1517 and also some in their respective test files. So, there are some little hiccups there. It will also create a headache for someone who is trying to place the test(deciding if they should put it in the t1517 as some test or inside their respective test as some others). Also, Ayush(GSoC) is also working currently around this part.

Is it something that is worth creating a new test file for, I will probably say that is a viable solution or better still we should put the test inside their respective test files.

What do you think ?
>
> So, I dunno.
>
Junio C Hamano· Jul 11, 2025, 16:37 UTC · re: Usman Akinyemi · lore

Re: [PATCH v3 6/7] t/t1517: move verify-commit -h test to t1517

Usman Akinyemi <usmanakinyemi202@gmail.com> writes:
Show 10 quoted lines
>> But in the longer run, we are very much likely that we'd want to
>> test something that needs things that require prerequisites (like
>> "do this only where XYZ is installed") but ought to work outside a
>> repository, which means t1517 would need to pull in things like
>> lib-gpg.sh only because it has a few tests about verify-blah
>> command.  These tend to accumulate over time.
>
> I understand the concern and I felt we should at least decide where to
> put the "verify -h" because, right now, we have some of them in the
> t1517 and also some in their respective test files.

If t1517 were only about "git subcmd -h outside a repository" for various subcommands, that would be a happy arrangement. I think we even have a way to iterate over all Git subcommands, current or future, so your patch may become "we've sprinkled 'subcmd -h' tests in various scripts, but now t1517 will do that automatically so anybody who add a new command do not have to do anything".

But if t1517 currently (before your series) already has other things tested, that changes the story somewhat. Especially if we aim for the automated solution, we may want to move existing tests in 1517 that is not about "subcmd -h" out to different scripts. Obvious two choices are:

 - We spread them to existing test scripts for the command being
   tested (e.g. "does patch-id work correctly outside a repo?"
   moves to t4204-patch-id, and "does update-server-info work OK
   inside and outside a repo?" can be split and one half moves to
   t5200-update-server-info).
 - We move them all to a new test script that is dedicated for "do
   various subcommands work outside a repo to do things other than
   responding to '-h'?".
and I would favour the former.

The only reason why you moved these to t1517 is because the set-up part of that script sets up the ceiling just once properly and let its tests do as if they are running outsie a repository, and having to arrange the ceiling correctly to add a few test in various scripts so that each of these scripts can test their single subcommand pretending that it is running outside a repository looked cumbersome, right? And I do agree with you, if that was the reason, that it is annoying to have to set up the ceiling manually in each test script. But then can we do it less annoying? We already made a nongit test helper and it may be good enough to help existing tests in t1517.

As an illustration, here is what the beginning of the former approach may look like.

 t/t1517-outside-repo.sh       | 27 +++++++++++++++++++++------
 t/t5200-update-server-info.sh |  5 +++++
 2 files changed, 26 insertions(+), 6 deletions(-)
Show changes to diff +26 −6
diff --git c/t/t1517-outside-repo.sh w/t/t1517-outside-repo.sh
index 6824581317..c1294d5761 100755
--- c/t/t1517-outside-repo.sh
+++ w/t/t1517-outside-repo.sh
@@ -107,11 +107,26 @@ test_expect_success LIBCURL 'remote-http outside repository' '
 	test_grep "^error: remote-curl" actual
 '
 
-test_expect_success 'update-server-info does not crash with -h' '
-	test_expect_code 129 git update-server-info -h >usage &&
-	test_grep "[Uu]sage: git update-server-info " usage &&
-	test_expect_code 129 nongit git update-server-info -h >usage &&
-	test_grep "[Uu]sage: git update-server-info " usage
-'
+for cmd in $(git --list-cmds=main)
+do
+	cmd=${cmd%.*} # strip .sh, .perl, etc.
+	case "$cmd" in
+	archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
+	difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
+	http-backend | http-fetch | http-push | init-db | instaweb.sh | \
+	merge-octopus | merge-one-file | merge-resolve | mergetool | \
+	mktag | p4 | p4.py | pickaxe | quiltimport | remote-ftp | remote-ftps | \
+	remote-http | remote-https | replay | request-pull | send-email | \
+	sh-i18n--envsubst | shell | show | stage | submodule | svn | \
+	upload-archive--writer | upload-pack | web--browse | whatchanged)
+		expect_outcome=expect_failure ;;
+	*)
+		expect_outcome=expect_success ;;
+	esac
+	test_$expect_outcome "'git $cmd -h' outside a repository" '
+		test_expect_code 129 nongit git $cmd -h >usage &&
+		test_grep "[Uu]sage: git $cmd " usage
+	'
+done
 
 test_done
diff --git c/t/t5200-update-server-info.sh w/t/t5200-update-server-info.sh
index 8365907055..a551e955b5 100755
--- c/t/t5200-update-server-info.sh
+++ w/t/t5200-update-server-info.sh
@@ -46,4 +46,9 @@ test_expect_success 'midx does not create duplicate pack entries' '
 	test_must_be_empty dups
 '
 
+test_expect_success 'update-server-info does not crash with -h' '
+	test_expect_code 129 git update-server-info -h >usage &&
+	test_grep "[Uu]sage: git update-server-info " usage
+'
+
 test_done
Usman Akinyemi· Jul 21, 2025, 11:55 UTC · re: Junio C Hamano · lore

[PATCH v4 0/2] refactor t1517 to focus on help output outside a repository

This series refactors t1517-outside-repo.sh to focus on testing `git subcmd -h` outside a Git repository. It does two things:

  1. Moves the existing `update-server-info -h` test to t5200, since it
     tests behavior *inside* a repo and belongs with other update-server-info
     tests.
  
  2. Introduces a loop in t1517 that automatically verifies `-h` output
     for all main Git subcommands when run outside a repository, using
     the `nongit` helper and `git --list-cmds=main`.

This makes t1517 easier to maintain and ensures that new commands are automatically covered for this class of behavior.

Changes since v3:
  - Changes the approach from having the t1517 to test
  both help outside and inside repo to just having inside repo.
Usman Akinyemi (2):
  t/t1517: automate `git subcmd -h` tests outside a repository
  t5200: move `update-server-info -h` test from t1517
 t/t1517-outside-repo.sh       | 28 ++++++++++++++++++++++------
 t/t5200-update-server-info.sh |  5 +++++
 2 files changed, 27 insertions(+), 6 deletions(-)
-- 
2.50.0
Usman Akinyemi· Jul 21, 2025, 11:55 UTC · re: Usman Akinyemi · lore

[PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

Replace manual `-h` tests with a loop over all subcommands using `git --list-cmds=main`. This ensures consistent coverage of `-h` behavior outside a repo and future-proofs the test by covering new commands automatically.

Known exceptions are skipped or marked as expected failures.
Suggested-by: Patrick Steinhardt <ps@pks.im>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
Show changes to t/t1517-outside-repo.sh +23 −2
diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 6824581317..9fcebb7d94 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -110,8 +110,29 @@ test_expect_success LIBCURL 'remote-http outside repository' '
 test_expect_success 'update-server-info does not crash with -h' '
 	test_expect_code 129 git update-server-info -h >usage &&
 	test_grep "[Uu]sage: git update-server-info " usage &&
-	test_expect_code 129 nongit git update-server-info -h >usage &&
-	test_grep "[Uu]sage: git update-server-info " usage
 '
 
+for cmd in $(git --list-cmds=main)
+do
+	cmd=${cmd%.*} # strip .sh, .perl, etc.
+	case "$cmd" in
+	archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
+	difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
+	http-backend | http-fetch | http-push | init-db | instaweb.sh | \
+	merge-octopus | merge-one-file | merge-resolve | mergetool | \
+	mktag | p4 | p4.py | pickaxe | quiltimport | remote-ftp | remote-ftps | \
+	remote-http | remote-https | replay | request-pull | send-email | \
+	sh-i18n--envsubst | shell | show | stage | submodule | svn | \
+	upload-archive--writer | upload-pack | web--browse | whatchanged)
+		expect_outcome=expect_failure ;;
+	*)
+		expect_outcome=expect_success ;;
+	esac
+	test_$expect_outcome "'git $cmd -h' outside a repository" '
+		test_expect_code 129 nongit git $cmd -h >usage &&
+		echo "Hello" &&
+		test_grep "[Uu]sage: git $cmd " usage
+	'
+done
+
 test_done
-- 
2.50.0
D. Ben Knoble· Jul 26, 2025, 14:34 UTC · re: Usman Akinyemi · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

On Mon, Jul 21, 2025 at 7:55 AM Usman Akinyemi <usmanakinyemi202@gmail.com> wrote:

Show 36 quoted lines
>
> Replace manual `-h` tests with a loop over all subcommands using
> `git --list-cmds=main`. This ensures consistent coverage of `-h`
> behavior outside a repo and future-proofs the test by covering
> new commands automatically.
>
> Known exceptions are skipped or marked as expected failures.
>
> Suggested-by: Patrick Steinhardt <ps@pks.im>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
> ---
>  t/t1517-outside-repo.sh | 25 +++++++++++++++++++++++--
>  1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
> index 6824581317..9fcebb7d94 100755
> --- a/t/t1517-outside-repo.sh
> +++ b/t/t1517-outside-repo.sh
> @@ -110,8 +110,29 @@ test_expect_success LIBCURL 'remote-http outside repository' '
>  test_expect_success 'update-server-info does not crash with -h' '
>         test_expect_code 129 git update-server-info -h >usage &&
>         test_grep "[Uu]sage: git update-server-info " usage &&
> -       test_expect_code 129 nongit git update-server-info -h >usage &&
> -       test_grep "[Uu]sage: git update-server-info " usage
>  '
>
> +for cmd in $(git --list-cmds=main)
> +do
> +       cmd=${cmd%.*} # strip .sh, .perl, etc.
> +       case "$cmd" in
> +       archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
> +       difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
> +       http-backend | http-fetch | http-push | init-db | instaweb.sh | \
> +       merge-octopus | merge-one-file | merge-resolve | mergetool | \
> +       mktag | p4 | p4.py | pickaxe | quiltimport | remote-ftp | remote-ftps | \

Hm—if we strip the suffix with ${cmd%.*}, do we need a p4.py pattern too? Actually, at first I wondered why we need to strip the suffix at all. My local Git produces only unsuffixed commands. But bin-wrappers/git produces both p4 and p4.py; request-pull and request-pull.sh; and several others. So I think stripping is probably right, just drop the .py pattern.

Show 10 quoted lines
> +       remote-http | remote-https | replay | request-pull | send-email | \
> +       sh-i18n--envsubst | shell | show | stage | submodule | svn | \
> +       upload-archive--writer | upload-pack | web--browse | whatchanged)
> +               expect_outcome=expect_failure ;;
> +       *)
> +               expect_outcome=expect_success ;;
> +       esac
> +       test_$expect_outcome "'git $cmd -h' outside a repository" '
> +               test_expect_code 129 nongit git $cmd -h >usage &&
> +               echo "Hello" &&

Woops! While basing some work on this branch, I spotted this "echo"—I assume it's leftover and didn't mean to be included here? Will drop locally for my own work.

Show 9 quoted lines
> +               test_grep "[Uu]sage: git $cmd " usage
> +       '
> +done
> +
>  test_done
> --
> 2.50.0
>
>

Last thing: outside the patch context, there's a test for prune that should probably get tweaked like the update-server-info test.

-- 
D. Ben Knoble
Usman Akinyemi· Jul 26, 2025, 21:53 UTC · re: D. Ben Knoble · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

Show 15 quoted lines
> > +do
> > +       cmd=${cmd%.*} # strip .sh, .perl, etc.
> > +       case "$cmd" in
> > +       archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
> > +       difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
> > +       http-backend | http-fetch | http-push | init-db | instaweb.sh | \
> > +       merge-octopus | merge-one-file | merge-resolve | mergetool | \
> > +       mktag | p4 | p4.py | pickaxe | quiltimport | remote-ftp | remote-ftps | \
>
> Hm—if we strip the suffix with ${cmd%.*}, do we need a p4.py pattern
> too? Actually, at first I wondered why we need to strip the suffix at
> all. My local Git produces only unsuffixed commands. But
> bin-wrappers/git produces both p4 and p4.py; request-pull and
> request-pull.sh; and several others. So I think stripping is probably
> right, just drop the .py pattern.
Noted and thanks.
Show 16 quoted lines
>
> > +       remote-http | remote-https | replay | request-pull | send-email | \
> > +       sh-i18n--envsubst | shell | show | stage | submodule | svn | \
> > +       upload-archive--writer | upload-pack | web--browse | whatchanged)
> > +               expect_outcome=expect_failure ;;
> > +       *)
> > +               expect_outcome=expect_success ;;
> > +       esac
> > +       test_$expect_outcome "'git $cmd -h' outside a repository" '
> > +               test_expect_code 129 nongit git $cmd -h >usage &&
> > +               echo "Hello" &&
>
> Woops! While basing some work on this branch, I spotted this "echo"—I
> assume it's leftover and didn't mean to be included here? Will drop
> locally for my own work.
>

Since you based your work on mine, does it mean I do not have to send the updated patch ?

D. Ben Knoble· Jul 30, 2025, 21:14 UTC · re: Usman Akinyemi · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

On Sat, Jul 26, 2025 at 5:53 PM Usman Akinyemi <usmanakinyemi202@gmail.com> wrote:

Show 17 quoted lines
> > > +       remote-http | remote-https | replay | request-pull | send-email | \
> > > +       sh-i18n--envsubst | shell | show | stage | submodule | svn | \
> > > +       upload-archive--writer | upload-pack | web--browse | whatchanged)
> > > +               expect_outcome=expect_failure ;;
> > > +       *)
> > > +               expect_outcome=expect_success ;;
> > > +       esac
> > > +       test_$expect_outcome "'git $cmd -h' outside a repository" '
> > > +               test_expect_code 129 nongit git $cmd -h >usage &&
> > > +               echo "Hello" &&
> >
> > Woops! While basing some work on this branch, I spotted this "echo"—I
> > assume it's leftover and didn't mean to be included here? Will drop
> > locally for my own work.
> >
> Since you based your work on mine, does it mean I do not have to send
> the updated patch ?

That's more a question for Junio than me, but I'm comfortable rebasing my work on top of updated versions of your branch—and I would prefer to keep iterations of this series separate from my own, heh.

Really I hope you'll squash my fixes in, and possibly a few others,
and send another version? For example:
- pickaxe is a failure because the message is about blame;
- show is a failure because the message is about log _and_ show;
- init-db is a failure because the message is about init;
- whatchanged is a failure because the message is about log/show.
Maybe these are "out of scope," which is fine—but I think they are
working as intended?
-- 
D. Ben Knoble
Junio C Hamano· Jul 28, 2025, 15:08 UTC · re: D. Ben Knoble · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

"D. Ben Knoble" <ben.knoble@gmail.com> writes:
Show 17 quoted lines
>> +for cmd in $(git --list-cmds=main)
>> +do
>> +       cmd=${cmd%.*} # strip .sh, .perl, etc.
>> +       case "$cmd" in
>> +       archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
>> +       difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
>> +       http-backend | http-fetch | http-push | init-db | instaweb.sh | \
>> +       merge-octopus | merge-one-file | merge-resolve | mergetool | \
>> +       mktag | p4 | p4.py | pickaxe | quiltimport | remote-ftp | remote-ftps | \
>
> Hm—if we strip the suffix with ${cmd%.*}, do we need a p4.py
> pattern too?  Actually, at first I wondered why we need to strip
> the suffix at all. My local Git produces only unsuffixed commands.
> ...
> bin-wrappers/git produces both p4 and p4.py; request-pull and
> request-pull.sh; and several others. So I think stripping is probably
> right, just drop the .py pattern.

Ahh, OK, I didn't realize that bin-wrappers gets into the picture. So you're right. Fixing the bin-wrappers may be necessary, but dropping the extra ones is certainly a good idea.

Show 6 quoted lines
>> +       test_$expect_outcome "'git $cmd -h' outside a repository" '
>> +               test_expect_code 129 nongit git $cmd -h >usage &&
>> +               echo "Hello" &&
>
> Woops! While basing some work on this branch, I spotted this "echo"—I
> assume it's leftover and didn't mean to be included here?
;-)
D. Ben Knoble· Aug 2, 2025, 19:56 UTC · re: D. Ben Knoble · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

On Sat, Jul 26, 2025 at 10:34 AM D. Ben Knoble <ben.knoble@gmail.com> wrote:
Show 46 quoted lines
>
> On Mon, Jul 21, 2025 at 7:55 AM Usman Akinyemi
> <usmanakinyemi202@gmail.com> wrote:
> >
> > Replace manual `-h` tests with a loop over all subcommands using
> > `git --list-cmds=main`. This ensures consistent coverage of `-h`
> > behavior outside a repo and future-proofs the test by covering
> > new commands automatically.
> >
> > Known exceptions are skipped or marked as expected failures.
> >
> > Suggested-by: Patrick Steinhardt <ps@pks.im>
> > Helped-by: Junio C Hamano <gitster@pobox.com>
> > Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
> > ---
> >  t/t1517-outside-repo.sh | 25 +++++++++++++++++++++++--
> >  1 file changed, 23 insertions(+), 2 deletions(-)
> >
> > diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
> > index 6824581317..9fcebb7d94 100755
> > --- a/t/t1517-outside-repo.sh
> > +++ b/t/t1517-outside-repo.sh
> > @@ -110,8 +110,29 @@ test_expect_success LIBCURL 'remote-http outside repository' '
> >  test_expect_success 'update-server-info does not crash with -h' '
> >         test_expect_code 129 git update-server-info -h >usage &&
> >         test_grep "[Uu]sage: git update-server-info " usage &&
> > -       test_expect_code 129 nongit git update-server-info -h >usage &&
> > -       test_grep "[Uu]sage: git update-server-info " usage
> >  '
> >
> > +for cmd in $(git --list-cmds=main)
> > +do
> > +       cmd=${cmd%.*} # strip .sh, .perl, etc.
> > +       case "$cmd" in
> > +       archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
> > +       difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
> > +       http-backend | http-fetch | http-push | init-db | instaweb.sh | \
> > +       merge-octopus | merge-one-file | merge-resolve | mergetool | \
> > +       mktag | p4 | p4.py | pickaxe | quiltimport | remote-ftp | remote-ftps | \
>
> Hm—if we strip the suffix with ${cmd%.*}, do we need a p4.py pattern
> too? Actually, at first I wondered why we need to strip the suffix at
> all. My local Git produces only unsuffixed commands. But
> bin-wrappers/git produces both p4 and p4.py; request-pull and
> request-pull.sh; and several others. So I think stripping is probably
> right, just drop the .py pattern.

I think that using "instaweb.sh" instead of "instaweb" also causes this to fail on Windows, like:

https://github.com/benknoble/git/actions/runs/16695826272/job/47259908953
-- 
D. Ben Knoble
Usman Akinyemi· Aug 3, 2025, 01:27 UTC · re: D. Ben Knoble · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

Show 11 quoted lines
> > Hm—if we strip the suffix with ${cmd%.*}, do we need a p4.py pattern
> > too? Actually, at first I wondered why we need to strip the suffix at
> > all. My local Git produces only unsuffixed commands. But
> > bin-wrappers/git produces both p4 and p4.py; request-pull and
> > request-pull.sh; and several others. So I think stripping is probably
> > right, just drop the .py pattern.
>
> I think that using "instaweb.sh" instead of "instaweb" also causes
> this to fail on Windows, like:
>
> https://github.com/benknoble/git/actions/runs/16695826272/job/47259908953
I think this is expected breakage. Removing ".sh" makes the #TODO to pass.
>
> --
> D. Ben Knoble
D. Ben Knoble· Jul 26, 2025, 14:37 UTC · re: Usman Akinyemi · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

On Mon, Jul 21, 2025 at 7:55 AM Usman Akinyemi <usmanakinyemi202@gmail.com> wrote:

Show 39 quoted lines
>
> Replace manual `-h` tests with a loop over all subcommands using
> `git --list-cmds=main`. This ensures consistent coverage of `-h`
> behavior outside a repo and future-proofs the test by covering
> new commands automatically.
>
> Known exceptions are skipped or marked as expected failures.
>
> Suggested-by: Patrick Steinhardt <ps@pks.im>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
> ---
>  t/t1517-outside-repo.sh | 25 +++++++++++++++++++++++--
>  1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
> index 6824581317..9fcebb7d94 100755
> --- a/t/t1517-outside-repo.sh
> +++ b/t/t1517-outside-repo.sh
> @@ -110,8 +110,29 @@ test_expect_success LIBCURL 'remote-http outside repository' '
>  test_expect_success 'update-server-info does not crash with -h' '
>         test_expect_code 129 git update-server-info -h >usage &&
>         test_grep "[Uu]sage: git update-server-info " usage &&
> -       test_expect_code 129 nongit git update-server-info -h >usage &&
> -       test_grep "[Uu]sage: git update-server-info " usage
>  '
>
> +for cmd in $(git --list-cmds=main)
> +do
> +       cmd=${cmd%.*} # strip .sh, .perl, etc.
> +       case "$cmd" in
> +       archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
> +       difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
> +       http-backend | http-fetch | http-push | init-db | instaweb.sh | \
> +       merge-octopus | merge-one-file | merge-resolve | mergetool | \
> +       mktag | p4 | p4.py | pickaxe | quiltimport | remote-ftp | remote-ftps | \
> +       remote-http | remote-https | replay | request-pull | send-email | \
> +       sh-i18n--envsubst | shell | show | stage | submodule | svn | \
> +       upload-archive--writer | upload-pack | web--browse | whatchanged)

Sorry, one more thing: I spot-checked a few of these, and it seems the main issue that causes failures is the exit code; they seem to work with "-h" outside a repo. Out of scope for this series, but something worth tidying up as #leftoverbits ?

Show 16 quoted lines
> +               expect_outcome=expect_failure ;;
> +       *)
> +               expect_outcome=expect_success ;;
> +       esac
> +       test_$expect_outcome "'git $cmd -h' outside a repository" '
> +               test_expect_code 129 nongit git $cmd -h >usage &&
> +               echo "Hello" &&
> +               test_grep "[Uu]sage: git $cmd " usage
> +       '
> +done
> +
>  test_done
> --
> 2.50.0
>
>
-- 
D. Ben Knoble
D. Ben Knoble· Jul 26, 2025, 14:52 UTC · re: D. Ben Knoble · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

On Sat, Jul 26, 2025 at 10:37 AM D. Ben Knoble <ben.knoble@gmail.com> wrote:
Show 47 quoted lines
>
> On Mon, Jul 21, 2025 at 7:55 AM Usman Akinyemi
> <usmanakinyemi202@gmail.com> wrote:
> >
> > Replace manual `-h` tests with a loop over all subcommands using
> > `git --list-cmds=main`. This ensures consistent coverage of `-h`
> > behavior outside a repo and future-proofs the test by covering
> > new commands automatically.
> >
> > Known exceptions are skipped or marked as expected failures.
> >
> > Suggested-by: Patrick Steinhardt <ps@pks.im>
> > Helped-by: Junio C Hamano <gitster@pobox.com>
> > Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
> > ---
> >  t/t1517-outside-repo.sh | 25 +++++++++++++++++++++++--
> >  1 file changed, 23 insertions(+), 2 deletions(-)
> >
> > diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
> > index 6824581317..9fcebb7d94 100755
> > --- a/t/t1517-outside-repo.sh
> > +++ b/t/t1517-outside-repo.sh
> > @@ -110,8 +110,29 @@ test_expect_success LIBCURL 'remote-http outside repository' '
> >  test_expect_success 'update-server-info does not crash with -h' '
> >         test_expect_code 129 git update-server-info -h >usage &&
> >         test_grep "[Uu]sage: git update-server-info " usage &&
> > -       test_expect_code 129 nongit git update-server-info -h >usage &&
> > -       test_grep "[Uu]sage: git update-server-info " usage
> >  '
> >
> > +for cmd in $(git --list-cmds=main)
> > +do
> > +       cmd=${cmd%.*} # strip .sh, .perl, etc.
> > +       case "$cmd" in
> > +       archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
> > +       difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
> > +       http-backend | http-fetch | http-push | init-db | instaweb.sh | \
> > +       merge-octopus | merge-one-file | merge-resolve | mergetool | \
> > +       mktag | p4 | p4.py | pickaxe | quiltimport | remote-ftp | remote-ftps | \
> > +       remote-http | remote-https | replay | request-pull | send-email | \
> > +       sh-i18n--envsubst | shell | show | stage | submodule | svn | \
> > +       upload-archive--writer | upload-pack | web--browse | whatchanged)
>
> Sorry, one more thing: I spot-checked a few of these, and it seems the
> main issue that causes failures is the exit code; they seem to work
> with "-h" outside a repo. Out of scope for this series, but something
> worth tidying up as #leftoverbits ?

It turns out a few pass for me right now: quiltimport and request-pull both work just fine.

-- 
D. Ben Knoble
Usman Akinyemi· Jul 26, 2025, 21:51 UTC · re: D. Ben Knoble · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

Show 18 quoted lines
> > +for cmd in $(git --list-cmds=main)
> > +do
> > +       cmd=${cmd%.*} # strip .sh, .perl, etc.
> > +       case "$cmd" in
> > +       archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
> > +       difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
> > +       http-backend | http-fetch | http-push | init-db | instaweb.sh | \
> > +       merge-octopus | merge-one-file | merge-resolve | mergetool | \
> > +       mktag | p4 | p4.py | pickaxe | quiltimport | remote-ftp | remote-ftps | \
> > +       remote-http | remote-https | replay | request-pull | send-email | \
> > +       sh-i18n--envsubst | shell | show | stage | submodule | svn | \
> > +       upload-archive--writer | upload-pack | web--browse | whatchanged)
>
> Sorry, one more thing: I spot-checked a few of these, and it seems the
> main issue that causes failures is the exit code; they seem to work
> with "-h" outside a repo. Out of scope for this series, but something
> worth tidying up as #leftoverbits ?
>
You meant the exit code of 129 right ?
D. Ben Knoble· Jul 30, 2025, 21:15 UTC · re: Usman Akinyemi · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

On Sat, Jul 26, 2025 at 5:51 PM Usman Akinyemi <usmanakinyemi202@gmail.com> wrote:

Show 20 quoted lines
>
> > > +for cmd in $(git --list-cmds=main)
> > > +do
> > > +       cmd=${cmd%.*} # strip .sh, .perl, etc.
> > > +       case "$cmd" in
> > > +       archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
> > > +       difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
> > > +       http-backend | http-fetch | http-push | init-db | instaweb.sh | \
> > > +       merge-octopus | merge-one-file | merge-resolve | mergetool | \
> > > +       mktag | p4 | p4.py | pickaxe | quiltimport | remote-ftp | remote-ftps | \
> > > +       remote-http | remote-https | replay | request-pull | send-email | \
> > > +       sh-i18n--envsubst | shell | show | stage | submodule | svn | \
> > > +       upload-archive--writer | upload-pack | web--browse | whatchanged)
> >
> > Sorry, one more thing: I spot-checked a few of these, and it seems the
> > main issue that causes failures is the exit code; they seem to work
> > with "-h" outside a repo. Out of scope for this series, but something
> > worth tidying up as #leftoverbits ?
> >
> You meant the exit code of 129 right ?
Yep: some of our commands (often the ones implemented as scripts?)
don't exit 129. Fixing that is certainly out-of-scope for this
otherwise-tightly focused series.
-- 
D. Ben Knoble
Junio C Hamano· Jul 28, 2025, 15:09 UTC · re: D. Ben Knoble · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

"D. Ben Knoble" <ben.knoble@gmail.com> writes:
> Sorry, one more thing: I spot-checked a few of these, and it seems the
> main issue that causes failures is the exit code; they seem to work
> with "-h" outside a repo. Out of scope for this series, but something
> worth tidying up as #leftoverbits ?
Great suggestion.  Thanks.
Phillip Wood· Aug 26, 2025, 15:57 UTC · re: Usman Akinyemi · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

Hi Usman
On 21/07/2025 12:55, Usman Akinyemi wrote:
Show 14 quoted lines
> 
> diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
> index 6824581317..9fcebb7d94 100755
> --- a/t/t1517-outside-repo.sh
> +++ b/t/t1517-outside-repo.sh
> @@ -110,8 +110,29 @@ test_expect_success LIBCURL 'remote-http outside repository' '
>   test_expect_success 'update-server-info does not crash with -h' '
>   	test_expect_code 129 git update-server-info -h >usage &&
>   	test_grep "[Uu]sage: git update-server-info " usage &&
> -	test_expect_code 129 nongit git update-server-info -h >usage &&
> -	test_grep "[Uu]sage: git update-server-info " usage
>   '
>   
> +for cmd in $(git --list-cmds=main)

This lists all the git commands in $PATH which is causing "make test" to fail when I run it locally as it is testing all my local "git-*" scripts most of which apparently fail this test. If there isn't already we should add a option that lists the commands only in $GIT_EXEC_PATH and use it here.

Also when I run the test with '-i' it does not stop at the first failure. I'm not sure what's causing that as I thought test_expect_success should exit on failure even when it is called in a loop.

Thanks
Phillip
Show 23 quoted lines
> +do
> +	cmd=${cmd%.*} # strip .sh, .perl, etc.
> +	case "$cmd" in
> +	archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
> +	difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
> +	http-backend | http-fetch | http-push | init-db | instaweb.sh | \
> +	merge-octopus | merge-one-file | merge-resolve | mergetool | \
> +	mktag | p4 | p4.py | pickaxe | quiltimport | remote-ftp | remote-ftps | \
> +	remote-http | remote-https | replay | request-pull | send-email | \
> +	sh-i18n--envsubst | shell | show | stage | submodule | svn | \
> +	upload-archive--writer | upload-pack | web--browse | whatchanged)
> +		expect_outcome=expect_failure ;;
> +	*)
> +		expect_outcome=expect_success ;;
> +	esac
> +	test_$expect_outcome "'git $cmd -h' outside a repository" '
> +		test_expect_code 129 nongit git $cmd -h >usage &&
> +		echo "Hello" &&
> +		test_grep "[Uu]sage: git $cmd " usage
> +	'
> +done
> +
>   test_done
D. Ben Knoble· Aug 28, 2025, 13:47 UTC · re: Phillip Wood · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

On Tue, Aug 26, 2025 at 12:04 PM Phillip Wood <phillip.wood123@gmail.com> wrote:
Show 24 quoted lines
>
> Hi Usman
>
> On 21/07/2025 12:55, Usman Akinyemi wrote:
> >
> > diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
> > index 6824581317..9fcebb7d94 100755
> > --- a/t/t1517-outside-repo.sh
> > +++ b/t/t1517-outside-repo.sh
> > @@ -110,8 +110,29 @@ test_expect_success LIBCURL 'remote-http outside repository' '
> >   test_expect_success 'update-server-info does not crash with -h' '
> >       test_expect_code 129 git update-server-info -h >usage &&
> >       test_grep "[Uu]sage: git update-server-info " usage &&
> > -     test_expect_code 129 nongit git update-server-info -h >usage &&
> > -     test_grep "[Uu]sage: git update-server-info " usage
> >   '
> >
> > +for cmd in $(git --list-cmds=main)
>
> This lists all the git commands in $PATH which is causing "make test" to
> fail when I run it locally as it is testing all my local "git-*" scripts
> most of which apparently fail this test. If there isn't already we
> should add a option that lists the commands only in $GIT_EXEC_PATH and
> use it here.

That should only happen if you set GIT_TEST_INSTALLED or something, right? Or maybe some even more exotic setup: even with my distro-installed Git, the command doesn't list my git-* scripts in $PATH or installed extensions (like git-when-merged).

> Also when I run the test with '-i' it does not stop at the first
> failure. I'm not sure what's causing that as I thought
> test_expect_success should exit on failure even when it is called in a loop.

That's odd: when I make some modifications that cause a failure and run with "-i," it does stop early. Hm.

Thanks for looking carefully! I'm personally having a hard time reproducing the issue though :/

-- 
D. Ben Knoble
Phillip Wood· Aug 29, 2025, 13:05 UTC · re: D. Ben Knoble · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

Hi Ben
On 28/08/2025 14:47, D. Ben Knoble wrote:
Show 14 quoted lines
> On Tue, Aug 26, 2025 at 12:04 PM Phillip Wood <phillip.wood123@gmail.com> wrote:
>>>
>>> +for cmd in $(git --list-cmds=main)
>>
>> This lists all the git commands in $PATH which is causing "make test" to
>> fail when I run it locally as it is testing all my local "git-*" scripts
>> most of which apparently fail this test. If there isn't already we
>> should add a option that lists the commands only in $GIT_EXEC_PATH and
>> use it here.
> 
> That should only happen if you set GIT_TEST_INSTALLED or something,
> right? Or maybe some even more exotic setup: even with my
> distro-installed Git, the command doesn't list my git-* scripts in
> $PATH or installed extensions (like git-when-merged).

Sorry for the confusion, I've just had another look and it turns out I had some rubbish laying around in the root of my repository which was causing the problem.

Show 9 quoted lines
>> Also when I run the test with '-i' it does not stop at the first
>> failure. I'm not sure what's causing that as I thought
>> test_expect_success should exit on failure even when it is called in a loop.
> 
> That's odd: when I make some modifications that cause a failure and
> run with "-i," it does stop early. Hm.
> 
> Thanks for looking carefully! I'm personally having a hard time
> reproducing the issue though :/

Hmm, I'm not sure what was happening, at the time it looked like the loop was continuing but I can't reproduce it either now.

Thanks for taking a look and sorry for the noise
Phillip
D. Ben Knoble· Aug 29, 2025, 13:22 UTC · re: Phillip Wood · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

On Fri, Aug 29, 2025 at 9:06 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
>
> Hi Ben
[snip]
> Thanks for taking a look and sorry for the noise
>
> Phillip
No worries, glad it worked out!
-- 
D. Ben Knoble
Junio C Hamano· Aug 29, 2025, 16:31 UTC · re: Phillip Wood · lore

Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

Phillip Wood <phillip.wood123@gmail.com> writes:
Show 8 quoted lines
>> That should only happen if you set GIT_TEST_INSTALLED or something,
>> right? Or maybe some even more exotic setup: even with my
>> distro-installed Git, the command doesn't list my git-* scripts in
>> $PATH or installed extensions (like git-when-merged).
>
> Sorry for the confusion, I've just had another look and it turns out I
> had some rubbish laying around in the root of my repository which was
> causing the problem.
I do not think this is something you should feel sorry about.

If you checked out and built 'seen' that invents new commands, and then checked out 'next' that lacks these new commands without first running "make clean" (relying on the mtime of the source will cause rebuilding of necessary things), your build on 'next' will see "some rubbish laying around" that may cause the same issue, no?

As "test" is primarily to help developers, I think we should find a way for this test not to be confused by "some rubbish laying around" if possible.

Thanks.
Usman Akinyemi· Jul 21, 2025, 11:55 UTC · re: Usman Akinyemi · lore

[PATCH v4 2/2] t5200: move `update-server-info -h` test from t1517

t1517 is now focused on testing subcommands outside a repository. Move the in-repo `-h` test for `update-server-info` to t5200, which covers this command.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh       | 5 -----
 t/t5200-update-server-info.sh | 5 +++++
 2 files changed, 5 insertions(+), 5 deletions(-)
Show changes to 2 files +5 −5

t/t1517-outside-repo.sh, t/t5200-update-server-info.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 9fcebb7d94..a1c644dffa 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -107,11 +107,6 @@ test_expect_success LIBCURL 'remote-http outside repository' '
 	test_grep "^error: remote-curl" actual
 '
 
-test_expect_success 'update-server-info does not crash with -h' '
-	test_expect_code 129 git update-server-info -h >usage &&
-	test_grep "[Uu]sage: git update-server-info " usage &&
-'
-
 for cmd in $(git --list-cmds=main)
 do
 	cmd=${cmd%.*} # strip .sh, .perl, etc.
diff --git a/t/t5200-update-server-info.sh b/t/t5200-update-server-info.sh
index 8365907055..a1f129db4e 100755
--- a/t/t5200-update-server-info.sh
+++ b/t/t5200-update-server-info.sh
@@ -46,4 +46,9 @@ test_expect_success 'midx does not create duplicate pack entries' '
 	test_must_be_empty dups
 '
 
+test_expect_success 'update-server-info does not crash with -h' '
+	test_expect_code 129 git update-server-info -h >usage &&
+	test_grep "[Uu]sage: git update-server-info " usage &&
+'
+
 test_done
-- 
2.50.0
D. Ben Knoble· Jul 26, 2025, 16:02 UTC · re: Usman Akinyemi · lore

Re: [PATCH v4 2/2] t5200: move `update-server-info -h` test from t1517

On Mon, Jul 21, 2025 at 7:55 AM Usman Akinyemi <usmanakinyemi202@gmail.com> wrote:

Show 40 quoted lines
>
> t1517 is now focused on testing subcommands outside a repository.
> Move the in-repo `-h` test for `update-server-info` to t5200,
> which covers this command.
>
> Suggested-by: Patrick Steinhardt <ps@pks.im>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
> ---
>  t/t1517-outside-repo.sh       | 5 -----
>  t/t5200-update-server-info.sh | 5 +++++
>  2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
> index 9fcebb7d94..a1c644dffa 100755
> --- a/t/t1517-outside-repo.sh
> +++ b/t/t1517-outside-repo.sh
> @@ -107,11 +107,6 @@ test_expect_success LIBCURL 'remote-http outside repository' '
>         test_grep "^error: remote-curl" actual
>  '
>
> -test_expect_success 'update-server-info does not crash with -h' '
> -       test_expect_code 129 git update-server-info -h >usage &&
> -       test_grep "[Uu]sage: git update-server-info " usage &&
> -'
> -
>  for cmd in $(git --list-cmds=main)
>  do
>         cmd=${cmd%.*} # strip .sh, .perl, etc.
> diff --git a/t/t5200-update-server-info.sh b/t/t5200-update-server-info.sh
> index 8365907055..a1f129db4e 100755
> --- a/t/t5200-update-server-info.sh
> +++ b/t/t5200-update-server-info.sh
> @@ -46,4 +46,9 @@ test_expect_success 'midx does not create duplicate pack entries' '
>         test_must_be_empty dups
>  '
>
> +test_expect_success 'update-server-info does not crash with -h' '
> +       test_expect_code 129 git update-server-info -h >usage &&
> +       test_grep "[Uu]sage: git update-server-info " usage &&

One other fix I needed locally: in neither the preimage nor postimage should this have a trailing "&&"

Show 7 quoted lines
> +'
> +
>  test_done
> --
> 2.50.0
>
>
-- 
D. Ben Knoble
Usman Akinyemi· Aug 3, 2025, 02:07 UTC · re: Usman Akinyemi · lore

[PATCH V5 0/3] refactor t1517 to focus on help output outside a repository

This series refactors t1517-outside-repo.sh to focus on testing `git subcmd -h` outside a Git repository. It does two things:

  1. Moves the existing `update-server-info -h` test to t5200, since it
     tests behavior *inside* a repo and belongs with other update-server-info
     tests.
  
  2. Introduces a loop in t1517 that automatically verifies `-h` output
     for all main Git subcommands when run outside a repository, using
     the `nongit` helper and `git --list-cmds=main`.

This makes t1517 easier to maintain and ensures that new commands are automatically covered for this class of behavior.

Changes since v4:
  - Changes the approach from having the t1517 to test
  both help outside and inside repo to just having inside repo.
  - Drop spurious message during test 
  - Fix known breakages that actually work
  - Fix new t5200 by removing the trailing &&
  - Move the `prune -h` test to t5304
Usman Akinyemi (3):
  t/t1517: automate `git subcmd -h` tests outside a repository
  t5200: move `update-server-info -h` test from t1517
  t5304: move `prune -h` test from t1517
 t/t1517-outside-repo.sh       | 34 +++++++++++++++++++++-------------
 t/t5200-update-server-info.sh |  5 +++++
 t/t5304-prune.sh              |  5 +++++
 3 files changed, 31 insertions(+), 13 deletions(-)
Range-diff against v2:
1:  11eb3e7bfe < -:  ---------- t/t1517: automate `git subcmd -h` tests outside a repository
-:  ---------- > 1:  75a1d540e4 t/t1517: automate `git subcmd -h` tests outside a repository
2:  5cf43192d0 ! 2:  8c028256a0 t5200: move `update-server-info -h` test from t1517
    @@ t/t1517-outside-repo.sh: test_expect_success LIBCURL 'remote-http outside reposi
      
     -test_expect_success 'update-server-info does not crash with -h' '
     -	test_expect_code 129 git update-server-info -h >usage &&
    --	test_grep "[Uu]sage: git update-server-info " usage &&
    +-	test_grep "[Uu]sage: git update-server-info " usage
     -'
     -
    + test_expect_success 'prune does not crash with -h' '
    + 	test_expect_code 129 git prune -h >usage &&
    + 	test_grep "[Uu]sage: git prune " usage &&
    + 	test_expect_code 129 nongit git prune -h >usage &&
    + 	test_grep "[Uu]sage: git prune " usage
    + '
    ++
      for cmd in $(git --list-cmds=main)
      do
      	cmd=${cmd%.*} # strip .sh, .perl, etc.
    @@ t/t5200-update-server-info.sh: test_expect_success 'midx does not create duplica
      
     +test_expect_success 'update-server-info does not crash with -h' '
     +	test_expect_code 129 git update-server-info -h >usage &&
    -+	test_grep "[Uu]sage: git update-server-info " usage &&
    ++	test_grep "[Uu]sage: git update-server-info " usage
     +'
     +
      test_done
-:  ---------- > 3:  c1cdbf272f t5304: move `prune -h` test from t1517
-- 
2.50.1
Usman Akinyemi· Aug 3, 2025, 02:07 UTC · re: Usman Akinyemi · lore

[PATCH V5 1/3] t/t1517: automate `git subcmd -h` tests outside a repository

Replace manual `-h` tests with a loop over all subcommands using `git --list-cmds=main`. This ensures consistent coverage of `-h` behavior outside a repo and future-proofs the test by covering new commands automatically.

Known exceptions are skipped or marked as expected failures.
Suggested-by: Patrick Steinhardt <ps@pks.im>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: D. Ben Knoble <ben.knoble+github@gmail.com>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
Show changes to t/t1517-outside-repo.sh +21 −2
diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 8f59b867f2..4a827b96f0 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -109,8 +109,6 @@ test_expect_success LIBCURL 'remote-http outside repository' '
 
 test_expect_success 'update-server-info does not crash with -h' '
 	test_expect_code 129 git update-server-info -h >usage &&
-	test_grep "[Uu]sage: git update-server-info " usage &&
-	test_expect_code 129 nongit git update-server-info -h >usage &&
 	test_grep "[Uu]sage: git update-server-info " usage
 '
 
@@ -120,5 +118,26 @@ test_expect_success 'prune does not crash with -h' '
 	test_expect_code 129 nongit git prune -h >usage &&
 	test_grep "[Uu]sage: git prune " usage
 '
+for cmd in $(git --list-cmds=main)
+do
+	cmd=${cmd%.*} # strip .sh, .perl, etc.
+	case "$cmd" in
+	archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
+	difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
+	http-backend | http-fetch | http-push | init-db | \
+	merge-octopus | merge-one-file | merge-resolve | mergetool | \
+	mktag | p4 | p4.py | pickaxe | remote-ftp | remote-ftps | \
+	remote-http | remote-https | replay | send-email | \
+	sh-i18n--envsubst | shell | show | stage | submodule | svn | \
+	upload-archive--writer | upload-pack | web--browse | whatchanged)
+		expect_outcome=expect_failure ;;
+	*)
+		expect_outcome=expect_success ;;
+	esac
+	test_$expect_outcome "'git $cmd -h' outside a repository" '
+		test_expect_code 129 nongit git $cmd -h >usage &&
+		test_grep "[Uu]sage: git $cmd " usage
+	'
+done
 
 test_done
-- 
2.50.1
D. Ben Knoble· Aug 3, 2025, 14:52 UTC · re: Usman Akinyemi · lore

Re: [PATCH V5 1/3] t/t1517: automate `git subcmd -h` tests outside a repository

On Sat, Aug 2, 2025 at 10:07 PM Usman Akinyemi <usmanakinyemi202@gmail.com> wrote:

Show 35 quoted lines
>
> Replace manual `-h` tests with a loop over all subcommands using
> `git --list-cmds=main`. This ensures consistent coverage of `-h`
> behavior outside a repo and future-proofs the test by covering
> new commands automatically.
>
> Known exceptions are skipped or marked as expected failures.
>
> Suggested-by: Patrick Steinhardt <ps@pks.im>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Helped-by: D. Ben Knoble <ben.knoble+github@gmail.com>
> Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
> ---
>  t/t1517-outside-repo.sh | 23 +++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
> index 8f59b867f2..4a827b96f0 100755
> --- a/t/t1517-outside-repo.sh
> +++ b/t/t1517-outside-repo.sh
> @@ -109,8 +109,6 @@ test_expect_success LIBCURL 'remote-http outside repository' '
>
>  test_expect_success 'update-server-info does not crash with -h' '
>         test_expect_code 129 git update-server-info -h >usage &&
> -       test_grep "[Uu]sage: git update-server-info " usage &&
> -       test_expect_code 129 nongit git update-server-info -h >usage &&
>         test_grep "[Uu]sage: git update-server-info " usage
>  '
>
> @@ -120,5 +118,26 @@ test_expect_success 'prune does not crash with -h' '
>         test_expect_code 129 nongit git prune -h >usage &&
>         test_grep "[Uu]sage: git prune " usage
>  '
> +for cmd in $(git --list-cmds=main)
> +do

This part of the patch does not apply cleanly to v2.50.0 (the original base of the series), but I was able to apply to latest master (866e6a391f (The sixteenth batch, 2025-08-01)). It seems like the conflict was due to 7cd03a555a (builtin/prune: stop depending on 'the_repository', 2025-07-04).

All fine, just leaving a note for myself ;) I didn't see any mention of the changed base in the cover letter, so I was confused. (Rebasing onto latest master makes sense to me, but I'm not sure what the list convention is).

PS I think we want a newline after the closing quote of the prune test and before the start of the loop.

Show 24 quoted lines
> +       cmd=${cmd%.*} # strip .sh, .perl, etc.
> +       case "$cmd" in
> +       archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
> +       difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
> +       http-backend | http-fetch | http-push | init-db | \
> +       merge-octopus | merge-one-file | merge-resolve | mergetool | \
> +       mktag | p4 | p4.py | pickaxe | remote-ftp | remote-ftps | \
> +       remote-http | remote-https | replay | send-email | \
> +       sh-i18n--envsubst | shell | show | stage | submodule | svn | \
> +       upload-archive--writer | upload-pack | web--browse | whatchanged)
> +               expect_outcome=expect_failure ;;
> +       *)
> +               expect_outcome=expect_success ;;
> +       esac
> +       test_$expect_outcome "'git $cmd -h' outside a repository" '
> +               test_expect_code 129 nongit git $cmd -h >usage &&
> +               test_grep "[Uu]sage: git $cmd " usage
> +       '
> +done
>
>  test_done
> --
> 2.50.1
>

I have had to deal with yet more instaweb issues [1], which I think are because the Windows CI runs without Perl. I'm trying to come up with a fix there, but any advice welcome. (I think we just need to mark that test with the Perl pre-req, but it's interesting that this is the only command I've seen have that problem.)

Looks like Makefile:2664 is the responsible code, which I couldn't find from just looking at the instaweb script (instead had to grep the error message -> grep for use of the "unimplemented" script).

[1]: https://github.com/benknoble/git/actions/runs/16699688470/job/47268852351

-- D. Ben Knoble

Junio C Hamano· Aug 3, 2025, 17:39 UTC · re: D. Ben Knoble · lore

Re: [PATCH V5 1/3] t/t1517: automate `git subcmd -h` tests outside a repository

"D. Ben Knoble" <ben.knoble@gmail.com> writes:
> All fine, just leaving a note for myself ;) I didn't see any mention
> of the changed base in the cover letter, so I was confused. (Rebasing
> onto latest master makes sense to me, but I'm not sure what the list
> convention is).

Once you picked a base, usually it is a good idea to keep it, unless making a trial merge of the resulting topic branch into 'master' leaves conflicts that are not trivial. And I do appreciate your noticing and mentioning that it is recommended to have a comment in the cover letter (or a comment after the three-dash line if a single patch topic) that the new iteration has been based on which commit.

Thanks.
Usman Akinyemi· Aug 6, 2025, 07:20 UTC · re: Junio C Hamano · lore

Re: [PATCH V5 1/3] t/t1517: automate `git subcmd -h` tests outside a repository

On Sun, Aug 3, 2025 at 11:09 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 14 quoted lines
>
> "D. Ben Knoble" <ben.knoble@gmail.com> writes:
>
> > All fine, just leaving a note for myself ;) I didn't see any mention
> > of the changed base in the cover letter, so I was confused. (Rebasing
> > onto latest master makes sense to me, but I'm not sure what the list
> > convention is).
>
> Once you picked a base, usually it is a good idea to keep it, unless
> making a trial merge of the resulting topic branch into 'master'
> leaves conflicts that are not trivial.  And I do appreciate your
> noticing and mentioning that it is recommended to have a comment in
> the cover letter (or a comment after the three-dash line if a single
> patch topic) that the new iteration has been based on which commit.
Thanks for this and noted.
>
> Thanks.
Usman Akinyemi· Aug 3, 2025, 02:07 UTC · re: Usman Akinyemi · lore

[PATCH V5 2/3] t5200: move `update-server-info -h` test from t1517

t1517 is now focused on testing subcommands outside a repository. Move the in-repo `-h` test for `update-server-info` to t5200, which covers this command.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh       | 6 +-----
 t/t5200-update-server-info.sh | 5 +++++
 2 files changed, 6 insertions(+), 5 deletions(-)
Show changes to 2 files +6 −5

t/t1517-outside-repo.sh, t/t5200-update-server-info.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 4a827b96f0..3623272db3 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -107,17 +107,13 @@ test_expect_success LIBCURL 'remote-http outside repository' '
 	test_grep "^error: remote-curl" actual
 '
 
-test_expect_success 'update-server-info does not crash with -h' '
-	test_expect_code 129 git update-server-info -h >usage &&
-	test_grep "[Uu]sage: git update-server-info " usage
-'
-
 test_expect_success 'prune does not crash with -h' '
 	test_expect_code 129 git prune -h >usage &&
 	test_grep "[Uu]sage: git prune " usage &&
 	test_expect_code 129 nongit git prune -h >usage &&
 	test_grep "[Uu]sage: git prune " usage
 '
+
 for cmd in $(git --list-cmds=main)
 do
 	cmd=${cmd%.*} # strip .sh, .perl, etc.
diff --git a/t/t5200-update-server-info.sh b/t/t5200-update-server-info.sh
index 8365907055..a551e955b5 100755
--- a/t/t5200-update-server-info.sh
+++ b/t/t5200-update-server-info.sh
@@ -46,4 +46,9 @@ test_expect_success 'midx does not create duplicate pack entries' '
 	test_must_be_empty dups
 '
 
+test_expect_success 'update-server-info does not crash with -h' '
+	test_expect_code 129 git update-server-info -h >usage &&
+	test_grep "[Uu]sage: git update-server-info " usage
+'
+
 test_done
-- 
2.50.1
Usman Akinyemi· Aug 3, 2025, 02:07 UTC · re: Usman Akinyemi · lore

[PATCH V5 3/3] t5304: move `prune -h` test from t1517

t1517 is now focused on testing subcommands outside a repository. Move the in-repo `-h` test for `prune` to t5304, which covers this command.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh | 7 -------
 t/t5304-prune.sh        | 5 +++++
 2 files changed, 5 insertions(+), 7 deletions(-)
Show changes to 2 files +5 −7

t/t1517-outside-repo.sh, t/t5304-prune.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 3623272db3..8a417af47a 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -107,13 +107,6 @@ test_expect_success LIBCURL 'remote-http outside repository' '
 	test_grep "^error: remote-curl" actual
 '
 
-test_expect_success 'prune does not crash with -h' '
-	test_expect_code 129 git prune -h >usage &&
-	test_grep "[Uu]sage: git prune " usage &&
-	test_expect_code 129 nongit git prune -h >usage &&
-	test_grep "[Uu]sage: git prune " usage
-'
-
 for cmd in $(git --list-cmds=main)
 do
 	cmd=${cmd%.*} # strip .sh, .perl, etc.
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
index 1f1f664871..2be7cd30de 100755
--- a/t/t5304-prune.sh
+++ b/t/t5304-prune.sh
@@ -364,4 +364,9 @@ test_expect_success 'gc.recentObjectsHook' '
 	git cat-file -p $BLOB
 '
 
+test_expect_success 'prune does not crash with -h' '
+	test_expect_code 129 git prune -h >usage &&
+	test_grep "[Uu]sage: git prune " usage
+'
+
 test_done
-- 
2.50.1
Usman Akinyemi· Aug 8, 2025, 01:06 UTC · re: Usman Akinyemi · lore

[PATCH v6 0/3] refactor t1517 to focus on help output outside a repository

This series refactors t1517-outside-repo.sh to focus on testing `git subcmd -h` outside a Git repository. It does two things:

  1. Moves the existing `update-server-info -h` test to t5200, since it
     tests behavior inside a repo and belongs with other update-server-info
     tests.
  2. Moves the existing `prune -h` test to t5304, since it
     tests behavior inside a repo and belongs with other prune tests.
  3. Introduces a loop in t1517 that automatically verifies `-h` output
     for all main Git subcommands when run outside a repository, using
     the `nongit` helper and `git --list-cmds=main`.

This makes t1517 easier to maintain and ensures that new commands are automatically covered for this class of behavior.

Changes since v5:
- fix instaweb test using PERL prereqs (helped by Ben)

Note: This new iteration is based on 7cd03a555a (builtin/prune: stop depending on 'the_repository', 2025-07-04) commit.

Usman Akinyemi (3):
  t/t1517: automate `git subcmd -h` tests outside a repository
  t5200: move `update-server-info -h` test from t1517
  t5304: move `prune -h` test from t1517
 t/t1517-outside-repo.sh       | 40 +++++++++++++++++++++++------------
 t/t5200-update-server-info.sh |  5 +++++
 t/t5304-prune.sh              |  5 +++++
 3 files changed, 37 insertions(+), 13 deletions(-)
-- 
2.50.1
Usman Akinyemi· Aug 8, 2025, 01:06 UTC · re: Usman Akinyemi · lore

[PATCH v6 1/3] t/t1517: automate `git subcmd -h` tests outside a repository

Replace manual `-h` tests with a loop over all subcommands using `git --list-cmds=main`. This ensures consistent coverage of `-h` behavior outside a repo and future-proofs the test by covering new commands automatically.

Known exceptions are skipped or marked as expected failures.
Suggested-by: Patrick Steinhardt <ps@pks.im>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: D. Ben Knoble <ben.knoble+github@gmail.com>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
Show changes to t/t1517-outside-repo.sh +28 −2
diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 8f59b867f2..e9f6d03e1b 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -109,8 +109,6 @@ test_expect_success LIBCURL 'remote-http outside repository' '
 
 test_expect_success 'update-server-info does not crash with -h' '
 	test_expect_code 129 git update-server-info -h >usage &&
-	test_grep "[Uu]sage: git update-server-info " usage &&
-	test_expect_code 129 nongit git update-server-info -h >usage &&
 	test_grep "[Uu]sage: git update-server-info " usage
 '
 
@@ -121,4 +119,32 @@ test_expect_success 'prune does not crash with -h' '
 	test_grep "[Uu]sage: git prune " usage
 '
 
+for cmd in $(git --list-cmds=main)
+do
+	cmd=${cmd%.*} # strip .sh, .perl, etc.
+	case "$cmd" in
+	archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
+	difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
+	http-backend | http-fetch | http-push | init-db | \
+	merge-octopus | merge-one-file | merge-resolve | mergetool | \
+	mktag | p4 | p4.py | pickaxe | remote-ftp | remote-ftps | \
+	remote-http | remote-https | replay | send-email | \
+	sh-i18n--envsubst | shell | show | stage | submodule | svn | \
+	upload-archive--writer | upload-pack | web--browse | whatchanged)
+		expect_outcome=expect_failure ;;
+	*)
+		expect_outcome=expect_success ;;
+	esac
+	case "$cmd" in
+	instaweb)
+		prereq=PERL ;;
+	*)
+		prereq= ;;
+	esac
+	test_$expect_outcome $prereq "'git $cmd -h' outside a repository" '
+		test_expect_code 129 nongit git $cmd -h >usage &&
+		test_grep "[Uu]sage: git $cmd " usage
+	'
+done
+
 test_done
-- 
2.50.1
Usman Akinyemi· Aug 8, 2025, 01:06 UTC · re: Usman Akinyemi · lore

[PATCH v6 2/3] t5200: move `update-server-info -h` test from t1517

t1517 is now focused on testing subcommands outside a repository. Move the in-repo `-h` test for `update-server-info` to t5200, which covers this command.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh       | 5 -----
 t/t5200-update-server-info.sh | 5 +++++
 2 files changed, 5 insertions(+), 5 deletions(-)
Show changes to 2 files +5 −5

t/t1517-outside-repo.sh, t/t5200-update-server-info.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index e9f6d03e1b..4eba3f486d 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -107,11 +107,6 @@ test_expect_success LIBCURL 'remote-http outside repository' '
 	test_grep "^error: remote-curl" actual
 '
 
-test_expect_success 'update-server-info does not crash with -h' '
-	test_expect_code 129 git update-server-info -h >usage &&
-	test_grep "[Uu]sage: git update-server-info " usage
-'
-
 test_expect_success 'prune does not crash with -h' '
 	test_expect_code 129 git prune -h >usage &&
 	test_grep "[Uu]sage: git prune " usage &&
diff --git a/t/t5200-update-server-info.sh b/t/t5200-update-server-info.sh
index 8365907055..a551e955b5 100755
--- a/t/t5200-update-server-info.sh
+++ b/t/t5200-update-server-info.sh
@@ -46,4 +46,9 @@ test_expect_success 'midx does not create duplicate pack entries' '
 	test_must_be_empty dups
 '
 
+test_expect_success 'update-server-info does not crash with -h' '
+	test_expect_code 129 git update-server-info -h >usage &&
+	test_grep "[Uu]sage: git update-server-info " usage
+'
+
 test_done
-- 
2.50.1
Usman Akinyemi· Aug 8, 2025, 01:06 UTC · re: Usman Akinyemi · lore

[PATCH v6 3/3] t5304: move `prune -h` test from t1517

t1517 is now focused on testing subcommands outside a repository. Move the in-repo `-h` test for `prune` to t5304, which covers this command.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh | 7 -------
 t/t5304-prune.sh        | 5 +++++
 2 files changed, 5 insertions(+), 7 deletions(-)
Show changes to 2 files +5 −7

t/t1517-outside-repo.sh, t/t5304-prune.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 4eba3f486d..3dc602872a 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -107,13 +107,6 @@ test_expect_success LIBCURL 'remote-http outside repository' '
 	test_grep "^error: remote-curl" actual
 '
 
-test_expect_success 'prune does not crash with -h' '
-	test_expect_code 129 git prune -h >usage &&
-	test_grep "[Uu]sage: git prune " usage &&
-	test_expect_code 129 nongit git prune -h >usage &&
-	test_grep "[Uu]sage: git prune " usage
-'
-
 for cmd in $(git --list-cmds=main)
 do
 	cmd=${cmd%.*} # strip .sh, .perl, etc.
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
index 1f1f664871..2be7cd30de 100755
--- a/t/t5304-prune.sh
+++ b/t/t5304-prune.sh
@@ -364,4 +364,9 @@ test_expect_success 'gc.recentObjectsHook' '
 	git cat-file -p $BLOB
 '
 
+test_expect_success 'prune does not crash with -h' '
+	test_expect_code 129 git prune -h >usage &&
+	test_grep "[Uu]sage: git prune " usage
+'
+
 test_done
-- 
2.50.1
Junio C Hamano· Aug 8, 2025, 14:53 UTC · re: Usman Akinyemi · lore

Re: [PATCH v6 0/3] refactor t1517 to focus on help output outside a repository

Usman Akinyemi <usmanakinyemi202@gmail.com> writes:
> This series refactors t1517-outside-repo.sh to focus on testing
> `git subcmd -h` outside a Git repository. It does two things:

Thanks, Usman and Ben. This iteration looks perfect. Let's mark it for 'next'.

D. Ben Knoble· Aug 9, 2025, 14:46 UTC · re: Junio C Hamano · lore

Re: [PATCH v6 0/3] refactor t1517 to focus on help output outside a repository

On Fri, Aug 8, 2025 at 10:53 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
>
> Usman Akinyemi <usmanakinyemi202@gmail.com> writes:
>
> > This series refactors t1517-outside-repo.sh to focus on testing
> > `git subcmd -h` outside a Git repository. It does two things:
>
> Thanks, Usman and Ben.  This iteration looks perfect.  Let's mark it
> for 'next'.
>

Excellent! In the recent "cooking" mail it looks like my series was recreated atop this one, so I won't send another version just to drop the fixup patch unless there are other comments to address.

-- 
D. Ben Knoble
Usman Akinyemi· Jul 6, 2025, 21:50 UTC · re: Usman Akinyemi · lore

[PATCH v3 7/7] t/t1517: move verify-tag -h test to t1517

The test 'verify-tag does not crash with -h' checks that the command exits cleanly with usage information, both inside and outside of a repository.

Move this test from "t/t7030-verify-tag.sh" to "t1517-outside-repo.sh" since it better fits with tests that check command behavior outside a repository.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t1517-outside-repo.sh | 7 +++++++
 t/t7030-verify-tag.sh   | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 2 files +7 −7

t/t1517-outside-repo.sh, t/t7030-verify-tag.sh

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 8a46fdfdd1..25ec3b3978 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -156,4 +156,11 @@ test_expect_success 'verify-commit does not crash with -h' '
 	test_grep "[Uu]sage: git verify-commit " usage
 '
 
+test_expect_success 'verify-tag does not crash with -h' '
+	test_expect_code 129 git verify-tag -h >usage &&
+	test_grep "[Uu]sage: git verify-tag " usage &&
+	test_expect_code 129 nongit git verify-tag -h >usage &&
+	test_grep "[Uu]sage: git verify-tag " usage
+'
+
 test_done
diff --git a/t/t7030-verify-tag.sh b/t/t7030-verify-tag.sh
index 2c147072c1..6f526c37c2 100755
--- a/t/t7030-verify-tag.sh
+++ b/t/t7030-verify-tag.sh
@@ -7,13 +7,6 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 . ./test-lib.sh
 . "$TEST_DIRECTORY/lib-gpg.sh"
 
-test_expect_success GPG 'verify-tag does not crash with -h' '
-	test_expect_code 129 git verify-tag -h >usage &&
-	test_grep "[Uu]sage: git verify-tag " usage &&
-	test_expect_code 129 nongit git verify-tag -h >usage &&
-	test_grep "[Uu]sage: git verify-tag " usage
-'
-
 test_expect_success GPG 'create signed tags' '
 	echo 1 >file && git add file &&
 	test_tick && git commit -m initial &&
-- 
2.50.0

← back to recent threads