From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: Taylor Blau <me@ttaylorr.com>, Junio C Hamano <gitster@pobox.com>,
Eric Sunshine <sunshine@sunshineco.com>,
Han-Wen Nienhuys <hanwen@google.com>
Subject: [PATCH v3 00/12] builtin/show-ref: introduce mode to check for ref existence
Date: Tue, 31 Oct 2023 09:16:08 +0100 [thread overview]
Message-ID: <cover.1698739941.git.ps@pks.im> (raw)
In-Reply-To: <cover.1698152926.git.ps@pks.im>
[-- Attachment #1: Type: text/plain, Size: 5399 bytes --]
Hi,
this is the third version of my patch series that introduces a new `git
show-ref --exists` mode to check for reference existence.
Changes compared to v2:
- Patch 5: Document why we need `exclude_existing_options.enabled`,
which isn't exactly obvious.
- Patch 6: Fix a grammar issue in the commit message.
- Patch 9: Switch to `test_cmp` instead of grep(1).
Thanks!
Patrick
Patrick Steinhardt (12):
builtin/show-ref: convert pattern to a local variable
builtin/show-ref: split up different subcommands
builtin/show-ref: fix leaking string buffer
builtin/show-ref: fix dead code when passing patterns
builtin/show-ref: refactor `--exclude-existing` options
builtin/show-ref: stop using global variable to count matches
builtin/show-ref: stop using global vars for `show_one()`
builtin/show-ref: refactor options for patterns subcommand
builtin/show-ref: ensure mutual exclusiveness of subcommands
builtin/show-ref: explicitly spell out different modes in synopsis
builtin/show-ref: add new mode to check for reference existence
t: use git-show-ref(1) to check for ref existence
Documentation/git-show-ref.txt | 20 ++-
builtin/show-ref.c | 284 ++++++++++++++++++++++-----------
t/t1403-show-ref.sh | 70 ++++++++
t/t1430-bad-ref-name.sh | 27 ++--
t/t3200-branch.sh | 33 ++--
t/t5521-pull-options.sh | 4 +-
t/t5605-clone-local.sh | 2 +-
t/test-lib-functions.sh | 55 +++++++
8 files changed, 373 insertions(+), 122 deletions(-)
Range-diff against v2:
1: 78163accbd2 = 1: 9570ad63924 builtin/show-ref: convert pattern to a local variable
2: 9a234622d99 = 2: 773c6119750 builtin/show-ref: split up different subcommands
3: bb0d656a0b4 = 3: b6f4c0325bf builtin/show-ref: fix leaking string buffer
4: 87afcee830c = 4: 4605c6f0ac9 builtin/show-ref: fix dead code when passing patterns
5: bed2a8a0769 ! 5: b47440089b6 builtin/show-ref: refactor `--exclude-existing` options
@@ builtin/show-ref.c: static int add_existing(const char *refname,
}
+struct exclude_existing_options {
++ /*
++ * We need an explicit `enabled` field because it is perfectly valid
++ * for `pattern` to be `NULL` even if `--exclude-existing` was given.
++ */
+ int enabled;
+ const char *pattern;
+};
6: d52a5e8ced2 ! 6: 6172888e465 builtin/show-ref: stop using global variable to count matches
@@ Commit message
builtin/show-ref: stop using global variable to count matches
When passing patterns to git-show-ref(1) we're checking whether any
- reference matches -- if none does, we indicate this condition via an
+ reference matches -- if none do, we indicate this condition via an
unsuccessful exit code.
We're using a global variable to count these matches, which is required
7: 63f1dadf4c2 = 7: bc528db7667 builtin/show-ref: stop using global vars for `show_one()`
8: 88dfeaa4871 = 8: e3882c07dfc builtin/show-ref: refactor options for patterns subcommand
9: 5ba566723e8 ! 9: a095decd778 builtin/show-ref: ensure mutual exclusiveness of subcommands
@@ t/t1403-show-ref.sh: test_expect_success 'show-ref --verify with dangling ref' '
'
+test_expect_success 'show-ref sub-modes are mutually exclusive' '
++ cat >expect <<-EOF &&
++ fatal: only one of ${SQ}--exclude-existing${SQ} or ${SQ}--verify${SQ} can be given
++ EOF
++
+ test_must_fail git show-ref --verify --exclude-existing 2>err &&
-+ grep "only one of ${SQ}--exclude-existing${SQ} or ${SQ}--verify${SQ} can be given" err
++ test_cmp expect err
+'
+
test_done
10: b78ccc5f692 = 10: 087384fd2fd builtin/show-ref: explicitly spell out different modes in synopsis
11: 327942b1162 ! 11: ca5187bb18a builtin/show-ref: add new mode to check for reference existence
@@ builtin/show-ref.c: int cmd_show_ref(int argc, const char **argv, const char *pr
## t/t1403-show-ref.sh ##
@@ t/t1403-show-ref.sh: test_expect_success 'show-ref --verify with dangling ref' '
- '
test_expect_success 'show-ref sub-modes are mutually exclusive' '
-+ cat >expect <<-EOF &&
+ cat >expect <<-EOF &&
+- fatal: only one of ${SQ}--exclude-existing${SQ} or ${SQ}--verify${SQ} can be given
+ fatal: only one of ${SQ}--exclude-existing${SQ}, ${SQ}--verify${SQ} or ${SQ}--exists${SQ} can be given
-+ EOF
-+
+ EOF
+
test_must_fail git show-ref --verify --exclude-existing 2>err &&
-- grep "only one of ${SQ}--exclude-existing${SQ} or ${SQ}--verify${SQ} can be given" err
+ test_cmp expect err &&
+
+ test_must_fail git show-ref --verify --exists 2>err &&
@@ t/t1403-show-ref.sh: test_expect_success 'show-ref --verify with dangling ref' '
+ error: failed to look up reference: Is a directory
+ EOF
+ test_expect_code 1 git show-ref --exists refs/heads 2>err &&
-+ test_cmp expect err
+ test_cmp expect err
'
- test_done
12: 226731c5f18 = 12: ea9919fe899 t: use git-show-ref(1) to check for ref existence
base-commit: a9ecda2788e229afc9b611acaa26d0d9d4da53ed
--
2.42.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-10-31 8:16 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-24 13:10 [PATCH 00/12] show-ref: introduce mode to check for ref existence Patrick Steinhardt
2023-10-24 13:10 ` [PATCH 01/12] builtin/show-ref: convert pattern to a local variable Patrick Steinhardt
2023-10-24 13:10 ` [PATCH 02/12] builtin/show-ref: split up different subcommands Patrick Steinhardt
2023-10-24 17:55 ` Eric Sunshine
2023-10-24 13:10 ` [PATCH 03/12] builtin/show-ref: fix leaking string buffer Patrick Steinhardt
2023-10-24 13:10 ` [PATCH 04/12] builtin/show-ref: fix dead code when passing patterns Patrick Steinhardt
2023-10-24 18:02 ` Eric Sunshine
2023-10-24 13:10 ` [PATCH 05/12] builtin/show-ref: refactor `--exclude-existing` options Patrick Steinhardt
2023-10-24 18:48 ` Eric Sunshine
2023-10-25 11:50 ` Patrick Steinhardt
2023-10-24 13:11 ` [PATCH 06/12] builtin/show-ref: stop using global variable to count matches Patrick Steinhardt
2023-10-24 13:11 ` [PATCH 07/12] builtin/show-ref: stop using global vars for `show_one()` Patrick Steinhardt
2023-10-24 13:11 ` [PATCH 08/12] builtin/show-ref: refactor options for patterns subcommand Patrick Steinhardt
2023-10-24 13:11 ` [PATCH 09/12] builtin/show-ref: ensure mutual exclusiveness of subcommands Patrick Steinhardt
2023-10-24 19:25 ` Eric Sunshine
2023-10-24 13:11 ` [PATCH 10/12] builtin/show-ref: explicitly spell out different modes in synopsis Patrick Steinhardt
2023-10-24 19:39 ` Eric Sunshine
2023-10-25 11:50 ` Patrick Steinhardt
2023-10-24 13:11 ` [PATCH 11/12] builtin/show-ref: add new mode to check for reference existence Patrick Steinhardt
2023-10-24 21:01 ` Eric Sunshine
2023-10-25 11:50 ` Patrick Steinhardt
2023-10-24 13:11 ` [PATCH 12/12] t: use git-show-ref(1) to check for ref existence Patrick Steinhardt
2023-10-24 19:17 ` [PATCH 00/12] show-ref: introduce mode " Junio C Hamano
2023-10-25 14:26 ` Han-Wen Nienhuys
2023-10-25 14:44 ` Phillip Wood
2023-10-26 9:48 ` Patrick Steinhardt
2023-10-27 13:06 ` Phillip Wood
2023-10-26 9:44 ` Patrick Steinhardt
2023-10-26 9:56 ` [PATCH v2 " Patrick Steinhardt
2023-10-26 9:56 ` [PATCH v2 01/12] builtin/show-ref: convert pattern to a local variable Patrick Steinhardt
2023-10-26 9:56 ` [PATCH v2 02/12] builtin/show-ref: split up different subcommands Patrick Steinhardt
2023-10-26 9:56 ` [PATCH v2 03/12] builtin/show-ref: fix leaking string buffer Patrick Steinhardt
2023-10-30 18:10 ` Taylor Blau
2023-10-26 9:56 ` [PATCH v2 04/12] builtin/show-ref: fix dead code when passing patterns Patrick Steinhardt
2023-10-30 18:24 ` Taylor Blau
2023-10-26 9:56 ` [PATCH v2 05/12] builtin/show-ref: refactor `--exclude-existing` options Patrick Steinhardt
2023-10-30 18:37 ` Taylor Blau
2023-10-31 8:10 ` Patrick Steinhardt
2023-10-30 18:55 ` Taylor Blau
2023-10-31 8:10 ` Patrick Steinhardt
2023-10-26 9:56 ` [PATCH v2 06/12] builtin/show-ref: stop using global variable to count matches Patrick Steinhardt
2023-10-30 19:14 ` Taylor Blau
2023-10-26 9:56 ` [PATCH v2 07/12] builtin/show-ref: stop using global vars for `show_one()` Patrick Steinhardt
2023-10-26 9:56 ` [PATCH v2 08/12] builtin/show-ref: refactor options for patterns subcommand Patrick Steinhardt
2023-10-26 9:56 ` [PATCH v2 09/12] builtin/show-ref: ensure mutual exclusiveness of subcommands Patrick Steinhardt
2023-10-30 19:31 ` Taylor Blau
2023-10-31 8:10 ` Patrick Steinhardt
2023-10-26 9:57 ` [PATCH v2 10/12] builtin/show-ref: explicitly spell out different modes in synopsis Patrick Steinhardt
2023-10-26 9:57 ` [PATCH v2 11/12] builtin/show-ref: add new mode to check for reference existence Patrick Steinhardt
2023-10-26 9:57 ` [PATCH v2 12/12] t: use git-show-ref(1) to check for ref existence Patrick Steinhardt
2023-10-30 19:32 ` [PATCH v2 00/12] show-ref: introduce mode " Taylor Blau
2023-10-31 2:26 ` Junio C Hamano
2023-10-31 8:16 ` Patrick Steinhardt [this message]
2023-10-31 8:16 ` [PATCH v3 01/12] builtin/show-ref: convert pattern to a local variable Patrick Steinhardt
2023-10-31 8:16 ` [PATCH v3 02/12] builtin/show-ref: split up different subcommands Patrick Steinhardt
2023-10-31 8:16 ` [PATCH v3 03/12] builtin/show-ref: fix leaking string buffer Patrick Steinhardt
2023-10-31 8:16 ` [PATCH v3 04/12] builtin/show-ref: fix dead code when passing patterns Patrick Steinhardt
2023-10-31 8:16 ` [PATCH v3 05/12] builtin/show-ref: refactor `--exclude-existing` options Patrick Steinhardt
2023-10-31 8:16 ` [PATCH v3 06/12] builtin/show-ref: stop using global variable to count matches Patrick Steinhardt
2023-10-31 8:16 ` [PATCH v3 07/12] builtin/show-ref: stop using global vars for `show_one()` Patrick Steinhardt
2023-10-31 8:16 ` [PATCH v3 08/12] builtin/show-ref: refactor options for patterns subcommand Patrick Steinhardt
2023-10-31 8:16 ` [PATCH v3 09/12] builtin/show-ref: ensure mutual exclusiveness of subcommands Patrick Steinhardt
2023-10-31 8:16 ` [PATCH v3 10/12] builtin/show-ref: explicitly spell out different modes in synopsis Patrick Steinhardt
2023-10-31 8:16 ` [PATCH v3 11/12] builtin/show-ref: add new mode to check for reference existence Patrick Steinhardt
2023-10-31 8:16 ` [PATCH v3 12/12] t: use git-show-ref(1) to check for ref existence Patrick Steinhardt
2023-10-31 19:06 ` [PATCH v3 00/12] builtin/show-ref: introduce mode " Taylor Blau
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=cover.1698739941.git.ps@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hanwen@google.com \
--cc=me@ttaylorr.com \
--cc=sunshine@sunshineco.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.