Subject: Re: [bug#76407] [GCD] A better name for the default branch

From: Simon Tournier <[email-masked]>
Date: Fri, 07 Mar 2025 16:27:43 +0100

Hi Liliana,

On Fri, 21 Feb 2025 at 20:56, Liliana Marie Prikler <[email-masked]> wrote:

>> Therefore, maybe we could imagine that the last commit pushed master
>> introduce a double pull.
>> 
>> Assume I still run this 056910e and we are after the grace period.  I
>> run “guix pull” so it fetch the last commit of master.  Now, when I
>> run again “guix pull”, I will get the last commit of main.  This
>> second pull could be transparent for me.
>
> I don't think we should do this for two reasons:
>
> First, the "double pull" commit would be introduced to master only,
> which would break authentication of the main branch pulled this way.

At this end of the grace period, you have a direct path from the HEAD of
’main’ to the authenticated commit.  And you also have a direct path
from the HEAD of ’master’ to the authenticated commit.

Assuming, this commit with “double pull” lives only in ’master’ and
’master’ forks from ’main’ – fork because it holds the very commit.

I do not know the detail about switching from an authenticable branch to
another authenticable branch.  Because indeed, the HEAD of both branches
’main’ and ’master’ would not be in the same closure.

Hum, something I need to check for my understanding. :-)

> Second, we would have to break Guix itself to introduce arbitrary code
> execution for this particular code 😉

Why?  We only need to introduce a special case in
’update-cached-checkout’, no?

Somehow, we would have:

        * main
        | * master
        |/
        * End grace period

so we could have something like introduced in the ’master’ branch.

--8<---------------cut here---------------start------------->8---
1 file changed, 1 insertion(+), 1 deletion(-)
guix/git.scm | 2 +-

modified   guix/git.scm
@@ -653,7 +653,7 @@ (define* (update-cached-checkout url
                                                #:cleanup-period
                                                %checkout-cache-cleanup-period)))
 
-       (values cache-directory (oid->string oid) relation)))))
+       (update-cached-checkout ... #:ref `(branch . "main") ...)))))
 
 (define* (latest-repository-commit store url
                                    #:key
--8<---------------cut here---------------end--------------->8---

Well, modulo the former question about authentication. :-)

> Perhaps instead, we can on the Git side "redirect" the master branch to
> main.  This would avoid the double pull, and it would be truly
> transparent.  Perhaps the following sequence of commands would achieve
> just that.  (CC'ing Denis for their expertise)

Yeah, who can more can less. :-)

> Am Mittwoch, dem 19.02.2025 um 02:12 +0100 schrieb Denis 'GNUtoo'
> Carikli:
>> $ git checkout origin/master -b temporary
>> $ git push origin HEAD:main
>> $ ssh root@server
>> $ cd /path/to/repository.git
>> $ git symbolic-ref HEAD refs/heads/main # Change the main branch
>> $ git symbolic-ref refs/heads/master refs/heads/main # Make master
>> point to main
>
>> This might avoid: Oops why don’t I get the last?  Because you’re
>> after the grace period. :-)
>> 
>> I don’t know if my suggestion is worth.
>
> Fair point.  Double-pulling is a source of annoyance in other package
> managers, so we should do our best not to make it affect too many
> users.

Assuming we are allowed to do that on the server hosting the Git
repository.

Cheers,
simon