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

Re: [PATCH 1/7] t: move tests exercising the "files" backend

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 14, 2024, 22:45 UTC
Message-ID
<xmqqr0heu0kt.fsf@gitster.g>
In-Reply-To
<2eca90234f60b5f48e444e8be212bd70b9ebf924.1707463221.git.ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 16 quoted lines
> We still have a bunch of tests scattered across our test suites that
> exercise on-disk files of the "files" backend directly:
>
>   - t1301 exercises permissions of reflog files when the config
>     "core.sharedRepository" is set.
>
>   - t1400 exercises whether empty directories in the ref store are
>     handled correctly.
>
>   - t3200 exercises what happens when there are symlinks in the ref
>     store.
>
>   - t3400 also exercises what happens when ".git/logs" is a symlink.
>
> All of these are inherently low-level tests specific to the "files"
> backend. Move them into "t0600-reffiles-backend.sh" to reflect this.
Makes sense, and they look like straight code movements.
Show 7 quoted lines
> diff --git a/t/t0600-reffiles-backend.sh b/t/t0600-reffiles-backend.sh
> index e6a5f1868f..485481d6b4 100755
> --- a/t/t0600-reffiles-backend.sh
> +++ b/t/t0600-reffiles-backend.sh
> @@ -381,4 +381,95 @@ test_expect_success 'log diagnoses bogus HEAD symref' '
>  	test_grep broken stderr
>  '
These two are from t1400.
Show 26 quoted lines
> +test_expect_success 'empty directory removal' '
> +	git branch d1/d2/r1 HEAD &&
> +	git branch d1/r2 HEAD &&
> +	test_path_is_file .git/refs/heads/d1/d2/r1 &&
> +	test_path_is_file .git/logs/refs/heads/d1/d2/r1 &&
> +	git branch -d d1/d2/r1 &&
> +	test_must_fail git show-ref --verify -q refs/heads/d1/d2 &&
> +	test_must_fail git show-ref --verify -q logs/refs/heads/d1/d2 &&
> +	test_path_is_file .git/refs/heads/d1/r2 &&
> +	test_path_is_file .git/logs/refs/heads/d1/r2
> +'
> +
> +test_expect_success 'symref empty directory removal' '
> +	git branch e1/e2/r1 HEAD &&
> +	git branch e1/r2 HEAD &&
> +	git checkout e1/e2/r1 &&
> +	test_when_finished "git checkout main" &&
> +	test_path_is_file .git/refs/heads/e1/e2/r1 &&
> +	test_path_is_file .git/logs/refs/heads/e1/e2/r1 &&
> +	git update-ref -d HEAD &&
> +	test_must_fail git show-ref --verify -q refs/heads/e1/e2 &&
> +	test_must_fail git show-ref --verify -q logs/refs/heads/e1/e2 &&
> +	test_path_is_file .git/refs/heads/e1/r2 &&
> +	test_path_is_file .git/logs/refs/heads/e1/r2 &&
> +	test_path_is_file .git/logs/HEAD
> +'

Luckily there aren't refs that were created at this point by earlier tests that would contradict/block the creation of the new refs this moved tests would want to create.

Show 8 quoted lines
> +test_expect_success 'directory not created deleting packed ref' '
> +	git branch d1/d2/r1 HEAD &&
> +	git pack-refs --all &&
> +	test_path_is_missing .git/refs/heads/d1/d2 &&
> +	git update-ref -d refs/heads/d1/d2/r1 &&
> +	test_path_is_missing .git/refs/heads/d1/d2 &&
> +	test_path_is_missing .git/refs/heads/d1
> +'

And this is from the same t1400 but appears much later in the file. Curiously, this tries to create d1/d2/r1 that an earlier test already created, and this one passes because the branch gets removed in the other test that also created the branch. Tricky but not a fault of this patch.

Show 6 quoted lines
> +test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '
> +	git branch --create-reflog u &&
> +	mv .git/logs/refs/heads/u real-u &&
> +	ln -s real-u .git/logs/refs/heads/u &&
> +	test_must_fail git branch -m u v
> +'

