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

Re: [PATCH 3/5] t5318: avoid top-level directory changes

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 21, 2023, 18:28 UTC
Message-ID
<CAPig+cSkoHnUY0obKkz93k7mHXrFj+kwJ21yPHy=KYroAQtiUA@mail.gmail.com>
In-Reply-To
<451ec003be8714bc38cc8cdc159add3e8899ce57.1689960606.git.me@ttaylorr.com>
On Fri, Jul 21, 2023 at 1:33 PM Taylor Blau <me@ttaylorr.com> wrote:
Show 45 quoted lines
> Avoid changing the current working directory from outside of a sub-shell
> during the tests in t5318.
>
> Each test has mostly straightforward changes, either:
>
>   - Removing the top-level `cd "$TRASH_DIRECTORY/full"`, which is
>     unnecessary after ensuring that other tests don't change their
>     working directory outside of a sub-shell.
>
>   - Changing any Git invocations which want to be in a sub-directory by
>     either (a) adding a "-C $DIR" argument, or (b) moving the whole test
>     into a sub-shell.
>
> While we're here, remove any explicit "git config core.commitGraph true"
> invocations which were designed to enable use of the commit-graph. These
> are unnecessary following 31b1de6a09b (commit-graph: turn on
> commit-graph by default, 2019-08-13).
>
> Signed-off-by: Taylor Blau <me@ttaylorr.com>
> ---
> diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
> @@ -69,117 +64,106 @@ test_expect_success 'create commits and repack' '
>  test_expect_success 'Add more commits' '
>  ...
> -       git reset --hard commits/2 &&
> -       git merge commits/4 &&
> -       git branch merge/1 &&
> -       git reset --hard commits/4 &&
> -       git merge commits/6 &&
> -       git branch merge/2 &&
> -       git reset --hard commits/3 &&
> -       git merge commits/5 commits/7 &&
> -       git branch merge/3 &&
> -       git repack
> +       git -C full reset --hard commits/2 &&
> +       git -C full merge commits/4 &&
> +       git -C full branch merge/1 &&
> +       git -C full reset --hard commits/4 &&
> +       git -C full merge commits/6 &&
> +       git -C full branch merge/2 &&
> +       git -C full reset --hard commits/3 &&
> +       git -C full merge commits/5 commits/7 &&
> +       git -C full branch merge/3 &&
> +       git -C full repack
>  '

This is one of those cases in which "cd full" while in subshell, rather than using "-C full" repeatedly, would perhaps make the code a bit less noisy, but it is, of course, subjective and what you have here is good enough.

Show 10 quoted lines
> @@ -229,114 +211,101 @@ graph_git_behavior 'mixed mode, commit 8 vs merge 1' full commits/8 merge/1
>  test_expect_success 'build graph from latest pack with closure' '
> -       cd "$TRASH_DIRECTORY/full" &&
> -       cat new-idx | git commit-graph write --stdin-packs &&
> -       test_path_is_file $objdir/info/commit-graph &&
> -       graph_read_expect "9" "generation_data extra_edges"
> +       git -C full commit-graph write --stdin-packs <new-idx &&
> +       test_path_is_file full/$objdir/info/commit-graph &&
> +       graph_read_expect -C full 9 "generation_data extra_edges"
>  '

This works because an earlier test created "new-idx", and it created it directly in the trash-directory rather than in the "full" subdirectory where it used to reside before this patch. Okay.

Show 10 quoted lines
> @@ -495,25 +464,24 @@ GRAPH_BYTE_OCTOPUS=$(($GRAPH_OCTOPUS_DATA_OFFSET + 4))
>  corrupt_graph_setup() {
> -       cd "$TRASH_DIRECTORY/full" &&
> -       test_when_finished mv commit-graph-backup $objdir/info/commit-graph &&
> -       cp $objdir/info/commit-graph commit-graph-backup &&
> -       chmod u+w $objdir/info/commit-graph
> +       test_when_finished mv commit-graph-backup full/$objdir/info/commit-graph &&
> +       cp full/$objdir/info/commit-graph commit-graph-backup &&
> +       chmod u+w full/$objdir/info/commit-graph
>  }

Prior to this patch, "commit-graph-backup" was placed in the "full" subdirectory and test_when_finished() removed it from that location. As of this patch, "commit-graph-backup" is placed in the top-level trash-directory and cleaned up from there. Okay.

Previous: Taylor BlauNext: Taylor Blau
Message 8 of 22 in “commit-graph: test cleanup and modernization”
  1. 0/5 commit-graph: test cleanup and modernizationTaylor Blau, Jul 21, 2023
  2. 1/5 t/lib-commit-graph.sh: allow `graph_read_expect()` in sub-directoriesTaylor Blau, Jul 21, 2023
  3. Eric SunshineJul 21, 2023
  4. Taylor BlauJul 21, 2023
  5. Junio C HamanoJul 21, 2023
  6. 4/5 t5328: avoid top-level directory changesTaylor Blau, Jul 21, 2023
  7. 3/5 t5318: avoid top-level directory changesTaylor Blau, Jul 21, 2023
  8. Eric SunshineJul 21, 2023
  9. 2/5 t/lib-commit-graph.sh: avoid directory change in `graph_git_behavior()`Taylor Blau, Jul 21, 2023
  10. Eric SunshineJul 21, 2023
  11. Taylor BlauJul 21, 2023
  12. Junio C HamanoJul 21, 2023
  13. 5/5 t/lib-commit-graph.sh: avoid sub-shell in `graph_git_behavior()`Taylor Blau, Jul 21, 2023
  14. Eric SunshineJul 21, 2023
  15. Junio C HamanoJul 21, 2023
  16. 0/5 commit-graph: test cleanup and modernizationTaylor Blau, Jul 24, 2023
  17. 1/5 t/lib-commit-graph.sh: allow `graph_read_expect()` in sub-directoriesTaylor Blau, Jul 24, 2023
  18. 2/5 t/lib-commit-graph.sh: avoid directory change in `graph_git_behavior()`Taylor Blau, Jul 24, 2023
  19. 3/5 t5318: avoid top-level directory changesTaylor Blau, Jul 24, 2023
  20. Junio C HamanoJul 24, 2023
  21. 5/5 t/lib-commit-graph.sh: avoid sub-shell in `graph_git_behavior()`Taylor Blau, Jul 24, 2023
  22. 4/5 t5328: avoid top-level directory changesTaylor Blau, Jul 24, 2023

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.