Thread (178 messages) 178 messages, 10 authors, 2025-08-16

Re: [GSoC PATCH v5 5/5] repo: add the --format flag

From: Ben Knoble <hidden>
Date: 2025-07-29 00:15:26

Le 27 juil. 2025 à 18:02, Eric Sunshine [off-list ref] a écrit :

On Sun, Jul 27, 2025 at 2:02 PM Lucas Seiki Oshiro
[off-list ref] wrote:
quoted
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
@@ -20,11 +20,20 @@ test_repo_info () {
+       test_expect_success "null-terminated: $label" '
+               test_when_finished "rm -rf repo" &&
+               eval "$init_command" &&
+               echo "$expected_value" | lf_to_nul >expected &&
Simpler:

   printf "$expected_value\0" >expected &&
(Below as well): the shell linter I use does prefer to see

    printf %s\\0 "$var"

to avoid issues with the variable containing format specifiers. 

(Backslash has to be quoted in double-quotes, too, I think? So I left out the quotes here.)
quoted
+               git -C repo repo info --format=nul "$key" >output &&
+               tail -n 1 output >actual &&
+               test_cmp expected actual
+       '
How confident are we that `tail -n 1 output >actual` is going to
perform as expected across platforms and versions of those platforms?
It feels awfully fragile to me. Why slice and dice the output anyhow
rather than merely crafting the correct expected output in the first
place and comparing that directly against the actual output? In other
words, something like this:

   printf "$key\n$expected_value\0" >expect &&
   git -C repo repo info --format=nul "$key" >actual &&
   test_cmp_bin expect actual
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help