This was migrated from t3200 and has no interaction with the new context of t0600 as branch 'u' has never been used. I notice that this test is buggy since its inception at 16c2bfbb (rename_ref: use lstat(2) when testing for symlink, 2006-11-29) in that we move the log for branch 'u' up and then make the log for branch 'u' into a dangling symlink, so it probably failed for a wrong reason even before 16c2bfbb updated stat() to lstat(). Anyway, the current code will see that logs/refs/heads/u is a symbolic link and fails, regardless of what the link points at, so we are OK. In any case, not a fault of this patch.

Show 21 quoted lines
> +test_expect_success SYMLINKS 'git branch -m with symlinked .git/refs' '
> +	test_when_finished "rm -rf subdir" &&
> +	git init --bare subdir &&
> +
> +	rm -rfv subdir/refs subdir/objects subdir/packed-refs &&
> +	ln -s ../.git/refs subdir/refs &&
> +	ln -s ../.git/objects subdir/objects &&
> +	ln -s ../.git/packed-refs subdir/packed-refs &&
> +
> +	git -C subdir rev-parse --absolute-git-dir >subdir.dir &&
> +	git rev-parse --absolute-git-dir >our.dir &&
> +	! test_cmp subdir.dir our.dir &&
> +
> +	git -C subdir log &&
> +	git -C subdir branch rename-src &&
> +	git rev-parse rename-src >expect &&
> +	git -C subdir branch -m rename-src rename-dest &&
> +	git rev-parse rename-dest >actual &&
> +	test_cmp expect actual &&
> +	git branch -D rename-dest
> +'

OK. As long as it cleans after itself, I won't read deeply into it and stop at making sure this came verbatim from t3200.

Show 9 quoted lines
> +test_expect_success MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' '
> +	git checkout main &&
> +	mv .git/logs actual_logs &&
> +	cmd //c "mklink /D .git\logs ..\actual_logs" &&
> +	git rebase -f HEAD^ &&
> +	test -L .git/logs &&
> +	rm .git/logs &&
> +	mv actual_logs .git/logs
> +'

As t0600 forces the default branch to be 'main', having this one migrated from t3400 should be safe.

Show 15 quoted lines
> +test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
> +	umask 077 &&
> +	git config core.sharedRepository group &&
> +	git reflog expire --all &&
> +	actual="$(ls -l .git/logs/refs/heads/main)" &&
> +	case "$actual" in
> +	-rw-rw-*)
> +		: happy
> +		;;
> +	*)
> +		echo Ooops, .git/logs/refs/heads/main is not 066x [$actual]
> +		false
> +		;;
> +	esac
> +'
And this is from t1301, another verbatim copy.
Show 25 quoted lines
>  test_done
> diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh
> index 8e2c01e760..b1eb5c01b8 100755
> --- a/t/t1301-shared-repo.sh
> +++ b/t/t1301-shared-repo.sh
> @@ -137,22 +137,6 @@ test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' '
>  	test_cmp expect actual
>  '
>  
> -test_expect_success REFFILES,POSIXPERM 'git reflog expire honors core.sharedRepository' '
> -	umask 077 &&
> -	git config core.sharedRepository group &&
> -	git reflog expire --all &&
> -	actual="$(ls -l .git/logs/refs/heads/main)" &&
> -	case "$actual" in
> -	-rw-rw-*)
> -		: happy
> -		;;
> -	*)
> -		echo Ooops, .git/logs/refs/heads/main is not 066x [$actual]
> -		false
> -		;;
> -	esac
> -'
> -

The rest of t1301 does not appear to depend on the reflog being expired, so this move should be safe.

