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

Re: [GSoC][PATCH 2/2] t: add test for git refs exists subcommand

From
Patrick Steinhardt <ps@pks.im>
Date
Aug 21, 2025, 10:21 UTC
Message-ID
<aKbzNNcZZ-E0FVeI@pks.im>
In-Reply-To
<20250821085246.929307-3-meetsoni3017@gmail.com>
On Thu, Aug 21, 2025 at 02:22:46PM +0530, Meet Soni wrote:
Show 9 quoted lines
> The new `git refs exists` subcommand must have identical behavior to its
> predecessor, `git show-ref --exists`. To avoid duplicating the entire
> test suite, refactor the existing tests into a shareable helper script.
> 
> Extract the tests for the `--exists` flag from `t1403-show-ref.sh` into
> a new `show-ref-exists-tests.sh` helper. The command under test is
> parameterized using the `$git_show_ref_exists` variable.
> 
> Source new helper to both `t1403-show-ref.sh` and the new test file,
s/new/this/, otherwise this reads grammatically wrong to me.
Show 25 quoted lines
>  test_done
> diff --git a/t/t1462-refs-exists.sh b/t/t1462-refs-exists.sh
> new file mode 100755
> index 0000000000..c00d76cc9e
> --- /dev/null
> +++ b/t/t1462-refs-exists.sh
> @@ -0,0 +1,22 @@
> +#!/bin/sh
> +
> +test_description='refs exists'
> +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
> +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
> +
> +. ./test-lib.sh
> +
> +git_show_ref_exists='git refs exists'
> +
> +test_expect_success setup '
> +	test_commit --annotate A &&
> +	git checkout -b side &&
> +	test_commit --annotate B &&
> +	git checkout main &&
> +	test_commit C &&
> +	git branch B A^0
> +'

It's a bit weird that this setup needs to be replicated. I guess it comes from the fact that t1403 also has a bunch of other tests for git-show-ref(1) that are irrelevant to existence checks.

How about we instead split out the existence-checks in t1403 into a separate test suite first and then pull out the whole logic from it in a subsequent commit so that we can also share the setup?

Patrick
Previous: Meet SoniNext: Meet Soni
Message 5 of 23 in “Add refs exists subcommand”
  1. Meet SoniAug 21, 2025
  2. [GSoC][PATCH 1/2] builtin/refs: add 'exists' subcommandMeet Soni, Aug 21, 2025
  3. Patrick SteinhardtAug 21, 2025
  4. [GSoC][PATCH 2/2] t: add test for git refs exists subcommandMeet Soni, Aug 21, 2025
  5. Patrick SteinhardtAug 21, 2025
  6. Meet SoniAug 22, 2025
  7. Patrick SteinhardtAug 21, 2025
  8. Junio C HamanoAug 21, 2025
  9. Meet SoniAug 22, 2025
  10. [GSoC][PATCH v2 0/4] Add refs exists subcommandMeet Soni, Aug 23, 2025
  11. [GSoC][PATCH v2 1/4] builtin/refs: add 'exists' subcommandMeet Soni, Aug 23, 2025
  12. [GSoC][PATCH v2 2/4] t1403: split 'show-ref --exists' tests into a separate fileMeet Soni, Aug 23, 2025
  13. [GSoC][PATCH v2 3/4] t1422: refactor tests to be shareableMeet Soni, Aug 23, 2025
  14. Patrick SteinhardtAug 24, 2025
  15. [GSoC][PATCH v2 4/4] t: add test for git refs exists subcommandMeet Soni, Aug 23, 2025
  16. Patrick SteinhardtAug 24, 2025
  17. [GSoC][PATCH v3 0/4] Add refs exists subcommandMeet Soni, Aug 26, 2025
  18. [GSoC][PATCH v3 1/4] builtin/refs: add 'exists' subcommandMeet Soni, Aug 26, 2025
  19. [GSoC][PATCH v3 2/4] t1403: split 'show-ref --exists' tests into a separate fileMeet Soni, Aug 26, 2025
  20. [GSoC][PATCH v3 3/4] t1422: refactor tests to be shareableMeet Soni, Aug 26, 2025
  21. [GSoC][PATCH v3 4/4] t: add test for git refs exists subcommandMeet Soni, Aug 26, 2025
  22. Patrick SteinhardtSep 2, 2025
  23. Junio C HamanoSep 2, 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.