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

Re: [PATCH 04/11] t: convert tests to not write references via the filesystem

From
Patrick Steinhardt <ps@pks.im>
Date
Oct 23, 2023, 13:58 UTC
Message-ID
<ZTZ8ATohRe7GVu5D@tanuki>
In-Reply-To
<xmqq1qdru6ds.fsf@gitster.g>
On Wed, Oct 18, 2023 at 11:34:23AM -0700, Junio C Hamano wrote:
Show 26 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > -test_expect_success "fail to create $n" '
> > -	test_when_finished "rm -f .git/$n_dir" &&
> > -	touch .git/$n_dir &&
> > -	test_must_fail git update-ref $n $A
> > +test_expect_success "fail to create $n due to file/directory conflict" '
> > +	test_when_finished "git update-ref -d refs/heads/gu" &&
> > +	git update-ref refs/heads/gu $A &&
> > +	test_must_fail git update-ref refs/heads/gu/fixes $A
> >  '
> 
> OK, the original checks "if a random garbage file, which may not
> necessarily be a ref, exists at $n_dir, we cannot create a ref at
> $n_dir/fixes, due to D/F conflict" more directly, but as long as our
> intention is to enforce the D/F restriction across different ref
> backends [*], creating a ref at $n_dir and making sure $n_dir/fixes
> cannot be created is an equivalent check that is better (because it
> can be applied for other backends).
> 
>     Side note: there is no fundamental need to, though, and there
>          are cases where being able to have the 'seen' branch and
>          'seen/ps/ref-test-tools' branches at the same time is
>          beneficial---packed-refs and ref-table backends would not
>          have such an inherent limitation, but they can of course be
>          castrated to match what files-backend can(not) do.

I think initially it is beneficial to keep any such restriction and cut back new backends to match them, even though it's more work. The main reason why I think this makes sense is that hosting providers are the most likely to update to the newer backend fast. It would be detrimental to the users though if hosting providers that converted to the newer backend were able to store such references that would be conflicting with the files backend because they wouldn't be able to clone such repositories anymore. And this isn't only true for hosting providers, but essentially whenever two repositories that use different backends try to interact with each other.

So even though I wish for a future where we don't need to care for D/F conflicts anymore, I think the time isn't ripe for it and we should for now aim for matching behaviour.

Show 11 quoted lines
> > @@ -222,7 +220,7 @@ test_expect_success 'delete symref without dereference when the referred ref is
> >  
> >  test_expect_success 'update-ref -d is not confused by self-reference' '
> >  	git symbolic-ref refs/heads/self refs/heads/self &&
> > -	test_when_finished "rm -f .git/refs/heads/self" &&
> > +	test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF refs/heads/self" &&
> >  	test_path_is_file .git/refs/heads/self &&
> 
> I trust that this will be corrected to use some wrapper around "git
> symbolic-ref" (or an equivalent for it as a test-tool subcommand) in
> some future patch, if not in this series?

Yup, this is getting fixed in a subsequent patch. I had two different options to structure this series:

    - Either by test file so that questions like this don't come up when
      a reviewer sees in the context that there are still tests that
      exercise the filesystem directly. This was my first approach.
    - The alternative is to write it such that we address common
      patterns globally, which I then rewrote my first version to.
There were two reasons why I didn't like the first iteration:
    - Commit messages would basically have to reexplain the exact same
      thing for every single testcase as the motivation is the same
      everywhere.
    - I think it's easier to review when you only see the same kind of
      transformation per patch.

But yes, it does have the downside that the reader is now left wondering why the other call to `test_path_is_file` still exists.

