summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Ævar Arnfjörð Bjarmason <avarab@gmail.com>2022-03-17 19:08:39 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2022-03-23 15:26:39 -0700
commite3c3675801f6d7494ac11e772e848981d1e158b4 (patch)
treebdf4a0281defe3227482c5df48352144f8ee3ea1 /t
parentreflog exists: use parse_options() API (diff)
downloadtgif-e3c3675801f6d7494ac11e772e848981d1e158b4.tar.xz
reflog: convert to parse_options() API
Continue the work started in 33d7bdd6459 (builtin/reflog.c: use parse-options api for expire, delete subcommands, 2022-01-06) and convert the cmd_reflog() function itself to use the parse_options() API. Let's also add a test which would fail if we forgot PARSE_OPT_NO_INTERNAL_HELP here, as well as making sure that we'll still pass through "--" by supplying PARSE_OPT_KEEP_DASHDASH. For that test we need to change "test_commit()" to accept files starting with "--". The "git reflog -h" usage will now show the usage for all of the sub-commands, rather than a terse summary which wasn't correct (e.g. "git reflog exists" is not a valid command). See my 8757b35d443 (commit-graph: define common usage with a macro, 2021-08-23) for prior art. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1410-reflog.sh17
-rw-r--r--t/test-lib-functions.sh2
2 files changed, 18 insertions, 1 deletions
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index 68f69bb543..0dc36d842b 100755
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
@@ -106,6 +106,23 @@ test_expect_success setup '
test_line_count = 4 output
'
+test_expect_success 'correct usage on sub-command -h' '
+ test_expect_code 129 git reflog expire -h >err &&
+ grep "git reflog expire" err
+'
+
+test_expect_success 'pass through -- to sub-command' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ test_commit -C repo message --a-file contents dash-tag &&
+
+ git -C repo reflog show -- --does-not-exist >out &&
+ test_must_be_empty out &&
+ git -C repo reflog show >expect &&
+ git -C repo reflog show -- --a-file >actual &&
+ test_cmp expect actual
+'
+
test_expect_success rewind '
test_tick && git reset --hard HEAD~2 &&
test -f C &&
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 0f439c99d6..1d00474458 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -329,7 +329,7 @@ test_commit () {
else
$echo "${3-$1}" >"$indir$file"
fi &&
- git ${indir:+ -C "$indir"} add "$file" &&
+ git ${indir:+ -C "$indir"} add -- "$file" &&
if test -z "$notick"
then
test_tick