[PATCH 1/2] remote: add camel-cased *.tagOpt key, like clone

Subsystems: the rest

STALE1996d

3 messages, 2 authors, 2021-03-18 · open the first message on its own page

[PATCH 1/2] remote: add camel-cased *.tagOpt key, like clone

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-02-25 01:22:15

Change "git remote add" so that it adds a *.tagOpt key, and not the
lower-cased *.tagopt on "git remote add --no-tags", just as "git clone
--no-tags" would do.

This doesn't matter for anything that reads the config. It's just
prettier if we write config keys in their documented camelCase form to
user-readable config files.

When I added support for "clone -no-tags" in 0dab2468ee5 (clone: add a
--no-tags option to clone without tags, 2017-04-26) I made it use
the *.tagOpt form, but the older "git remote add" added in
111fb858654 (remote add: add a --[no-]tags option, 2010-04-20) has
been using *.tagopt all this time.

It's easy enough to add a test for this, so let's do that. We can't
use "git config -l" there, because it'll normalize the keys to their
lower-cased form. Let's add the test for "git clone" too for good
measure, not just to the "git remote" codepath we're fixing.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---

I also noticed that we write e.g. init.objectformat instead of
init.objectFormat, and core.logallrefupdates etc. If anyone's got an
even even worse case of OCD there's an interesting #leftoverbits
project there of scouring the code for more cases of this sort of
thing...

 builtin/remote.c         | 2 +-
 t/t5505-remote.sh        | 1 +
 t/t5612-clone-refspec.sh | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/builtin/remote.c b/builtin/remote.c
index d11a5589e49..f286ae97538 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -221,7 +221,7 @@ static int add(int argc, const char **argv)
 
 	if (fetch_tags != TAGS_DEFAULT) {
 		strbuf_reset(&buf);
-		strbuf_addf(&buf, "remote.%s.tagopt", name);
+		strbuf_addf(&buf, "remote.%s.tagOpt", name);
 		git_config_set(buf.buf,
 			       fetch_tags == TAGS_SET ? "--tags" : "--no-tags");
 	}
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 045398b94e6..2a7b5cd00a0 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -594,6 +594,7 @@ test_expect_success 'add --no-tags' '
 		cd add-no-tags &&
 		git init &&
 		git remote add -f --no-tags origin ../one &&
+		grep tagOpt .git/config &&
 		git tag -l some-tag >../test/output &&
 		git tag -l foobar-tag >../test/output &&
 		git config remote.origin.tagopt >>../test/output
diff --git a/t/t5612-clone-refspec.sh b/t/t5612-clone-refspec.sh
index 6a6af7449ca..3126cfd7e9d 100755
--- a/t/t5612-clone-refspec.sh
+++ b/t/t5612-clone-refspec.sh
@@ -97,6 +97,7 @@ test_expect_success 'by default no tags will be kept updated' '
 test_expect_success 'clone with --no-tags' '
 	(
 		cd dir_all_no_tags &&
+		grep tagOpt .git/config &&
 		git fetch &&
 		git for-each-ref refs/tags >../actual
 	) &&
-- 
2.30.0.284.gd98b1dd5eaa7

[PATCH 2/2] remote: write camel-cased *.pushRemote on rename

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-02-25 01:22:17

When a remote is renamed don't change the canonical "*.pushRemote"
form to "*.pushremote". Fixes and tests for a minor bug in
923d4a5ca4f (remote rename/remove: handle branch.<name>.pushRemote
config values, 2020-01-27). See the preceding commit for why this does
& doesn't matter.

While we're at it let's also test that we handle the "*.pushDefault"
key correctly. The code to handle that was added in
b3fd6cbf294 (remote rename/remove: gently handle remote.pushDefault
config, 2020-02-01) and does the right thing, but nothing tested that
we wrote out the canonical camel-cased form.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
 builtin/remote.c  | 2 +-
 t/t5505-remote.sh | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/builtin/remote.c b/builtin/remote.c
index f286ae97538..717b662d455 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -746,7 +746,7 @@ static int mv(int argc, const char **argv)
 		}
 		if (info->push_remote_name && !strcmp(info->push_remote_name, rename.old_name)) {
 			strbuf_reset(&buf);
-			strbuf_addf(&buf, "branch.%s.pushremote", item->string);
+			strbuf_addf(&buf, "branch.%s.pushRemote", item->string);
 			git_config_set(buf.buf, rename.new_name);
 		}
 	}
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 2a7b5cd00a0..34fc3fa421f 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -757,6 +757,7 @@ test_expect_success 'rename a remote' '
 		cd four &&
 		git config branch.main.pushRemote origin &&
 		git remote rename origin upstream &&
+		grep "pushRemote" .git/config &&
 		test -z "$(git for-each-ref refs/remotes/origin)" &&
 		test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/main" &&
 		test "$(git rev-parse upstream/main)" = "$(git rev-parse main)" &&
@@ -773,6 +774,7 @@ test_expect_success 'rename a remote renames repo remote.pushDefault' '
 		cd four.1 &&
 		git config remote.pushDefault origin &&
 		git remote rename origin upstream &&
+		grep pushDefault .git/config &&
 		test "$(git config --local remote.pushDefault)" = "upstream"
 	)
 '
-- 
2.30.0.284.gd98b1dd5eaa7

Re: [PATCH 2/2] remote: write camel-cased *.pushRemote on rename

From: Bert Wesarg <hidden>
Date: 2021-03-18 11:23:45

On Thu, Feb 25, 2021 at 2:21 AM Ævar Arnfjörð Bjarmason
[off-list ref] wrote:
When a remote is renamed don't change the canonical "*.pushRemote"
form to "*.pushremote". Fixes and tests for a minor bug in
923d4a5ca4f (remote rename/remove: handle branch.<name>.pushRemote
config values, 2020-01-27). See the preceding commit for why this does
& doesn't matter.

While we're at it let's also test that we handle the "*.pushDefault"
key correctly. The code to handle that was added in
b3fd6cbf294 (remote rename/remove: gently handle remote.pushDefault
config, 2020-02-01) and does the right thing, but nothing tested that
we wrote out the canonical camel-cased form.
Fine with me.

Thanks.
quoted hunk
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
 builtin/remote.c  | 2 +-
 t/t5505-remote.sh | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/builtin/remote.c b/builtin/remote.c
index f286ae97538..717b662d455 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -746,7 +746,7 @@ static int mv(int argc, const char **argv)
                }
                if (info->push_remote_name && !strcmp(info->push_remote_name, rename.old_name)) {
                        strbuf_reset(&buf);
-                       strbuf_addf(&buf, "branch.%s.pushremote", item->string);
+                       strbuf_addf(&buf, "branch.%s.pushRemote", item->string);
                        git_config_set(buf.buf, rename.new_name);
                }
        }
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 2a7b5cd00a0..34fc3fa421f 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -757,6 +757,7 @@ test_expect_success 'rename a remote' '
                cd four &&
                git config branch.main.pushRemote origin &&
                git remote rename origin upstream &&
+               grep "pushRemote" .git/config &&
                test -z "$(git for-each-ref refs/remotes/origin)" &&
                test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/main" &&
                test "$(git rev-parse upstream/main)" = "$(git rev-parse main)" &&
@@ -773,6 +774,7 @@ test_expect_success 'rename a remote renames repo remote.pushDefault' '
                cd four.1 &&
                git config remote.pushDefault origin &&
                git remote rename origin upstream &&
+               grep pushDefault .git/config &&
                test "$(git config --local remote.pushDefault)" = "upstream"
        )
 '
--
2.30.0.284.gd98b1dd5eaa7
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help