[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#69780] [PATCH 1/4] git authenticate: Record introduction and keyrin
From: |
Ludovic Courtès |
Subject: |
[bug#69780] [PATCH 1/4] git authenticate: Record introduction and keyring in ‘.git/config’. |
Date: |
Tue, 19 Mar 2024 14:32:47 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hi Tomas!
Tomas Volf <~@wolfsden.cz> skribis:
>> +(define* (record-configuration repository
>> + #:key commit signer keyring-reference)
>> + "Record COMMIT, SIGNER, and KEYRING-REFERENCE in the 'config' file of
>> +REPOSITORY."
>> + (define directory
>> + (repository-directory repository))
>> +
>> + (define config-file
>> + (in-vicinity directory "config"))
>
> I do not think this will work with worktrees. It will create the config file
> in
> the worktree's git directory, but that file will be ignored by git.
>
> scheme@(guile-user)> (repository-discover "/home/xx/src/guix-wt/patch-1")
> $7 = "/home/xx/src/guix/.git/worktrees/orig/"
> scheme@(guile-user)> (repository-open $7)
> $8 = #<git-repository 128cbe0>
> scheme@(guile-user)> (repository-directory $8)
> $9 = "/home/xx/src/guix/.git/worktrees/orig/"
> scheme@(guile-user)> (in-vicinity $9 "config")
> $10 = "/home/xx/src/guix/.git/worktrees/orig/config"
>
> The $10 should be "/home/xx/src/guix/.git/config" instead.
Damn it. So hmm, I can see two options:
1. Add more bindings to (git config) in Guile-Git so we can populate
that file “the right way”. But then we’ll have to require that
newer version of Guile-Git.
2. Bail out when the ‘.git/config’ isn’t found, as in the case of
worktrees; we can change that to use the proper (git config)
eventually.
Maybe we should go straight to #1 though. Thoughts?
>> + (call-with-port (open-file config-file "a")
>> + (lambda (port)
>> + (format port "
>> +# Added by 'guix git authenticate'.
>> +[guix \"authentication\"]
>> + introduction-commit = ~a
>> + introduction-signer = ~a
>> + keyring = ~a~%"
>> + commit signer keyring-reference)))
>
> I guess these specific values might not need any escaping? But the escaping
> (and the previous problem) would be solved by just shelling out to the `git
> config --local ...' to set the value. Something to consider.
No escaping is needed in this case. Things will be even clearer if/when
we switch to (git config).
>> + (unless (configured? repository)
>> + (record-configuration repository
>> + #:commit commit #:signer signer
>> + #:keyring-reference keyring))
>
> Hm, so this records the information only on the very first successful
> authentication?
Right.
> So if I re-run with different values (e.g. I am creating a new channel
> and `git commit --amend'-ed after checking the authorization), I am
> stuck with the (now) invalid values forever until I edit the
> .git/config by hand?
You mean if you change the introduction? Yes.
> Also (as Skyler Ferris already mentioned) this ignores the case of multiple
> branches with different authentication origins (I actually do have such use
> case), so the suggested option of storing it per-branch might be nice. Not
> sure
> how to deal with pruning of old values though (if at all?).
Oh right. Needs some thought.
Thanks for your feedback!
Ludo’.
[bug#69780] [PATCH 4/4] DRAFT news: Add entry for ‘guix git authenticate’ changes., Ludovic Courtès, 2024/03/13