Show 53 quoted lines
>  test_expect_success POSIXPERM 'forced modes' '
>  	test_when_finished "rm -rf new" &&
>  	mkdir -p templates/hooks &&
> diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
> index f18843bf7a..3294b7ce08 100755
> --- a/t/t1400-update-ref.sh
> +++ b/t/t1400-update-ref.sh
> @@ -288,33 +288,6 @@ test_expect_success "set $m (logged by touch)" '
>  	test $A = $(git show-ref -s --verify $m)
>  '
>  
> -test_expect_success REFFILES 'empty directory removal' '
> -	git branch d1/d2/r1 HEAD &&
> -	git branch d1/r2 HEAD &&
> -	test_path_is_file .git/refs/heads/d1/d2/r1 &&
> -	test_path_is_file .git/logs/refs/heads/d1/d2/r1 &&
> -	git branch -d d1/d2/r1 &&
> -	test_must_fail git show-ref --verify -q refs/heads/d1/d2 &&
> -	test_must_fail git show-ref --verify -q logs/refs/heads/d1/d2 &&
> -	test_path_is_file .git/refs/heads/d1/r2 &&
> -	test_path_is_file .git/logs/refs/heads/d1/r2
> -'
> -
> -test_expect_success REFFILES 'symref empty directory removal' '
> -	git branch e1/e2/r1 HEAD &&
> -	git branch e1/r2 HEAD &&
> -	git checkout e1/e2/r1 &&
> -	test_when_finished "git checkout main" &&
> -	test_path_is_file .git/refs/heads/e1/e2/r1 &&
> -	test_path_is_file .git/logs/refs/heads/e1/e2/r1 &&
> -	git update-ref -d HEAD &&
> -	test_must_fail git show-ref --verify -q refs/heads/e1/e2 &&
> -	test_must_fail git show-ref --verify -q logs/refs/heads/e1/e2 &&
> -	test_path_is_file .git/refs/heads/e1/r2 &&
> -	test_path_is_file .git/logs/refs/heads/e1/r2 &&
> -	test_path_is_file .git/logs/HEAD
> -'
> -
>  cat >expect <<EOF
>  $Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000	Initial Creation
>  $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000	Switch
> @@ -1668,13 +1641,4 @@ test_expect_success PIPE 'transaction flushes status updates' '
>  	test_cmp expected actual
>  '
>  
> -test_expect_success REFFILES 'directory not created deleting packed ref' '
> -	git branch d1/d2/r1 HEAD &&
> -	git pack-refs --all &&
> -	test_path_is_missing .git/refs/heads/d1/d2 &&
> -	git update-ref -d refs/heads/d1/d2/r1 &&
> -	test_path_is_missing .git/refs/heads/d1/d2 &&
> -	test_path_is_missing .git/refs/heads/d1
> -'

I've covered how these removals should be safe for the remaining tests in this file already. Good.

