From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Teng Long <dyroneteng@gmail.com>
Cc: git@vger.kernel.org, avarab@gmail.com,
tenglong.tl@alibaba-inc.com, me@ttaylorr.com
Subject: Re: [RFC PATCH 6/6] ls-tree: introduce '--pattern' option
Date: Mon, 12 Dec 2022 09:32:38 +0100 (CET) [thread overview]
Message-ID: <2q985o75-p6ro-3319-rqos-004621r0p7pq@tzk.qr> (raw)
In-Reply-To: <20221117113023.65865-7-tenglong.tl@alibaba-inc.com>
Hi,
On Thu, 17 Nov 2022, Teng Long wrote:
> diff --git a/t/t3106-ls-tree-pattern.sh b/t/t3106-ls-tree-pattern.sh
> new file mode 100755
> index 00000000000..e4a81c8c47e
> --- /dev/null
> +++ b/t/t3106-ls-tree-pattern.sh
> @@ -0,0 +1,70 @@
> +#!/bin/sh
> +
> +test_description='ls-tree pattern'
> +
> +TEST_PASSES_SANITIZE_LEAK=true
> +. ./test-lib.sh
> +. "$TEST_DIRECTORY"/lib-t3100.sh
> +
> +test_expect_success 'setup' '
> + setup_basic_ls_tree_data
> +'
> +
> +test_expect_success 'ls-tree pattern usage' '
> + test_expect_code 129 git ls-tree --pattern HEAD &&
> + test_expect_code 128 git ls-tree --pattern "" HEAD >err 2>&1 &&
> + grep "Not a valid pattern, the value is empty" err
> +'
> +
> +test_expect_success 'combine with "--object-only"' '
> + cat > expect <<-EOF &&
> + 6da7993
> + EOF
> +
> + git ls-tree --object-only --abbrev=7 --pattern "6da7993" HEAD > actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'combine with "--name-only"' '
> + cat > expect <<-EOF &&
> + .gitmodules
> + top-file.t
> + EOF
> +
> + git ls-tree --name-only --pattern "\." HEAD > actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'combine with "--long"' '
> + cat > expect <<-EOF &&
> + 100644 blob 6da7993 61 .gitmodules
> + 100644 blob 02dad95 9 top-file.t
> + EOF
> + git ls-tree --long --abbrev=7 --pattern "blob" HEAD > actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'combine with "--format"' '
> + # Change the output format by replacing space separators with asterisks.
> + format="%(objectmode)*%(objecttype)*%(objectname)%x09%(path)" &&
> + pattern="100644\*blob" &&
> +
> + cat > expect <<-EOF &&
> + 100644*blob*6da7993 .gitmodules
> + 100644*blob*02dad95 top-file.t
> + EOF
> +
> + git ls-tree --abbrev=7 --format "$format" --pattern "$pattern" HEAD >actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'default output format (only with "--pattern" option)' '
> + cat > expect <<-EOF &&
> + 100644 blob 6da7993ca1a3435f63c598464f77bdc6dae15aa5 .gitmodules
> + 100644 blob 02dad956d9274a70f7fafe45a5ffa2e123acd9a8 top-file.t
> + EOF
> + git ls-tree --pattern "blob" HEAD > actual &&
> + test_cmp expect actual
> +'
> +
> +test_done
The hard-coded object IDs break the `linux-sha256` job, as pointed out in
https://github.com/git/git/blob/6ab7651d8669/whats-cooking.txt#L522-L537.
Please squash this in to address this (Junio, please feel free to
cherry-pick this on top of `tl/ls-tree--pattern` to reduce the number of
CI failures):
-- snipsnap --
Subject: [PATCH] fixup! ls-tree: introduce '--pattern' option
We need to avoid hard-coding OIDs because of the SHA-256 support.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
t/t3106-ls-tree-pattern.sh | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/t/t3106-ls-tree-pattern.sh b/t/t3106-ls-tree-pattern.sh
index e4a81c8c47e..8aaca307804 100755
--- a/t/t3106-ls-tree-pattern.sh
+++ b/t/t3106-ls-tree-pattern.sh
@@ -17,11 +17,12 @@ test_expect_success 'ls-tree pattern usage' '
'
test_expect_success 'combine with "--object-only"' '
+ oid="$(git rev-parse --short HEAD:.gitmodules)" &&
cat > expect <<-EOF &&
- 6da7993
+ $oid
EOF
- git ls-tree --object-only --abbrev=7 --pattern "6da7993" HEAD > actual &&
+ git ls-tree --object-only --abbrev=7 --pattern "$oid" HEAD > actual &&
test_cmp expect actual
'
@@ -36,22 +37,26 @@ test_expect_success 'combine with "--name-only"' '
'
test_expect_success 'combine with "--long"' '
+ oid1="$(git rev-parse --short HEAD:.gitmodules)" &&
+ oid2="$(git rev-parse --short HEAD:top-file.t)" &&
cat > expect <<-EOF &&
- 100644 blob 6da7993 61 .gitmodules
- 100644 blob 02dad95 9 top-file.t
+ 100644 blob $oid1 61 .gitmodules
+ 100644 blob $oid2 9 top-file.t
EOF
git ls-tree --long --abbrev=7 --pattern "blob" HEAD > actual &&
test_cmp expect actual
'
test_expect_success 'combine with "--format"' '
+ oid1="$(git rev-parse --short HEAD:.gitmodules)" &&
+ oid2="$(git rev-parse --short HEAD:top-file.t)" &&
# Change the output format by replacing space separators with asterisks.
format="%(objectmode)*%(objecttype)*%(objectname)%x09%(path)" &&
pattern="100644\*blob" &&
cat > expect <<-EOF &&
- 100644*blob*6da7993 .gitmodules
- 100644*blob*02dad95 top-file.t
+ 100644*blob*$oid1 .gitmodules
+ 100644*blob*$oid2 top-file.t
EOF
git ls-tree --abbrev=7 --format "$format" --pattern "$pattern" HEAD >actual &&
@@ -59,9 +64,11 @@ test_expect_success 'combine with "--format"' '
'
test_expect_success 'default output format (only with "--pattern" option)' '
+ oid1="$(git rev-parse HEAD:.gitmodules)" &&
+ oid2="$(git rev-parse HEAD:top-file.t)" &&
cat > expect <<-EOF &&
- 100644 blob 6da7993ca1a3435f63c598464f77bdc6dae15aa5 .gitmodules
- 100644 blob 02dad956d9274a70f7fafe45a5ffa2e123acd9a8 top-file.t
+ 100644 blob $oid1 .gitmodules
+ 100644 blob $oid2 top-file.t
EOF
git ls-tree --pattern "blob" HEAD > actual &&
test_cmp expect actual
--
2.38.1.windows.1.24.g5ff6506c583.dirty
next prev parent reply other threads:[~2022-12-12 8:32 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 11:30 [RFC PATCH 0/6] ls-tree: introduce '--pattern' option Teng Long
2022-11-17 11:30 ` [RFC PATCH 1/6] ls-tree: cleanup the redundant SPACE Teng Long
2022-11-17 11:30 ` [RFC PATCH 2/6] t3104: remove shift code in 'test_ls_tree_format' Teng Long
2022-11-17 11:30 ` [RFC PATCH 3/6] ls-tree: optimize params of 'show_tree_common_default_long()' Teng Long
2022-11-17 11:30 ` [RFC PATCH 4/6] ls-tree: improving cohension in the print code Teng Long
2022-11-17 13:53 ` Ævar Arnfjörð Bjarmason
2022-11-17 11:30 ` [RFC PATCH 5/6] ls-tree: introduce 'match_pattern()' function Teng Long
2022-11-17 14:02 ` Ævar Arnfjörð Bjarmason
2022-11-30 9:39 ` Ævar Arnfjörð Bjarmason
2022-11-17 11:30 ` [RFC PATCH 6/6] ls-tree: introduce '--pattern' option Teng Long
2022-11-17 14:03 ` Ævar Arnfjörð Bjarmason
2022-12-12 8:32 ` Johannes Schindelin [this message]
2022-12-12 23:57 ` Junio C Hamano
2022-12-14 5:27 ` Junio C Hamano
2022-12-14 10:03 ` Ævar Arnfjörð Bjarmason
2022-12-14 10:38 ` Junio C Hamano
2023-03-27 10:37 ` win-test: unknown terminal "xterm-256color", was " Johannes Schindelin
2023-03-27 20:42 ` Junio C Hamano
2023-03-28 18:08 ` Jeff King
2023-03-28 19:31 ` Junio C Hamano
2023-03-28 19:59 ` Jeff King
2023-03-28 20:43 ` Jeff King
2023-03-28 21:05 ` Junio C Hamano
2022-11-17 13:22 ` [RFC PATCH 0/6] " Ævar Arnfjörð Bjarmason
2022-11-17 22:02 ` Taylor Blau
2022-11-21 11:41 ` Teng Long
2022-11-21 12:12 ` Ævar Arnfjörð Bjarmason
2022-11-17 13:48 ` [RFC PATCH 0/4] ls-tree: pass state in struct, not globals Ævar Arnfjörð Bjarmason
2022-11-17 13:48 ` [RFC PATCH 1/4] ls-tree: don't use "show_tree_data" for "fast" callbacks Ævar Arnfjörð Bjarmason
2022-12-21 11:47 ` Teng Long
2022-11-17 13:48 ` [RFC PATCH 2/4] ls-tree: use a "struct options" Ævar Arnfjörð Bjarmason
2022-11-17 13:48 ` [RFC PATCH 3/4] ls-tree: fold "show_tree_data" into "cb" struct Ævar Arnfjörð Bjarmason
2022-11-17 13:48 ` [RFC PATCH 4/4] ls-tree: make "line_termination" less generic Ævar Arnfjörð Bjarmason
2022-11-21 12:00 ` [RFC PATCH 0/4] ls-tree: pass state in struct, not globals Teng Long
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=2q985o75-p6ro-3319-rqos-004621r0p7pq@tzk.qr \
--to=johannes.schindelin@gmx.de \
--cc=avarab@gmail.com \
--cc=dyroneteng@gmail.com \
--cc=git@vger.kernel.org \
--cc=me@ttaylorr.com \
--cc=tenglong.tl@alibaba-inc.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.