t: add test for git refs optimize subcommand
Add a test script, `t/t1463-refs-optimize.sh`, for the new `git refs optimize` command. This script acts as a simple driver, leveraging the shared test library created in the preceding commit. It works by overriding the `$pack_refs` variable to "refs optimize" and then sourcing the shared library (`t/pack-refs-tests.sh`). This approach ensures that `git refs optimize` is tested against the entire comprehensive test suite of `git pack-refs`, verifying that it acts as a compatible drop-in replacement. Mentored-by: Patrick Steinhardt <ps@pks.im> Mentored-by: shejialuo <shejialuo@gmail.com> Signed-off-by: Meet Soni <meetsoni3017@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Meet Soni committed
Sep 19, 2025 at 13:56 UTC
c44afd67d2bcfc2958e7cc79d7064ab5fcfa468a
2 files changed
+19
-1
t/meson.build
+2
-1
@@ -211,6 +211,7 @@ integration_tests = [
211
't1451-fsck-buffer.sh',
212
't1460-refs-migrate.sh',
213
't1461-refs-list.sh',
214
+ 't1463-refs-optimize.sh',
215
't1500-rev-parse.sh',
216
't1501-work-tree.sh',
217
't1502-rev-parse-parseopt.sh',
@@ -1219,4 +1220,4 @@ if perl.found() and time.found()
1220
timeout: 0,
1221
)
1222
endforeach
1222
-endif
\ No newline at end of file
1223
+endif
t/t1463-refs-optimize.sh
new
+17
@@ -0,0 +1,17 @@
1
+#!/bin/sh
2
+
3
+test_description='git refs optimize should not change the branch semantic
4
+
5
+This test runs git refs optimize and git show-ref and checks that the branch
6
+semantic is still the same.
7
+'
8
+
9
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
10
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11
+GIT_TEST_DEFAULT_REF_FORMAT=files
12
+export GIT_TEST_DEFAULT_REF_FORMAT
13
+
14
+. ./test-lib.sh
15
+
16
+pack_refs='refs optimize'
17
+. "$TEST_DIRECTORY"/pack-refs-tests.sh