git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Taylor Blau <me@ttaylorr.com>
Cc: git@vger.kernel.org, Derrick Stolee <derrickstolee@github.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 3/5] t5318: avoid top-level directory changes
Date: Fri, 21 Jul 2023 14:28:17 -0400	[thread overview]
Message-ID: <CAPig+cSkoHnUY0obKkz93k7mHXrFj+kwJ21yPHy=KYroAQtiUA@mail.gmail.com> (raw)
In-Reply-To: <451ec003be8714bc38cc8cdc159add3e8899ce57.1689960606.git.me@ttaylorr.com>

On Fri, Jul 21, 2023 at 1:33 PM Taylor Blau <me@ttaylorr.com> wrote:
> 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.

> @@ -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.

> @@ -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.

  reply	other threads:[~2023-07-21 18:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 17:30 [PATCH 0/5] commit-graph: test cleanup and modernization Taylor Blau
2023-07-21 17:30 ` [PATCH 1/5] t/lib-commit-graph.sh: allow `graph_read_expect()` in sub-directories Taylor Blau
2023-07-21 17:41   ` Eric Sunshine
2023-07-21 18:33     ` Taylor Blau
2023-07-21 18:54       ` Junio C Hamano
2023-07-21 17:30 ` [PATCH 2/5] t/lib-commit-graph.sh: avoid directory change in `graph_git_behavior()` Taylor Blau
2023-07-21 18:01   ` Eric Sunshine
2023-07-21 18:39     ` Taylor Blau
2023-07-21 19:02       ` Junio C Hamano
2023-07-21 17:30 ` [PATCH 3/5] t5318: avoid top-level directory changes Taylor Blau
2023-07-21 18:28   ` Eric Sunshine [this message]
2023-07-21 17:30 ` [PATCH 4/5] t5328: " Taylor Blau
2023-07-21 17:30 ` [PATCH 5/5] t/lib-commit-graph.sh: avoid sub-shell in `graph_git_behavior()` Taylor Blau
2023-07-21 18:34 ` [PATCH 0/5] commit-graph: test cleanup and modernization Eric Sunshine
2023-07-21 22:35 ` Junio C Hamano
2023-07-24 16:39 ` [PATCH v2 " Taylor Blau
2023-07-24 16:39   ` [PATCH v2 1/5] t/lib-commit-graph.sh: allow `graph_read_expect()` in sub-directories Taylor Blau
2023-07-24 16:39   ` [PATCH v2 2/5] t/lib-commit-graph.sh: avoid directory change in `graph_git_behavior()` Taylor Blau
2023-07-24 16:39   ` [PATCH v2 3/5] t5318: avoid top-level directory changes Taylor Blau
2023-07-24 21:48     ` Junio C Hamano
2023-07-24 16:39   ` [PATCH v2 4/5] t5328: " Taylor Blau
2023-07-24 16:39   ` [PATCH v2 5/5] t/lib-commit-graph.sh: avoid sub-shell in `graph_git_behavior()` Taylor Blau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPig+cSkoHnUY0obKkz93k7mHXrFj+kwJ21yPHy=KYroAQtiUA@mail.gmail.com' \
    --to=sunshine@sunshineco.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).