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

Re: [PATCH 3/4] t5510: prefer "git -C" to subshell for followRemoteHEAD tests

From
Jeff King <peff@peff.net>
Date
Aug 26, 2025, 03:44 UTC
Message-ID
<20250826034434.GB388997@coredump.intra.peff.net>
In-Reply-To
<xmqqfrdftnet.fsf@gitster.g>
On Mon, Aug 25, 2025 at 08:46:02AM -0700, Junio C Hamano wrote:
Show 13 quoted lines
> > I for one think that the original is much more readable.
> >
> > With the subshell it's quite clear, even at a cursory glance, which
> > commands are executed in a subdirectory, but when using '-C dir' all
> > over we have to look closely.  Furthermore, when there is a command
> > outside of the subshell, we can be fairly sure that it's intentional,
> > but when a command without '-C dir' lurks among many others using '-C
> > dir', then we can't be so sure, but have to investigate whether that
> > was intentional or oversight.
> 
> Unfortunately I tend to agree.  A few downsides I find a bit
> problematic in the subshell solution are
> [...]

OK, I am happy to drop that patch (3/4). The resulting change to the final patch to match style would be:

diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 6e8b741491..bac464a9ec 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -269,12 +269,16 @@ test_expect_success 'followRemoteHEAD does not kick in with refspecs' '
 '
 
 test_expect_success 'followRemoteHEAD create does not overwrite dangling symref' '
-	git -C two remote add -m does-not-exist custom-head ../one &&
-	test_config -C two remote.custom-head.followRemoteHEAD create &&
-	git -C two fetch custom-head &&
-	echo refs/remotes/custom-head/does-not-exist >expect &&
-	git -C two symbolic-ref refs/remotes/custom-head/HEAD >actual &&
-	test_cmp expect actual
+	test_when_finished "git -C two config unset remote.custom-head.followRemoteHEAD" &&
+	(
+		cd two &&
+		git remote add -m does-not-exist custom-head ../one &&
+		git config remote.custom-head.followRemoteHEAD create &&
+		git fetch custom-head &&
+		echo refs/remotes/custom-head/does-not-exist >expect &&
+		git symbolic-ref refs/remotes/custom-head/HEAD >actual &&
+		test_cmp expect actual
+	)
 '
 
 test_expect_success 'fetch --prune on its own works as expected' '


But both patches are already in 'next'. How do you want to proceed? I
can prepare a patch on top converting back to sub-shells. Or if we are
going to do the post-release rewind of next, that is an opportunity to
fix things cleanly. Or we could leave it as-is if it is not worth the
bother at this point.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 22 in “dangling symrefs and fetchRemoteHEAD=create”
  1. 0/4 dangling symrefs and fetchRemoteHEAD=createJeff King, Aug 19, 2025
  2. Jeff KingAug 19, 2025
  3. 1/4 t5510: make confusing config cleanup more explicitJeff King, Aug 19, 2025
  4. Eric SunshineAug 19, 2025
  5. Eric SunshineAug 19, 2025
  6. Jeff KingAug 19, 2025
  7. 2/4 t5510: stop changing top-level working directoryJeff King, Aug 19, 2025
  8. 3/4 t5510: prefer "git -C" to subshell for followRemoteHEAD testsJeff King, Aug 19, 2025
  9. SZEDER GáborAug 24, 2025
  10. Junio C HamanoAug 25, 2025
  11. Jeff KingAug 26, 2025
  12. Junio C HamanoAug 26, 2025
  13. 4/4 refs: do not clobber dangling symrefsJeff King, Aug 19, 2025
  14. Patrick SteinhardtAug 20, 2025
  15. Jeff KingAug 20, 2025
  16. Toon ClaesSep 22, 2025
  17. Junio C HamanoSep 22, 2025
  18. Jeff KingSep 22, 2025
  19. Junio C HamanoSep 22, 2025
  20. Jeff KingSep 22, 2025
  21. Toon ClaesSep 23, 2025
  22. Jeff KingSep 23, 2025

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

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