Thread View: linux.kernel.git
10 messages
10 total messages
Started by Dorine Tipo
Wed, 14 Oct 2026 13:45
[Outreachy PATCH 0/2] t0410: fix exit code and hash assumptions in the missing-tree test
Author: Dorine Tipo
Date: Wed, 14 Oct 2026 13:45
Date: Wed, 14 Oct 2026 13:45
29 lines
8659 bytes
8659 bytes
This series cleans up the 'rev-list stops traversal at missing and promised tree' test in t0410: - Patch 1 replaces the 'git ls-tree | grep | head | cut' pipeline that finds the OID of a_dir with 'git rev-parse HEAD:a_dir'. The pipeline drops git's exit code, and its cut assumes a SHA-1 length, so it yields an abbreviated OID under SHA-256. - Patch 2 stores the output of 'git rev-parse' in variables before passing it to test_grep, so a failure in git stops the && chain. I ran the full test suite with both SHA-1 and SHA-256, and it passes. There are more places in t0410 that pass "$(git ...)" directly as an argument. If this approach looks good, I'm happy to convert the rest in a follow-up. This is my microproject for Outreachy. Dorine Tipo (2): t0410: use rev-parse to get the subtree OID t0410: keep git's exit code in test_grep calls t/t0410-partial-clone.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.34.1
[Outreachy PATCH 1/2] t0410: use rev-parse to get the subtree OID
Author: Dorine Tipo
Date: Wed, 14 Oct 2026 13:45
Date: Wed, 14 Oct 2026 13:45
33 lines
9174 bytes
9174 bytes
The 'rev-list stops traversal at missing and promised tree' test gets
the OID of a_dir by piping 'git ls-tree' through grep, head and cut.
The pipeline goes against t/README which says not to pipe the output
of a git command, since only the last command's exit code is kept.
'cut -b13-52' also assumes a 40-character SHA-1 name, so under SHA-256
TREE2 holds an abbreviated OID.
Use 'git rev-parse HEAD:a_dir' instead. It returns the full OID in a
single command, the same way TREE is computed with
'git rev-parse foo^{tree}' just above.
Signed-off-by: Dorine Tipo <dorine.a.tipo@gmail.com>
---
t/t0410-partial-clone.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
index 788e9a1631..a24b663f73 100755
--- a/t/t0410-partial-clone.sh
+++ b/t/t0410-partial-clone.sh
@@ -405,7 +405,7 @@ test_expect_success 'rev-list stops traversal at missing and promised tree' '
TREE=$(git -C repo rev-parse foo^{tree}) &&
# a tree referenced by HEAD^{tree} (tree referenced from tree)
- TREE2=$(git -C repo ls-tree HEAD^{tree} | grep " tree " | head -1 | cut -b13-52) &&
+ TREE2=$(git -C repo rev-parse HEAD:a_dir) &&
promise_and_delete "$TREE" &&
promise_and_delete "$TREE2" &&
--
2.34.1
[Outreachy PATCH 2/2] t0410: keep git's exit code in test_grep calls
Author: Dorine Tipo
Date: Wed, 14 Oct 2026 13:45
Date: Wed, 14 Oct 2026 13:45
37 lines
9171 bytes
9171 bytes
The 'rev-list stops traversal at missing and promised tree' test passes "$(git -C repo rev-parse ...)" directly to test_grep. t/README says not to use command substitution in a way that discards git's exit code: the && chain only sees test_grep's exit code, so a failure in git is not caught there. Assign the rev-parse output to variables first and pass those to test_grep instead. Signed-off-by: Dorine Tipo <dorine.a.tipo@gmail.com> --- t/t0410-partial-clone.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh index a24b663f73..57da830105 100755 --- a/t/t0410-partial-clone.sh +++ b/t/t0410-partial-clone.sh @@ -413,9 +413,13 @@ test_expect_success 'rev-list stops traversal at missing and promised tree' ' git -C repo config core.repositoryformatversion 1 && git -C repo config extensions.partialclone "arbitrary string" && git -C repo rev-list --exclude-promisor-objects --objects HEAD >out && - test_grep $(git -C repo rev-parse foo) out && + + FOO=$(git -C repo rev-parse foo) && + HEAD_OID=$(git -C repo rev-parse HEAD) && + + test_grep "$FOO" out && test_grep ! $TREE out && - test_grep $(git -C repo rev-parse HEAD) out && + test_grep "$HEAD_OID" out && test_grep ! $TREE2 out ' -- 2.34.1
Re: [Outreachy PATCH 1/2] t0410: use rev-parse to get the subtree OID
Author: Junio C Hamano
Date: Wed, 14 Oct 2026 20:01
Date: Wed, 14 Oct 2026 20:01
58 lines
12229 bytes
12229 bytes
Dorine Tipo <dorine.a.tipo@gmail.com> writes:
> The 'rev-list stops traversal at missing and promised tree' test gets
> the OID of a_dir by piping 'git ls-tree' through grep, head and cut.
>
> The pipeline goes against t/README which says not to pipe the output
> of a git command, since only the last command's exit code is kept.
> 'cut -b13-52' also assumes a 40-character SHA-1 name, so under SHA-256
> TREE2 holds an abbreviated OID.
>
> Use 'git rev-parse HEAD:a_dir' instead. It returns the full OID in a
> single command, the same way TREE is computed with
> 'git rev-parse foo^{tree}' just above.
>
> Signed-off-by: Dorine Tipo <dorine.a.tipo@gmail.com>
> ---
> t/t0410-partial-clone.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
> index 788e9a1631..a24b663f73 100755
> --- a/t/t0410-partial-clone.sh
> +++ b/t/t0410-partial-clone.sh
> @@ -405,7 +405,7 @@ test_expect_success 'rev-list stops traversal at missing and promised tree' '
> TREE=$(git -C repo rev-parse foo^{tree}) &&
>
> # a tree referenced by HEAD^{tree} (tree referenced from tree)
> - TREE2=$(git -C repo ls-tree HEAD^{tree} | grep " tree " | head -1 | cut -b13-52) &&
> + TREE2=$(git -C repo rev-parse HEAD:a_dir) &&
>
> promise_and_delete "$TREE" &&
> promise_and_delete "$TREE2" &&
[devil's advocate hat on]
That may avoid piping, but are they chekcing the same thing? If
HEAD had a tree that sorts before a_dir due to a bug, the original
test would have used that tree instead of the tree of a_dir. Later
tests may have noticed that the tree object is not what is expected
for a_dir and led to the discovery of such a bug. The new test goes
directly to a_dir so it wouldn't catch such a bug.
[devil's advoicate hat off]
Arguably, the use of "head -1" in the original pipeline is
unnecessary as 'repo' prepared there only has a_dir/something and
nothing else, and if the extra tree that was added by a bug sorted
after a_dir, it would have hidden such a bug, instead of catching
it. So in the sense, it would be better to assume that the tree
would be created in a shape that we expect and explicitly name the
directory we are interested in i.e., "HEAD:a_dir".
So, one thing we may want to add to the second paragraph of the
proposed log message is that the original assumed silently that the
first tree object in ls-tree output is the tree we are intrerested
in, without even validating what path the tree was stored at, and it
would be an improvement to name 'a_dir' explicitly in the test.
Re: [Outreachy PATCH 1/2] t0410: use rev-parse to get the subtree OID
Author: Dorine Tipo
Date: Thu, 15 Oct 2026 15:47
Date: Thu, 15 Oct 2026 15:47
32 lines
9479 bytes
9479 bytes
On Wed, Oct 14, 2026 at 01:01:29PM -0700, Junio C Hamano wrote: > > [devil's advocate hat on] > > That may avoid piping, but are they chekcing the same thing? If > HEAD had a tree that sorts before a_dir due to a bug, the original > test would have used that tree instead of the tree of a_dir. Later > tests may have noticed that the tree object is not what is expected > for a_dir and led to the discovery of such a bug. The new test goes > directly to a_dir so it wouldn't catch such a bug. > > [devil's advoicate hat off] > > Arguably, the use of "head -1" in the original pipeline is > unnecessary as 'repo' prepared there only has a_dir/something and > nothing else, and if the extra tree that was added by a bug sorted > after a_dir, it would have hidden such a bug, instead of catching > it. So in the sense, it would be better to assume that the tree > would be created in a shape that we expect and explicitly name the > directory we are interested in i.e., "HEAD:a_dir". > > So, one thing we may want to add to the second paragraph of the > proposed log message is that the original assumed silently that the > first tree object in ls-tree output is the tree we are intrerested > in, without even validating what path the tree was stored at, and it > would be an improvement to name 'a_dir' explicitly in the test. > > Thank you, that makes sense. I'll add that to the second paragraph in v2. I'll wait a little to see if any changes are needed on patch 2/2, then send v2 with everything together.
[Outreachy PATCH v2 0/2] t0410: fix exit code and hash assumptions in the missing-tree test
Author: Dorine Tipo
Date: Tue, 20 Oct 2026 16:01
Date: Tue, 20 Oct 2026 16:01
48 lines
12625 bytes
12625 bytes
This series cleans up the 'rev-list stops traversal at missing and
promised tree' test in t0410.
Changes since v1:
- 1/2: expanded the log message to note that the original pipeline
silently assumed the first tree in the ls-tree output was the one
we wanted, and that naming a_dir explicitly is an improvement.
Thanks, Junio.
- 2/2: unchanged.
I ran the full test suite with both SHA-1 and SHA-256, and it passes.
Dorine Tipo (2):
t0410: use rev-parse to get the subtree OID
t0410: keep git's exit code in test_grep calls
t/t0410-partial-clone.sh | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
Range-diff against v1:
1: b8f514e0a2 ! 1: dcf6c7da4c t0410: use rev-parse to get the subtree OID
@@ Commit message
The pipeline goes against t/README which says not to pipe the output
of a git command, since only the last command's exit code is kept.
- 'cut -b13-52' also assumes a 40-character SHA-1 name, so under SHA-256
- TREE2 holds an abbreviated OID.
+ It also silently assumes that the first tree in the ls-tree output is
+ the one we want, without checking which path it is stored at.
+ And 'cut -b13-52' also assumes a 40-character SHA-1 name, so under
+ SHA-256 TREE2 holds an abbreviated OID.
- Use 'git rev-parse HEAD:a_dir' instead. It returns the full OID in a
- single command, the same way TREE is computed with
- 'git rev-parse foo^{tree}' just above.
+ Use 'git rev-parse HEAD:a_dir' instead. It names the directory we are
+ interested in explicitly and returns the full OID in a single command,
+ the same way TREE is computed with 'git rev-parse foo^{tree}' just
+ above.
+ Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Dorine Tipo <dorine.a.tipo@gmail.com>
## t/t0410-partial-clone.sh ##
2: 5823e65a88 = 2: f810625e77 t0410: keep git's exit code in test_grep calls
--
2.34.1
[Outreachy PATCH v2 1/2] t0410: use rev-parse to get the subtree OID
Author: Dorine Tipo
Date: Tue, 20 Oct 2026 16:01
Date: Tue, 20 Oct 2026 16:01
37 lines
12120 bytes
12120 bytes
The 'rev-list stops traversal at missing and promised tree' test gets
the OID of a_dir by piping 'git ls-tree' through grep, head and cut.
The pipeline goes against t/README which says not to pipe the output
of a git command, since only the last command's exit code is kept.
It also silently assumes that the first tree in the ls-tree output is
the one we want, without checking which path it is stored at.
And 'cut -b13-52' also assumes a 40-character SHA-1 name, so under
SHA-256 TREE2 holds an abbreviated OID.
Use 'git rev-parse HEAD:a_dir' instead. It names the directory we are
interested in explicitly and returns the full OID in a single command,
the same way TREE is computed with 'git rev-parse foo^{tree}' just
above.
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Dorine Tipo <dorine.a.tipo@gmail.com>
---
t/t0410-partial-clone.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
index 788e9a1631..a24b663f73 100755
--- a/t/t0410-partial-clone.sh
+++ b/t/t0410-partial-clone.sh
@@ -405,7 +405,7 @@ test_expect_success 'rev-list stops traversal at missing and promised tree' '
TREE=$(git -C repo rev-parse foo^{tree}) &&
# a tree referenced by HEAD^{tree} (tree referenced from tree)
- TREE2=$(git -C repo ls-tree HEAD^{tree} | grep " tree " | head -1 | cut -b13-52) &&
+ TREE2=$(git -C repo rev-parse HEAD:a_dir) &&
promise_and_delete "$TREE" &&
promise_and_delete "$TREE2" &&
--
2.34.1
[Outreachy PATCH v2 2/2] t0410: keep git's exit code in test_grep calls
Author: Dorine Tipo
Date: Tue, 20 Oct 2026 16:01
Date: Tue, 20 Oct 2026 16:01
37 lines
11905 bytes
11905 bytes
The 'rev-list stops traversal at missing and promised tree' test passes "$(git -C repo rev-parse ...)" directly to test_grep. t/README says not to use command substitution in a way that discards git's exit code: the && chain only sees test_grep's exit code, so a failure in git is not caught there. Assign the rev-parse output to variables first and pass those to test_grep instead. Signed-off-by: Dorine Tipo <dorine.a.tipo@gmail.com> --- t/t0410-partial-clone.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh index a24b663f73..57da830105 100755 --- a/t/t0410-partial-clone.sh +++ b/t/t0410-partial-clone.sh @@ -413,9 +413,13 @@ test_expect_success 'rev-list stops traversal at missing and promised tree' ' git -C repo config core.repositoryformatversion 1 && git -C repo config extensions.partialclone "arbitrary string" && git -C repo rev-list --exclude-promisor-objects --objects HEAD >out && - test_grep $(git -C repo rev-parse foo) out && + + FOO=$(git -C repo rev-parse foo) && + HEAD_OID=$(git -C repo rev-parse HEAD) && + + test_grep "$FOO" out && test_grep ! $TREE out && - test_grep $(git -C repo rev-parse HEAD) out && + test_grep "$HEAD_OID" out && test_grep ! $TREE2 out ' -- 2.34.1
Re: [Outreachy PATCH v2 1/2] t0410: use rev-parse to get the subtree OID
Author: Laveesh Bansal
Date: Sat, 14 Nov 2026 20:37
Date: Sat, 14 Nov 2026 20:37
4 lines
9491 bytes
9491 bytes
Looks good to me. t0410 passes for me, also with sha256. Reviewed-by: Laveesh Bansal <laveeshb@laveeshbansal.com>
Re: [Outreachy PATCH v2 2/2] t0410: keep git's exit code in test_grep calls
Author: Laveesh Bansal
Date: Sat, 14 Nov 2026 20:38
Date: Sat, 14 Nov 2026 20:38
4 lines
9461 bytes
9461 bytes
Looks good to me. t0410 passes for me too. Reviewed-by: Laveesh Bansal <laveeshb@laveeshbansal.com>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads