Web lists-archives.com

Re: [PATCH 03/10] t0002: abstract away SHA-1-specific constants




On Mon, Jun 4, 2018 at 7:52 PM, brian m. carlson
<sandals@xxxxxxxxxxxxxxxxxxxx> wrote:
> Adjust the test so that it computes variables for object IDs instead of
> using hard-coded hashes.
>
> Signed-off-by: brian m. carlson <sandals@xxxxxxxxxxxxxxxxxxxx>
> ---
> diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh
> @@ -89,14 +89,16 @@ test_expect_success 'enter_repo non-strict mode' '
>                 cd enter_repo &&
>                 test_tick &&
>                 test_commit foo &&
> +               git rev-parse HEAD >head-revision &&
>                 mv .git .realgit &&
>                 echo "gitdir: .realgit" >.git
>         ) &&
> +       head=$(cat enter_repo/head-revision) &&

Stashing the value temporarily in a file ("head-revision") is
unnecessary and somewhat ugly. Just grab it directly after the
subshell exits:

    (
        cd enter_repo &&
        ...
    ) &&
    head=$(git -C enter_repo rev-parse HEAD) &&
    ...