git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] fetch: add new config option fetch.all

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jan 4, 2024, 20:50 UTC
Message-ID
<CAPig+cSkNVt0P=38X_h3VShirwCDA7UR1SB0Sb7VkBgV5-AGyQ@mail.gmail.com>
In-Reply-To
<20240104202605.7382-1-dev@tb6.eu>
On Thu, Jan 4, 2024 at 3:26 PM Tamino Bauknecht <dev@tb6.eu> wrote:
> I'm still not entirely happy with the tests (especially the `cp` in
> there)
Easily enough solved; see below...
> and the heredoc doesn't seem to respect the one additional
> space of its indentation - I am admittedly not the best POSIX shell
> developer, if anyone has an idea on how to improve it, your suggestion
> is welcome.

Not sure what you mean by the heredoc not "respecting one additional space of indentation".

The <<- operator strips leading TABs from the body of the heredoc but leaves other leading whitespace alone. In your tests, you have one or more TABs followed by two spaces, followed by the remaining (actual) text. So, with the leading TABs stripped off by the <<- operator, you're left with the two spaces and the remaining text, which is exactly what you want.

Show 37 quoted lines
> diff --git a/t/t5514-fetch-multiple.sh b/t/t5514-fetch-multiple.sh
> @@ -209,4 +218,70 @@ test_expect_success 'git fetch --multiple --jobs=0 picks a default' '
> +for fetch_all in true false
> +do
> +       test_expect_success "git fetch --all (works with fetch.all = $fetch_all)" '
> +               test_dir="test_fetch_all_$fetch_all" &&
> +               setup_test_clone "$test_dir" && (
> +                cd "$test_dir" &&
> +                git config fetch.all $fetch_all &&
> +                git fetch --all &&
> +                cat >expect <<-\ EOF &&
> +                 one/main
> +                 one/side
> +                 origin/HEAD -> origin/main
> +                 origin/main
> +                 origin/side
> +                 three/another
> +                 three/main
> +                 three/side
> +                 two/another
> +                 two/main
> +                 two/side
> +                EOF
> +                git branch -r >actual &&
> +                test_cmp expect actual)
> +       '
> +done
> +
> +test_expect_success 'git fetch (fetch all remotes with fetch.all = true)' '
> +       setup_test_clone test9 && (
> +        cd test9 &&
> +        git config fetch.all true &&
> +        git fetch --all &&
> +        git branch -r >actual &&
> +        cp ../test_fetch_all_true/expect . &&
> +        test_cmp expect actual)
> +'

Ideally, this test should create the "expect" file itself, even if the "expect" file happens to exactly match the "expect" file from the preceding test. Doing so will make the test (more) self-contained, which makes it possible to run the test in isolation without having to run all tests preceding it (see the --run option in t/README).

Previous: Tamino BauknechtNext: Eric Sunshine
Message 12 of 23 in “new config option "fetch.all"”
  1. Tamino BauknechtDec 18, 2023
  2. fetch: add new config option fetch.allTamino Bauknecht, Jan 4, 2024
  3. Taylor BlauJan 4, 2024
  4. Eric SunshineJan 4, 2024
  5. Junio C HamanoJan 4, 2024
  6. Tamino BauknechtJan 4, 2024
  7. Taylor BlauJan 4, 2024
  8. Junio C HamanoJan 4, 2024
  9. Tamino BauknechtJan 4, 2024
  10. Junio C HamanoJan 4, 2024
  11. fetch: add new config option fetch.allTamino Bauknecht, Jan 4, 2024
  12. Eric SunshineJan 4, 2024
  13. Eric SunshineJan 4, 2024
  14. 1/2 fetch: add new config option fetch.allTamino Bauknecht, Jan 4, 2024
  15. 2/2 fetch: add cli option --default-onlyTamino Bauknecht, Jan 4, 2024
  16. Eric SunshineJan 5, 2024
  17. Junio C HamanoJan 5, 2024
  18. fetch: add new config option fetch.allTamino Bauknecht, Jan 6, 2024
  19. Eric SunshineJan 6, 2024
  20. Eric SunshineJan 6, 2024
  21. Junio C HamanoJan 8, 2024
  22. fetch: add new config option fetch.allTamino Bauknecht, Jan 8, 2024
  23. Eric SunshineJan 5, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.