All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fien Dora <fiendora5@gmail.com>
To: git@vger.kernel.org
Cc: christian.couder@gmail.com, siddharthasthana31@gmail.com,
	phillip.wood123@gmail.com, gitster@pobox.com
Subject: [Outreachy PATCH v3] t1402: test --no-allow-onelevel option precedence
Date: Thu, 29 Oct 2026 13:17:15 +0100	[thread overview]
Message-ID: <20261029121715.3845-1-fiendora5@gmail.com> (raw)
In-Reply-To: <20261027145451.8617-1-fiendora5@gmail.com>

Unlike most Git commands that use the parse_options() API,
check-ref-format relies on a handcrafted loop to parse command-line
options. Although the --no- prefix is commonly used to negate options
in Git, the precedence of --allow-onelevel and --no-allow-onelevel
is not explicitly covered by the existing tests.

Add regression tests for both orders of --allow-onelevel and
--no-allow-onelevel to verify that the last option takes precedence.
The tests confirm that --no-allow-onelevel overrides a preceding
--allow-onelevel, and that --allow-onelevel similarly overrides a
preceding --no-allow-onelevel.

To improve Git's command-line argument parsing, I plan to
explore converting check-ref-format's handcrafted parser to
parse_options() API in a separate patch series. These tests
establish the current option-precedence behavior that the
conversion would need to preserve.

Signed-off-by: Fien Dora <fiendora5@gmail.com>
---

Changes since v2:
- Clarify that converting check-ref-format to parse_options()
  is work I plan to explore in a separate patch series, not
  an existing Git development plan.
- No changes to the tests.

 t/t1402-check-ref-format.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/t/t1402-check-ref-format.sh b/t/t1402-check-ref-format.sh
index 9dd64662b2..6036df0210 100755
--- a/t/t1402-check-ref-format.sh
+++ b/t/t1402-check-ref-format.sh
@@ -74,6 +74,8 @@ invalid_ref 'heads/foo*/bar*' --refspec-pattern
 ref='foo'
 invalid_ref "$ref"
 valid_ref "$ref" --allow-onelevel
+invalid_ref "$ref" '--allow-onelevel --no-allow-onelevel'
+valid_ref "$ref" '--no-allow-onelevel --allow-onelevel'
 invalid_ref "$ref" --refspec-pattern
 valid_ref "$ref" '--refspec-pattern --allow-onelevel'
 invalid_ref "$ref" --normalize
-- 
2.50.1 (Apple Git-155)


      parent reply	other threads:[~2026-10-29 12:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 13:25 [Outreachy PATCH] t1402: test --no-allow-onelevel option precedence Fien Dora
2026-10-26 21:06 ` Junio C Hamano
2026-10-27 11:56   ` Fien Dora
2026-10-27 16:29     ` Junio C Hamano
2026-10-28 19:49       ` Fien Dora
2026-10-28 20:00       ` Fien Dora
2026-10-27 14:54 ` [Outreachy PATCH v2] " Fien Dora
2026-10-27 17:59   ` Junio C Hamano
2026-10-28 20:22     ` Fien Dora
2026-10-29 12:17   ` Fien Dora [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261029121715.3845-1-fiendora5@gmail.com \
    --to=fiendora5@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=phillip.wood123@gmail.com \
    --cc=siddharthasthana31@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.