Skip to contentSkip to conversation

git-remote and remotes with '.' in their names

PATCH Paul Collins 4 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

I just switched my remotes over to the git-remote way (which is very nice!) and was looking for a way to list all of the known remotes. git-remote with no arguments almost does it, but I get the following:

  [briny(linux-2.6)] git --version
  git version 1.5.0.1
  [briny(linux-2.6)] cat .git/config
  [core]
          repositoryformatversion = 0
          filemode = true

[user]
email = "[email protected]"
[remote "origin"]
url = git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "wireless-dev"]
url = git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-dev.git
fetch = +refs/heads/*:refs/remotes/wireless-dev/*
[remote "stable-2.6.19"]

          url = git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-2.6.19.y.git
          fetch = +refs/heads/*:refs/remotes/stable-2.6.19/*
  [remote "stable-2.6.20"]
          url = git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-2.6.20.y.git
          fetch = +refs/heads/*:refs/remotes/stable-2.6.20/*

[remote "wireless-2.6"]
url = git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git
fetch = +refs/heads/*:refs/remotes/wireless-2.6/*
[briny(linux-2.6)] git-remote
origin
stable-2
wireless-2
wireless-dev

With this patch I get the correct list, but then it will break if there are ever config keys like "remote.$remote_name.foo.bar".

git-remote renamed from git-remote~ +1 -1
@@ -68,7 +68,7 @@
 		$git->command(qw(config --get-regexp), '^remote\.');
 	};
 	for (@remotes) {
-		if (/^remote\.([^.]*)\.(\S*)\s+(.*)$/) {
+		if (/^remote\.(.*)\.(\S*)\s+(.*)$/) {
 			add_remote_config(\%seen, $1, $2, $3);
 		}
 	}
Signature · 4 lines
Paul Collins
Wellington, New Zealand

Dag vijandelijk luchtschip de huismeester is dood
#1 lore raw

Hi,

Quoted 2 lines · Paul Collins

With this patch I get the correct list, but then it will break if there are ever config keys like "remote.$remote_name.foo.bar".

I think you do not need to worry. AFAIR variable names in the config must not contain dots, so the only way to set your example variable would be

[remote "$remote_name.foo"]
bar = blabla

Ciao,
Dscho

#2 lore raw
In reply to Paul Collins
Quoted 2 lines · Paul Collins

With this patch I get the correct list, but then it will break if there are ever config keys like "remote.$remote_name.foo.bar".

I don't think there would ever be key (variable) names with dots in them; if I remember correctly we don't allow this now.

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
#3 lore raw
In reply to Paul Collins

Hello,

git-remote line 71

Quoted 3 lines
git-remote renamed from git-remote~ +1 -1
 	for (@remotes) {
-		if (/^remote\.([^.]*)\.(\S*)\s+(.*)$/) {
+		if (/^remote\.(.*)\.(\S*)\s+(.*)$/) {

You probably want either

+ if (/^remote\.(\S*)\.(\S*)\s+(.*)$/) {

or

+ if (/^remote\.(\S*)\.([^.]*)\s+(.*)$/) {

here.

Paolo

#4 lore raw

Hi,

Review

Quoted 13 lines · Paolo Bonzini

Hello,

git-remote line 71

Quoted 3 lines
git-remote renamed from git-remote~ +1 -1
 	for (@remotes) {
-		if (/^remote\.([^.]*)\.(\S*)\s+(.*)$/) {
+		if (/^remote\.(.*)\.(\S*)\s+(.*)$/) {

You probably want either

(quoted diff) +1 -0
+		if (/^remote\.(\S*)\.(\S*)\s+(.*)$/) {

or

(quoted diff) +1 -0
+		if (/^remote\.(\S*)\.([^.]*)\s+(.*)$/) {

Did you mean to prevent the remote starting with a dot? IMHO that would be a good change, but AFAIS both your proposals don't do that.

Ciao,
Dscho

#5 lore raw
Quoted 11 lines · Johannes Schindelin

Hi,

Quoted 7 lines · Paolo Bonzini

Hello,

git-remote line 71

Quoted 3 lines
git-remote renamed from git-remote~ +1 -1
 	for (@remotes) {
-		if (/^remote\.([^.]*)\.(\S*)\s+(.*)$/) {
+		if (/^remote\.(.*)\.(\S*)\s+(.*)$/) {

You probably want either

Quoted 7 lines

Review

Quoted 5 lines
(quoted diff) +1 -0
+		if (/^remote\.(\S*)\.(\S*)\s+(.*)$/) {

or

(quoted diff) +1 -0
+		if (/^remote\.(\S*)\.([^.]*)\s+(.*)$/) {

Did you mean to prevent the remote starting with a dot? IMHO that would be a good change, but AFAIS both your proposals don't do that.

No, I meant to avoid the ".*" in Paul's proposal. They should be in practice equivalent but, with the second one, I made the regex more readable: it is clearer that the $3 variable is not meant to include dots.

Your proposal makes sense to me -- that would be

+ if (/^remote\.([^.]\S*)\.([^.]*)\s+(.*)$/) {

Paolo