{"thread":{"id":"66536","subject":"[Outreachy PATCH 0/2] t0410: fix exit code and hash assumptions in the missing-tree test","startedAt":"2026-10-14T13:45:02Z","lastAt":"2026-11-14T20:38:54Z","messageCount":10,"participants":["Dorine Tipo","Junio C Hamano","Laveesh Bansal"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"555021","messageId":"20261014134504.1152225-1-dorine.a.tipo@gmail.com","threadId":"66536","inReplyTo":null,"subject":"[Outreachy PATCH 0/2] t0410: fix exit code and hash assumptions in the missing-tree test","fromName":"Dorine Tipo","fromEmail":"dorine.a.tipo@gmail.com","sentAt":"2026-10-14T13:45:02Z","receivedAt":"2026-10-14T13:45:02Z","isPatch":true,"sender":{"key":"dorine.a.tipo@gmail.com","avatar":null},"body":"This series cleans up the 'rev-list stops traversal at missing and\npromised tree' test in t0410:\n\n - Patch 1 replaces the 'git ls-tree | grep | head | cut' pipeline that\n   finds the OID of a_dir with 'git rev-parse HEAD:a_dir'. The pipeline\n   drops git's exit code, and its cut assumes a SHA-1 length, so it\n   yields an abbreviated OID under SHA-256.\n\n - Patch 2 stores the output of 'git rev-parse' in variables before\n   passing it to test_grep, so a failure in git stops the && chain.\n\nI ran the full test suite with both SHA-1 and SHA-256, and it passes.\n\nThere are more places in t0410 that pass \"$(git ...)\" directly as an\nargument. If this approach looks good, I'm happy to convert the rest\nin a follow-up.\n\nThis is my microproject for Outreachy.\n\nDorine Tipo (2):\n  t0410: use rev-parse to get the subtree OID\n  t0410: keep git's exit code in test_grep calls\n\n t/t0410-partial-clone.sh | 10 +++++++---\n 1 file changed, 7 insertions(+), 3 deletions(-)\n\n-- \n2.34.1\n\n\n"},{"id":"555022","messageId":"20261014134504.1152225-2-dorine.a.tipo@gmail.com","threadId":"66536","inReplyTo":"20261014134504.1152225-1-dorine.a.tipo@gmail.com","subject":"[Outreachy PATCH 1/2] t0410: use rev-parse to get the subtree OID","fromName":"Dorine Tipo","fromEmail":"dorine.a.tipo@gmail.com","sentAt":"2026-10-14T13:45:03Z","receivedAt":"2026-10-14T13:45:03Z","isPatch":true,"sender":{"key":"dorine.a.tipo@gmail.com","avatar":null},"body":"The 'rev-list stops traversal at missing and promised tree' test gets\nthe OID of a_dir by piping 'git ls-tree' through grep, head and cut.\n\nThe pipeline goes against t/README which says not to pipe the output\nof a git command, since only the last command's exit code is kept.\n'cut -b13-52' also assumes a 40-character SHA-1 name, so under SHA-256\nTREE2 holds an abbreviated OID.\n\nUse 'git rev-parse HEAD:a_dir' instead. It returns the full OID in a\nsingle command, the same way TREE is computed with\n'git rev-parse foo^{tree}' just above.\n\nSigned-off-by: Dorine Tipo <dorine.a.tipo@gmail.com>\n---\n t/t0410-partial-clone.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh\nindex 788e9a1631..a24b663f73 100755\n--- a/t/t0410-partial-clone.sh\n+++ b/t/t0410-partial-clone.sh\n@@ -405,7 +405,7 @@ test_expect_success 'rev-list stops traversal at missing and promised tree' '\n \tTREE=$(git -C repo rev-parse foo^{tree}) &&\n \n \t# a tree referenced by HEAD^{tree} (tree referenced from tree)\n-\tTREE2=$(git -C repo ls-tree HEAD^{tree} | grep \" tree \" | head -1 | cut -b13-52) &&\n+\tTREE2=$(git -C repo rev-parse HEAD:a_dir) &&\n \n \tpromise_and_delete \"$TREE\" &&\n \tpromise_and_delete \"$TREE2\" &&\n-- \n2.34.1\n\n\n"},{"id":"555023","messageId":"20261014134504.1152225-3-dorine.a.tipo@gmail.com","threadId":"66536","inReplyTo":"20261014134504.1152225-1-dorine.a.tipo@gmail.com","subject":"[Outreachy PATCH 2/2] t0410: keep git's exit code in test_grep calls","fromName":"Dorine Tipo","fromEmail":"dorine.a.tipo@gmail.com","sentAt":"2026-10-14T13:45:04Z","receivedAt":"2026-10-14T13:45:04Z","isPatch":true,"sender":{"key":"dorine.a.tipo@gmail.com","avatar":null},"body":"The 'rev-list stops traversal at missing and promised tree' test passes\n\"$(git -C repo rev-parse ...)\" directly to test_grep. t/README says\nnot to use command substitution in a way that discards git's exit\ncode: the && chain only sees test_grep's exit code, so a failure in\ngit is not caught there.\n\nAssign the rev-parse output to variables first and pass those to\ntest_grep instead.\n\nSigned-off-by: Dorine Tipo <dorine.a.tipo@gmail.com>\n---\n t/t0410-partial-clone.sh | 8 ++++++--\n 1 file changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh\nindex a24b663f73..57da830105 100755\n--- a/t/t0410-partial-clone.sh\n+++ b/t/t0410-partial-clone.sh\n@@ -413,9 +413,13 @@ test_expect_success 'rev-list stops traversal at missing and promised tree' '\n \tgit -C repo config core.repositoryformatversion 1 &&\n \tgit -C repo config extensions.partialclone \"arbitrary string\" &&\n \tgit -C repo rev-list --exclude-promisor-objects --objects HEAD >out &&\n-\ttest_grep $(git -C repo rev-parse foo) out &&\n+\n+\tFOO=$(git -C repo rev-parse foo) &&\n+\tHEAD_OID=$(git -C repo rev-parse HEAD) &&\n+\n+\ttest_grep \"$FOO\" out &&\n \ttest_grep ! $TREE out &&\n-\ttest_grep $(git -C repo rev-parse HEAD) out &&\n+\ttest_grep \"$HEAD_OID\" out &&\n \ttest_grep ! $TREE2 out\n '\n \n-- \n2.34.1\n\n\n"},{"id":"555070","messageId":"xmqqcxtcqcfa.fsf@gitster.g","threadId":"66536","inReplyTo":"20261014134504.1152225-2-dorine.a.tipo@gmail.com","subject":"Re: [Outreachy PATCH 1/2] t0410: use rev-parse to get the subtree OID","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-14T20:01:29Z","receivedAt":"2026-10-14T20:01:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dorine Tipo <dorine.a.tipo@gmail.com> writes:\n\n> The 'rev-list stops traversal at missing and promised tree' test gets\n> the OID of a_dir by piping 'git ls-tree' through grep, head and cut.\n>\n> The pipeline goes against t/README which says not to pipe the output\n> of a git command, since only the last command's exit code is kept.\n> 'cut -b13-52' also assumes a 40-character SHA-1 name, so under SHA-256\n> TREE2 holds an abbreviated OID.\n>\n> Use 'git rev-parse HEAD:a_dir' instead. It returns the full OID in a\n> single command, the same way TREE is computed with\n> 'git rev-parse foo^{tree}' just above.\n>\n> Signed-off-by: Dorine Tipo <dorine.a.tipo@gmail.com>\n> ---\n>  t/t0410-partial-clone.sh | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh\n> index 788e9a1631..a24b663f73 100755\n> --- a/t/t0410-partial-clone.sh\n> +++ b/t/t0410-partial-clone.sh\n> @@ -405,7 +405,7 @@ test_expect_success 'rev-list stops traversal at missing and promised tree' '\n>  \tTREE=$(git -C repo rev-parse foo^{tree}) &&\n>  \n>  \t# a tree referenced by HEAD^{tree} (tree referenced from tree)\n> -\tTREE2=$(git -C repo ls-tree HEAD^{tree} | grep \" tree \" | head -1 | cut -b13-52) &&\n> +\tTREE2=$(git -C repo rev-parse HEAD:a_dir) &&\n>  \n>  \tpromise_and_delete \"$TREE\" &&\n>  \tpromise_and_delete \"$TREE2\" &&\n\n[devil's advocate hat on]\n\nThat may avoid piping, but are they chekcing the same thing?  If\nHEAD had a tree that sorts before a_dir due to a bug, the original\ntest would have used that tree instead of the tree of a_dir.  Later\ntests may have noticed that the tree object is not what is expected\nfor a_dir and led to the discovery of such a bug.  The new test goes\ndirectly to a_dir so it wouldn't catch such a bug.\n\n[devil's advoicate hat off]\n\nArguably, the use of \"head -1\" in the original pipeline is\nunnecessary as 'repo' prepared there only has a_dir/something and\nnothing else, and if the extra tree that was added by a bug sorted\nafter a_dir, it would have hidden such a bug, instead of catching\nit.  So in the sense, it would be better to assume that the tree\nwould be created in a shape that we expect and explicitly name the\ndirectory we are interested in i.e., \"HEAD:a_dir\".\n\nSo, one thing we may want to add to the second paragraph of the\nproposed log message is that the original assumed silently that the\nfirst tree object in ls-tree output is the tree we are intrerested\nin, without even validating what path the tree was stored at, and it\nwould be an improvement to name 'a_dir' explicitly in the test.\n\n\n\n"},{"id":"555158","messageId":"atD1oFyLb0k4oFWN@Stealth","threadId":"66536","inReplyTo":"xmqqcxtcqcfa.fsf@gitster.g","subject":"Re: [Outreachy PATCH 1/2] t0410: use rev-parse to get the subtree OID","fromName":"Dorine Tipo","fromEmail":"dorine.a.tipo@gmail.com","sentAt":"2026-10-15T15:47:44Z","receivedAt":"2026-10-15T15:47:44Z","isPatch":true,"sender":{"key":"dorine.a.tipo@gmail.com","avatar":null},"body":"On Wed, Oct 14, 2026 at 01:01:29PM -0700, Junio C Hamano wrote:\n> \n> [devil's advocate hat on]\n> \n> That may avoid piping, but are they chekcing the same thing?  If\n> HEAD had a tree that sorts before a_dir due to a bug, the original\n> test would have used that tree instead of the tree of a_dir.  Later\n> tests may have noticed that the tree object is not what is expected\n> for a_dir and led to the discovery of such a bug.  The new test goes\n> directly to a_dir so it wouldn't catch such a bug.\n> \n> [devil's advoicate hat off]\n> \n> Arguably, the use of \"head -1\" in the original pipeline is\n> unnecessary as 'repo' prepared there only has a_dir/something and\n> nothing else, and if the extra tree that was added by a bug sorted\n> after a_dir, it would have hidden such a bug, instead of catching\n> it.  So in the sense, it would be better to assume that the tree\n> would be created in a shape that we expect and explicitly name the\n> directory we are interested in i.e., \"HEAD:a_dir\".\n> \n> So, one thing we may want to add to the second paragraph of the\n> proposed log message is that the original assumed silently that the\n> first tree object in ls-tree output is the tree we are intrerested\n> in, without even validating what path the tree was stored at, and it\n> would be an improvement to name 'a_dir' explicitly in the test.\n> \n> \nThank you, that makes sense. I'll add that to the second paragraph in v2.\nI'll wait a little to see if any changes are needed on patch 2/2, then\nsend v2 with everything together.\n\n"},{"id":"555571","messageId":"20261020160127.29096-1-dorine.a.tipo@gmail.com","threadId":"66536","inReplyTo":"20261014134504.1152225-1-dorine.a.tipo@gmail.com","subject":"[Outreachy PATCH v2 0/2] t0410: fix exit code and hash assumptions in the missing-tree test","fromName":"Dorine Tipo","fromEmail":"dorine.a.tipo@gmail.com","sentAt":"2026-10-20T16:01:25Z","receivedAt":"2026-10-20T16:01:25Z","isPatch":true,"sender":{"key":"dorine.a.tipo@gmail.com","avatar":null},"body":"This series cleans up the 'rev-list stops traversal at missing and\npromised tree' test in t0410.\n\nChanges since v1:\n - 1/2: expanded the log message to note that the original pipeline\n   silently assumed the first tree in the ls-tree output was the one\n   we wanted, and that naming a_dir explicitly is an improvement.\n   Thanks, Junio.\n - 2/2: unchanged.\n\nI ran the full test suite with both SHA-1 and SHA-256, and it passes.\n\nDorine Tipo (2):\n  t0410: use rev-parse to get the subtree OID\n  t0410: keep git's exit code in test_grep calls\n\n t/t0410-partial-clone.sh | 10 +++++++---\n 1 file changed, 7 insertions(+), 3 deletions(-)\n\nRange-diff against v1:\n1:  b8f514e0a2 ! 1:  dcf6c7da4c t0410: use rev-parse to get the subtree OID\n    @@ Commit message\n     \n         The pipeline goes against t/README which says not to pipe the output\n         of a git command, since only the last command's exit code is kept.\n    -    'cut -b13-52' also assumes a 40-character SHA-1 name, so under SHA-256\n    -    TREE2 holds an abbreviated OID.\n    +    It also silently assumes that the first tree in the ls-tree output is\n    +    the one we want, without checking which path it is stored at.\n    +    And 'cut -b13-52' also assumes a 40-character SHA-1 name, so under\n    +    SHA-256 TREE2 holds an abbreviated OID.\n     \n    -    Use 'git rev-parse HEAD:a_dir' instead. It returns the full OID in a\n    -    single command, the same way TREE is computed with\n    -    'git rev-parse foo^{tree}' just above.\n    +    Use 'git rev-parse HEAD:a_dir' instead. It names the directory we are\n    +    interested in explicitly and returns the full OID in a single command,\n    +    the same way TREE is computed with 'git rev-parse foo^{tree}' just\n    +    above.\n     \n    +    Helped-by: Junio C Hamano <gitster@pobox.com>\n         Signed-off-by: Dorine Tipo <dorine.a.tipo@gmail.com>\n     \n      ## t/t0410-partial-clone.sh ##\n2:  5823e65a88 = 2:  f810625e77 t0410: keep git's exit code in test_grep calls\n-- \n2.34.1\n\n\n"},{"id":"555572","messageId":"20261020160127.29096-2-dorine.a.tipo@gmail.com","threadId":"66536","inReplyTo":"20261020160127.29096-1-dorine.a.tipo@gmail.com","subject":"[Outreachy PATCH v2 1/2] t0410: use rev-parse to get the subtree OID","fromName":"Dorine Tipo","fromEmail":"dorine.a.tipo@gmail.com","sentAt":"2026-10-20T16:01:26Z","receivedAt":"2026-10-20T16:01:26Z","isPatch":true,"sender":{"key":"dorine.a.tipo@gmail.com","avatar":null},"body":"The 'rev-list stops traversal at missing and promised tree' test gets\nthe OID of a_dir by piping 'git ls-tree' through grep, head and cut.\n\nThe pipeline goes against t/README which says not to pipe the output\nof a git command, since only the last command's exit code is kept.\nIt also silently assumes that the first tree in the ls-tree output is\nthe one we want, without checking which path it is stored at.\nAnd 'cut -b13-52' also assumes a 40-character SHA-1 name, so under\nSHA-256 TREE2 holds an abbreviated OID.\n\nUse 'git rev-parse HEAD:a_dir' instead. It names the directory we are\ninterested in explicitly and returns the full OID in a single command,\nthe same way TREE is computed with 'git rev-parse foo^{tree}' just\nabove.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Dorine Tipo <dorine.a.tipo@gmail.com>\n---\n t/t0410-partial-clone.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh\nindex 788e9a1631..a24b663f73 100755\n--- a/t/t0410-partial-clone.sh\n+++ b/t/t0410-partial-clone.sh\n@@ -405,7 +405,7 @@ test_expect_success 'rev-list stops traversal at missing and promised tree' '\n \tTREE=$(git -C repo rev-parse foo^{tree}) &&\n \n \t# a tree referenced by HEAD^{tree} (tree referenced from tree)\n-\tTREE2=$(git -C repo ls-tree HEAD^{tree} | grep \" tree \" | head -1 | cut -b13-52) &&\n+\tTREE2=$(git -C repo rev-parse HEAD:a_dir) &&\n \n \tpromise_and_delete \"$TREE\" &&\n \tpromise_and_delete \"$TREE2\" &&\n-- \n2.34.1\n\n\n"},{"id":"555573","messageId":"20261020160127.29096-3-dorine.a.tipo@gmail.com","threadId":"66536","inReplyTo":"20261020160127.29096-1-dorine.a.tipo@gmail.com","subject":"[Outreachy PATCH v2 2/2] t0410: keep git's exit code in test_grep calls","fromName":"Dorine Tipo","fromEmail":"dorine.a.tipo@gmail.com","sentAt":"2026-10-20T16:01:27Z","receivedAt":"2026-10-20T16:01:27Z","isPatch":true,"sender":{"key":"dorine.a.tipo@gmail.com","avatar":null},"body":"The 'rev-list stops traversal at missing and promised tree' test passes\n\"$(git -C repo rev-parse ...)\" directly to test_grep. t/README says\nnot to use command substitution in a way that discards git's exit\ncode: the && chain only sees test_grep's exit code, so a failure in\ngit is not caught there.\n\nAssign the rev-parse output to variables first and pass those to\ntest_grep instead.\n\nSigned-off-by: Dorine Tipo <dorine.a.tipo@gmail.com>\n---\n t/t0410-partial-clone.sh | 8 ++++++--\n 1 file changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh\nindex a24b663f73..57da830105 100755\n--- a/t/t0410-partial-clone.sh\n+++ b/t/t0410-partial-clone.sh\n@@ -413,9 +413,13 @@ test_expect_success 'rev-list stops traversal at missing and promised tree' '\n \tgit -C repo config core.repositoryformatversion 1 &&\n \tgit -C repo config extensions.partialclone \"arbitrary string\" &&\n \tgit -C repo rev-list --exclude-promisor-objects --objects HEAD >out &&\n-\ttest_grep $(git -C repo rev-parse foo) out &&\n+\n+\tFOO=$(git -C repo rev-parse foo) &&\n+\tHEAD_OID=$(git -C repo rev-parse HEAD) &&\n+\n+\ttest_grep \"$FOO\" out &&\n \ttest_grep ! $TREE out &&\n-\ttest_grep $(git -C repo rev-parse HEAD) out &&\n+\ttest_grep \"$HEAD_OID\" out &&\n \ttest_grep ! $TREE2 out\n '\n \n-- \n2.34.1\n\n\n"},{"id":"558485","messageId":"20261114203718.38000-1-laveeshb@laveeshbansal.com","threadId":"66536","inReplyTo":"20261020160127.29096-2-dorine.a.tipo@gmail.com","subject":"Re: [Outreachy PATCH v2 1/2] t0410: use rev-parse to get the subtree OID","fromName":"Laveesh Bansal","fromEmail":"laveeshb@laveeshbansal.com","sentAt":"2026-11-14T20:37:18Z","receivedAt":"2026-11-14T20:37:18Z","isPatch":true,"sender":{"key":"laveeshb@laveeshbansal.com","avatar":null},"body":"Looks good to me. t0410 passes for me, also with sha256.\n\nReviewed-by: Laveesh Bansal <laveeshb@laveeshbansal.com>\n\n"},{"id":"558486","messageId":"20261114203854.38111-1-laveeshb@laveeshbansal.com","threadId":"66536","inReplyTo":"20261020160127.29096-3-dorine.a.tipo@gmail.com","subject":"Re: [Outreachy PATCH v2 2/2] t0410: keep git's exit code in test_grep calls","fromName":"Laveesh Bansal","fromEmail":"laveeshb@laveeshbansal.com","sentAt":"2026-11-14T20:38:54Z","receivedAt":"2026-11-14T20:38:54Z","isPatch":true,"sender":{"key":"laveeshb@laveeshbansal.com","avatar":null},"body":"Looks good to me. t0410 passes for me too.\n\nReviewed-by: Laveesh Bansal <laveeshb@laveeshbansal.com>\n\n"}]}