Show 37 quoted lines
>  test_done
> diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
> index de7d3014e4..e36f4d15f2 100755
> --- a/t/t3200-branch.sh
> +++ b/t/t3200-branch.sh
> @@ -836,35 +836,6 @@ test_expect_success 'renaming a symref is not allowed' '
>  	test_ref_missing refs/heads/new-topic
>  '
>  
> -test_expect_success SYMLINKS,REFFILES 'git branch -m u v should fail when the reflog for u is a symlink' '
> -	git branch --create-reflog u &&
> -	mv .git/logs/refs/heads/u real-u &&
> -	ln -s real-u .git/logs/refs/heads/u &&
> -	test_must_fail git branch -m u v
> -'
> -
> -test_expect_success SYMLINKS,REFFILES 'git branch -m with symlinked .git/refs' '
> -	test_when_finished "rm -rf subdir" &&
> -	git init --bare subdir &&
> -
> -	rm -rfv subdir/refs subdir/objects subdir/packed-refs &&
> -	ln -s ../.git/refs subdir/refs &&
> -	ln -s ../.git/objects subdir/objects &&
> -	ln -s ../.git/packed-refs subdir/packed-refs &&
> -
> -	git -C subdir rev-parse --absolute-git-dir >subdir.dir &&
> -	git rev-parse --absolute-git-dir >our.dir &&
> -	! test_cmp subdir.dir our.dir &&
> -
> -	git -C subdir log &&
> -	git -C subdir branch rename-src &&
> -	git rev-parse rename-src >expect &&
> -	git -C subdir branch -m rename-src rename-dest &&
> -	git rev-parse rename-dest >actual &&
> -	test_cmp expect actual &&
> -	git branch -D rename-dest
> -'
Likewise.
Show 21 quoted lines
> diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
> index 57f1392926..e1c8c5f701 100755
> --- a/t/t3400-rebase.sh
> +++ b/t/t3400-rebase.sh
> @@ -424,16 +424,6 @@ test_expect_success 'refuse to switch to branch checked out elsewhere' '
>  	test_grep "already used by worktree at" err
>  '
>  
> -test_expect_success REFFILES,MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' '
> -	git checkout main &&
> -	mv .git/logs actual_logs &&
> -	cmd //c "mklink /D .git\logs ..\actual_logs" &&
> -	git rebase -f HEAD^ &&
> -	test -L .git/logs &&
> -	rm .git/logs &&
> -	mv actual_logs .git/logs
> -'
> -
>  test_expect_success 'rebase when inside worktree subdirectory' '
>  	git init main-wt &&
>  	(
Looking good.
Thanks.
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 3 of 28 in “t: drop more REFFILES prereqs”
  1. 0/7 t: drop more REFFILES prereqsPatrick Steinhardt, Feb 9, 2024
  2. 1/7 t: move tests exercising the "files" backendPatrick Steinhardt, Feb 9, 2024
  3. Junio C HamanoFeb 14, 2024
  4. 2/7 t0410: enable tests with extensions with non-default repo formatPatrick Steinhardt, Feb 9, 2024
  5. Junio C HamanoFeb 14, 2024
  6. Patrick SteinhardtFeb 15, 2024
  7. Junio C HamanoFeb 15, 2024
  8. 3/7 t1400: exercise reflog with gaps with reftable backendPatrick Steinhardt, Feb 9, 2024
  9. Junio C HamanoFeb 14, 2024
  10. 4/7 t1404: make D/F conflict tests compatible with reftable backendPatrick Steinhardt, Feb 9, 2024
  11. Junio C HamanoFeb 14, 2024
  12. 5/7 t1405: remove unneeded cleanup stepPatrick Steinhardt, Feb 9, 2024
  13. Junio C HamanoFeb 14, 2024
  14. Patrick SteinhardtFeb 15, 2024
  15. 6/7 t2011: exercise D/F conflicts with HEAD with the reftable backendPatrick Steinhardt, Feb 9, 2024
  16. 7/7 t7003: ensure filter-branch prunes reflogs with the reftable backendPatrick Steinhardt, Feb 9, 2024
  17. Karthik NayakFeb 11, 2024
  18. Junio C HamanoFeb 14, 2024
  19. Patrick SteinhardtFeb 15, 2024
  20. 0/7 t: drop more REFFILES prereqsPatrick Steinhardt, Feb 15, 2024
  21. 1/7 t: move tests exercising the "files" backendPatrick Steinhardt, Feb 15, 2024
  22. 2/7 t0410: convert tests to use DEFAULT_REPO_FORMAT prereqPatrick Steinhardt, Feb 15, 2024
  23. Junio C HamanoFeb 15, 2024
  24. 3/7 t1400: exercise reflog with gaps with reftable backendPatrick Steinhardt, Feb 15, 2024
  25. 4/7 t1404: make D/F conflict tests compatible with reftable backendPatrick Steinhardt, Feb 15, 2024
  26. 5/7 t1405: remove unneeded cleanup stepPatrick Steinhardt, Feb 15, 2024
  27. 6/7 t2011: exercise D/F conflicts with HEAD with the reftable backendPatrick Steinhardt, Feb 15, 2024
  28. 7/7 t7003: ensure filter-branch prunes reflogs with the reftable backendPatrick Steinhardt, Feb 15, 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.