Patrick
Show 19 quoted lines
> >  	test_must_fail git update-ref -d refs/heads/self &&
> >  	test_path_is_file .git/refs/heads/self
> 
> Likewise.
> 
> > @@ -230,7 +228,7 @@ test_expect_success 'update-ref -d is not confused by self-reference' '
> >  
> >  test_expect_success 'update-ref --no-deref -d can delete self-reference' '
> >  	git symbolic-ref refs/heads/self refs/heads/self &&
> > -	test_when_finished "rm -f .git/refs/heads/self" &&
> > +	test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF refs/heads/self" &&
> >  	test_path_is_file .git/refs/heads/self &&
> >  	git update-ref --no-deref -d refs/heads/self &&
> >  	test_must_fail git show-ref --verify -q refs/heads/self
> 
> We already have the "ref is missing" test here.
> 
> I'll stop at this point for now; will hopefully continue in a
> separate message later.  Thanks.
Previous: Junio C HamanoNext: Junio C Hamano
Message 15 of 59 in “t: reduce direct disk access to data structures”
  1. 00/11 t: reduce direct disk access to data structuresPatrick Steinhardt, Oct 18, 2023
  2. 01/11 t: add helpers to test for reference existencePatrick Steinhardt, Oct 18, 2023
  3. Junio C HamanoOct 18, 2023
  4. Patrick SteinhardtOct 23, 2023
  5. Eric SunshineOct 18, 2023
  6. Patrick SteinhardtOct 23, 2023
  7. 02/11 t: allow skipping expected object ID in `ref-store update-ref`Patrick Steinhardt, Oct 18, 2023
  8. Junio C HamanoOct 18, 2023
  9. Patrick SteinhardtOct 23, 2023
  10. Junio C HamanoOct 23, 2023
  11. 03/11 t: convert tests to use helpers for reference existencePatrick Steinhardt, Oct 18, 2023
  12. Junio C HamanoOct 18, 2023
  13. 04/11 t: convert tests to not write references via the filesystemPatrick Steinhardt, Oct 18, 2023
  14. Junio C HamanoOct 18, 2023
  15. Patrick SteinhardtOct 23, 2023
  16. Junio C HamanoOct 23, 2023
  17. Junio C HamanoOct 18, 2023
  18. Patrick SteinhardtOct 23, 2023
  19. 05/11 t: convert tests to not access symrefs via the filesystemPatrick Steinhardt, Oct 18, 2023
  20. Junio C HamanoOct 20, 2023
  21. 06/11 t: convert tests to not access reflog via the filesystemPatrick Steinhardt, Oct 18, 2023
  22. Junio C HamanoOct 21, 2023
  23. 07/11 t1450: convert tests to remove worktrees via git-worktree(1)Patrick Steinhardt, Oct 18, 2023
  24. 08/11 t4207: delete replace references via git-update-ref(1)Patrick Steinhardt, Oct 18, 2023
  25. Han-Wen NienhuysOct 18, 2023
  26. Patrick SteinhardtOct 23, 2023
  27. Taylor BlauOct 23, 2023
  28. Patrick SteinhardtOct 24, 2023
  29. 09/11 t7300: assert exact states of repoPatrick Steinhardt, Oct 18, 2023
  30. 10/11 t7900: assert the absence of refs via git-for-each-ref(1)Patrick Steinhardt, Oct 18, 2023
  31. 11/11 t: mark several tests that assume the files backend with REFFILESPatrick Steinhardt, Oct 18, 2023
  32. Patrick SteinhardtOct 18, 2023
  33. Junio C HamanoOct 18, 2023
  34. Patrick SteinhardtOct 23, 2023
  35. Junio C HamanoOct 18, 2023
  36. Han-Wen NienhuysOct 19, 2023
  37. Junio C HamanoOct 19, 2023
  38. Patrick SteinhardtOct 23, 2023
  39. 0/9 t: reduce direct disk access to data structuresPatrick Steinhardt, Oct 24, 2023
  40. 1/9 t: allow skipping expected object ID in `ref-store update-ref`Patrick Steinhardt, Oct 24, 2023
  41. 2/9 t: convert tests to not write references via the filesystemPatrick Steinhardt, Oct 24, 2023
  42. 3/9 t: convert tests to not access symrefs via the filesystemPatrick Steinhardt, Oct 24, 2023
  43. 4/9 t: convert tests to not access reflog via the filesystemPatrick Steinhardt, Oct 24, 2023
  44. 5/9 t1450: convert tests to remove worktrees via git-worktree(1)Patrick Steinhardt, Oct 24, 2023
  45. Eric SunshineOct 27, 2023
  46. 6/9 t4207: delete replace references via git-update-ref(1)Patrick Steinhardt, Oct 24, 2023
  47. 7/9 t7300: assert exact states of repoPatrick Steinhardt, Oct 24, 2023
  48. 8/9 t7900: assert the absence of refs via git-for-each-ref(1)Patrick Steinhardt, Oct 24, 2023
  49. 9/9 t: mark several tests that assume the files backend with REFFILESPatrick Steinhardt, Oct 24, 2023
  50. 0/9 t: reduce direct disk access to data structuresPatrick Steinhardt, Nov 2, 2023
  51. 1/9 t: allow skipping expected object ID in `ref-store update-ref`Patrick Steinhardt, Nov 2, 2023
  52. 2/9 t: convert tests to not write references via the filesystemPatrick Steinhardt, Nov 2, 2023
  53. 3/9 t: convert tests to not access symrefs via the filesystemPatrick Steinhardt, Nov 2, 2023
  54. 4/9 t: convert tests to not access reflog via the filesystemPatrick Steinhardt, Nov 2, 2023
  55. 5/9 t1450: convert tests to remove worktrees via git-worktree(1)Patrick Steinhardt, Nov 2, 2023
  56. 6/9 t4207: delete replace references via git-update-ref(1)Patrick Steinhardt, Nov 2, 2023
  57. 7/9 t7300: assert exact states of repoPatrick Steinhardt, Nov 2, 2023
  58. 8/9 t7900: assert the absence of refs via git-for-each-ref(1)Patrick Steinhardt, Nov 2, 2023
  59. 9/9 t: mark several tests that assume the files backend with REFFILESPatrick Steinhardt, Nov 2, 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.