From: "Jérémie Detrey" <Jeremie.Detrey@altu.fr>
To: git@vger.kernel.org
Cc: Shulhan <m.shulhan@gmail.com>,
"Brandon Williams" <bwilliams.eng@gmail.com>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Junio C Hamano" <gitster@pobox.com>,
"Jérémie Detrey" <Jeremie.Detrey@altu.fr>
Subject: [PATCH] git-remote: load config whenever create_symref() might be called
Date: Sat, 26 Dec 2020 14:44:20 +0100 [thread overview]
Message-ID: <20201226134420.722643-1-Jeremie.Detrey@altu.fr> (raw)
Currently, the calls to `create_symref()` do not honor the
`core.logAllRefUpdates` nor the `user.{name,email}` configuration
settings, and therefore write reflogs even when explicitly asked not
to, and ignore the configured user identity.
This happens on `git remote add --fetch`, `git remote set-head`, and
`git remote rename`: these are the three commands which may create
a symbolic-ref for the remote's HEAD.
A call to `git_config(git_default_config, NULL);` for these three
commands is enough to load the necessary configuration beforehand.
The call to `git_config()` was inserted right after command-line
processing for these three commands. One might also decide to push
it closer to the actual call to `create_symref()`, as it is not
needed elsewhere, but it made more sense not to have it buried into
nested `if` conditions.
Signed-off-by: Jérémie Detrey <Jeremie.Detrey@altu.fr>
---
builtin/remote.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/builtin/remote.c b/builtin/remote.c
index 64b4b551eb..f797fc3f65 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -190,6 +190,8 @@ static int add(int argc, const char **argv)
name = argv[0];
url = argv[1];
+ git_config(git_default_config, NULL);
+
remote = remote_get(name);
if (remote_is_configured(remote, 1))
die(_("remote %s already exists."), name);
@@ -685,6 +687,8 @@ static int mv(int argc, const char **argv)
rename.new_name = argv[2];
rename.remote_branches = &remote_branches;
+ git_config(git_default_config, NULL);
+
oldremote = remote_get(rename.old_name);
if (!remote_is_configured(oldremote, 1))
die(_("No such remote: '%s'"), rename.old_name);
@@ -1326,6 +1330,8 @@ static int set_head(int argc, const char **argv)
if (argc)
strbuf_addf(&buf, "refs/remotes/%s/HEAD", argv[0]);
+ git_config(git_default_config, NULL);
+
if (!opt_a && !opt_d && argc == 2) {
head_name = xstrdup(argv[1]);
} else if (opt_a && !opt_d && argc == 1) {
--
2.29.2
next reply other threads:[~2020-12-26 13:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-26 13:44 Jérémie Detrey [this message]
2020-12-26 21:52 ` [PATCH] git-remote: load config whenever create_symref() might be called Junio C Hamano
2020-12-26 22:28 ` Jérémie Detrey
2020-12-27 0:34 ` Eric Sunshine
2020-12-27 6:22 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201226134420.722643-1-Jeremie.Detrey@altu.fr \
--to=jeremie.detrey@altu.fr \
--cc=Johannes.Schindelin@gmx.de \
--cc=bwilliams.eng@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=m.shulhan@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox