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

Re: [PATCH v2 2/4] t1500-rev-parse: add tests executed from sub path of the main worktree

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Apr 29, 2016, 14:22 UTC
Message-ID
<20160429142206.16397-1-szeder@ira.uka.de>
In-Reply-To
<1461361992-91918-3-git-send-email-rappazzo@gmail.com>
[Resend to list, sorry for the duplicates.]
Show 25 quoted lines
> Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>
> ---
>  t/t1500-rev-parse.sh | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
> 
> diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
> index 48ee077..1e220f7 100755
> --- a/t/t1500-rev-parse.sh
> +++ b/t/t1500-rev-parse.sh
> @@ -36,6 +36,7 @@ test_rev_parse() {
>  # label is-bare is-inside-git is-inside-work prefix git-dir
>  
>  ROOT=$(pwd)
> +original_core_bare=$(git config core.bare)
>  
>  test_rev_parse toplevel false false true '' .git
>  
> @@ -84,4 +85,40 @@ test_rev_parse 'GIT_DIR=../repo.git, core.bare = true' true false false ''
>  git config --unset core.bare
>  test_rev_parse 'GIT_DIR=../repo.git, core.bare undefined' false false true ''
>  
> +#cleanup from the above
> +cd ..
> +rm -r work
> +mv repo.git .git || exit 1

You can't just 'exit 1' mid-script, because terminating the test script abruptly makes the test harness unhappy.

> +unset GIT_DIR
> +unset GIT_CONFIG

Both variables are set at this point, so calling plain 'unset' is OK. Still, I would suggest using 'sane_unset' instead, so the next person looking at this test doesn't have to spend brain cycles on figuring out whether plain 'unset' is indeed safe or not.

> +git config core.bare $original_core_bare

This whole '#cleanup from the above' block is just ugly. Not your fault, of course, but the consequence of how the preceeding tests were written in the past. I think it would be best if this series were scheduled on top of the 't1500 cleanup & modernization' patch I saw a few days ago, then this block wouldn't be necessary at all.

Show 31 quoted lines
> +test_expect_success 'git-common-dir from worktree root' '
> +	echo .git >expect &&
> +	git rev-parse --git-common-dir >actual &&
> +	test_cmp expect actual
> +'
> +
> +test_expect_success 'git-common-dir inside sub-dir' '
> +	mkdir -p path/to/child &&
> +	test_when_finished "rm -rf path" &&
> +	echo "$(git -C path/to/child rev-parse --show-cdup).git" >expect &&
> +	git -C path/to/child rev-parse --git-common-dir >actual &&
> +	test_cmp expect actual
> +'
> +
> +test_expect_success 'git-path from worktree root' '
> +	echo .git/objects >expect &&
> +	git rev-parse --git-path objects >actual &&
> +	test_cmp expect actual
> +'
> +
> +test_expect_success 'git-path inside sub-dir' '
> +	mkdir -p path/to/child &&
> +	test_when_finished "rm -rf path" &&
> +	echo "$(git -C path/to/child rev-parse --show-cdup).git/objects" >expect &&
> +	git -C path/to/child rev-parse --git-path objects >actual &&
> +	test_cmp expect actual
> +'
> +
>  test_done
> -- 
> 2.8.0
Previous: Michael RappazzoNext: Michael Rappazzo
Message 5 of 12 in “rev-parse: adjust results when they should be relative”
  1. 0/4 rev-parse: adjust results when they should be relativeMichael Rappazzo, Apr 22, 2016
  2. 1/4 rev-parse: fix some options when executed from subpath of main treeMichael Rappazzo, Apr 22, 2016
  3. SZEDER GáborApr 29, 2016
  4. 2/4 t1500-rev-parse: add tests executed from sub path of the main worktreeMichael Rappazzo, Apr 22, 2016
  5. SZEDER GáborApr 29, 2016
  6. 3/4 t2027-worktree-list: add and adjust tests related to git-rev-parseMichael Rappazzo, Apr 22, 2016
  7. SZEDER GáborApr 29, 2016
  8. 4/4 t1700-split-index: add test for rev-parse --shared-index-pathMichael Rappazzo, Apr 22, 2016
  9. Mike RappazzoMay 6, 2016
  10. SZEDER GáborMay 6, 2016
  11. Junio C HamanoMay 6, 2016
  12. Eric SunshineMay 10, 2016

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.