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

Re: [PATCH 2/6] t3404-rebase-interactive: mark a test with REFFILES prereq

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 5, 2022, 16:45 UTC
Message-ID
<xmqqwn9eqkw8.fsf@gitster.g>
In-Reply-To
<220930.86ill4vman.gmgdl@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 21 quoted lines
> On Fri, Sep 30 2022, SZEDER Gábor wrote:
>
>> The test '--update-refs: check failed ref update' added in b3b1a21d1a
>> (sequencer: rewrite update-refs as user edits todo list, 2022-07-19)
>> directly modifies the contents of a ref file, so mark this test with
>> the REFFILES prereq.
>> ...
>  	# At this point, the values of first, second, and third are
>  	# recorded in the update-refs file. We will force-update the
>  	# "second" ref, but "git branch -f" will not work because of
> -	# the lock in the update-refs file.
> -	git rev-parse third >.git/refs/heads/second &&
> +	# the lock in the update-refs file, so we need to use
> +	# "update-ref".
> +	git update-ref refs/heads/second third &&
>  
>  	test_must_fail git rebase --continue 2>err &&
>  	grep "update_ref failed for ref '\''refs/heads/second'\''" err &&
>
> As the comment notes if you try that with "git branch" you'll get an
> error, even with --force, but update-ref works just fine...

Ah, I had exactly the same thought but was stopped from sending the suggestion to use "git update-ref" right away by "because of the lock in the update-refs file" that did not immediately click. What is happening is "git branch" and any Porcelain commands that call the now slightly misnamed branch_checked_out() function to see if an operation is allowed to touch a branch would refrain from touching this ref, but "update-ref" as a plumbing is deliberately designed to be usable to bypass the check [*]. The --update-refs series added code to branch_checked_out() to consider any refs being rewritten as "checked out hence no touch".

Even though being listed in the update-refs file may count as a moral equivalent to having a "lock in the update-refs file", because write_update_refs_state() mentions no "lock", the proposed log message was confusing and I think that was why it did not "immediately click" at least for me.

If this works with the update-ref plumbing, we should do so instead of adding REFFILES prerequisite.

[Footnote]
 * Allowing more flexibility to the plumbing is OK, but those
   scripting around plumbing commands should get the same support as
   those writing built-in and making internal calls to functions
   like branch_checked_out(), in order for them to be able to write
   their Porcelain and offer the same safety to their users.  The
   function certainly should be exposed to plumbing users, and
   possibly many other internal-only features.
   The trend in the past ten or so years has been "Porcelain first"
   and then "Porcelain only", which sadly made the composability of
   Git plumbing commands much less useful than pre-made Porcelain
   commands.
Previous: Ævar Arnfjörð BjarmasonNext: SZEDER Gábor
Message 5 of 20 in “rebase --update-refs: smooth out some rough edges”
  1. 0/6 rebase --update-refs: smooth out some rough edgesSZEDER Gábor, Sep 30, 2022
  2. 1/6 t2407-worktree-heads.sh: remove outdated loopSZEDER Gábor, Sep 30, 2022
  3. 2/6 t3404-rebase-interactive: mark a test with REFFILES prereqSZEDER Gábor, Sep 30, 2022
  4. Ævar Arnfjörð BjarmasonSep 30, 2022
  5. Junio C HamanoOct 5, 2022
  6. 4/6 sequencer: avoid empty lines after 'update-ref' instructionsSZEDER Gábor, Sep 30, 2022
  7. Derrick StoleeSep 30, 2022
  8. Junio C HamanoOct 5, 2022
  9. 3/6 rebase -i: emphasize that 'update-ref' expects a fully-qualified refSZEDER Gábor, Sep 30, 2022
  10. 5/6 sequencer: duplicate the result of resolve_ref_unsafe()SZEDER Gábor, Sep 30, 2022
  11. Ævar Arnfjörð BjarmasonSep 30, 2022
  12. Ævar Arnfjörð BjarmasonSep 30, 2022
  13. Derrick StoleeSep 30, 2022
  14. SZEDER GáborOct 9, 2022
  15. 6/6 sequencer: fail early if invalid ref is given to 'update-ref' instructionSZEDER Gábor, Sep 30, 2022
  16. Ævar Arnfjörð BjarmasonSep 30, 2022
  17. Derrick StoleeSep 30, 2022
  18. SZEDER GáborOct 1, 2022
  19. Junio C HamanoOct 1, 2022
  20. Junio C HamanoOct 5, 2022

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.