# [PATCH] Use new .git/config for storing "origin" shortcut repository

5 messages from 2006-11-26 to 2006-11-26. Participants: Andy Parkins, Jakub Narebski, Johannes Schindelin, Junio C Hamano.
Thread: https://gitlist.dev/t/43204

## Junio C Hamano, 2006-11-26 09:15

Subject: Re: [PATCH] Use new .git/config for storing "origin" shortcut repository
Message-ID: <7vvel2va9d.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vvel2va9d.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <200611260856.03057.andyparkins@gmail.com>

```
Andy Parkins <andyparkins@gmail.com> writes:

> On Sunday 2006, November 26 00:48, Johannes Schindelin wrote:
>
>> This hunk is wrong: "git-repo-config remote.bla.fetch b" will _overwrite_
>> remoter.bla.fetch. To avoid that, you have to use "git repo-config
>> remote.bla.fetch b ^$". (The last argument is a regular expression which
>> has to be matched by the value-to-be-oreplaced.)
>
> This is in git-clone; the config is empty.  What is there to overwrite?

The entry you wrote in the previous iteration in the same loop,
perhaps?

```

## Andy Parkins, 2006-11-26 09:35

Subject: [PATCH] Use new .git/config for storing "origin" shortcut repository
Message-ID: <200611260935.43762.andyparkins@gmail.com>
URL: https://gitlist.dev/e/200611260935.43762.andyparkins%40gmail.com
In-Reply-To: <7vvel2va9d.fsf@assigned-by-dhcp.cox.net>

```
Rather than use a separate config .git/remotes/ for remote shortcuts, this
patch adds the analogous definitions to .git/config using git-repo-config
calls.

For example what was previously .git/remotes/origin
  URL: proto://host/path
  Pull: refs/heads/master:refs/heads/origin
Is now added to .git/config as
  [remote "origin"]
  url = proto://host/path
  fetch = refs/heads/master:refs/heads/origin

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
Oops; you're absolutely right.  I'd not realised that it was the add operation
that needed the special syntax rather than the replace.

 git-clone.sh |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/git-clone.sh b/git-clone.sh
index 9ed4135..19a5a63 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -373,9 +373,8 @@ then
 		*)	origin_track="$remote_top/$origin"
 			git-update-ref "refs/heads/$origin" "$head_sha1" ;;
 		esac &&
-		echo >"$GIT_DIR/remotes/$origin" \
-		"URL: $repo
-Pull: refs/heads/$head_points_at:$origin_track" &&
+		git-repo-config remote."$origin".url "$repo" ^$ &&
+		git-repo-config remote."$origin".fetch "refs/heads/$head_points_at:$origin_track" ^$ &&
 		(cd "$GIT_DIR/$remote_top" && find . -type f -print) |
 		while read dotslref
 		do
@@ -389,8 +388,8 @@ Pull: refs/heads/$head_points_at:$origin_track" &&
 			then
 				continue
 			fi
-			echo "Pull: refs/heads/${name}:$remote_top/${name}"
-		done >>"$GIT_DIR/remotes/$origin" &&
+			git-repo-config remote."$origin".fetch "refs/heads/${name}:$remote_top/${name} ^$"
+		done &&
 		case "$use_separate_remote" in
 		t)
 			rm -f "refs/remotes/$origin/HEAD"
-- 
1.4.4.1.g9fd7

```

## Jakub Narebski, 2006-11-26 09:49

Subject: Re: [PATCH] Use new .git/config for storing "origin" shortcut repository
Message-ID: <ekbnr6$naq$2@sea.gmane.org>
URL: https://gitlist.dev/e/ekbnr6%24naq%242%40sea.gmane.org
In-Reply-To: <200611260935.43762.andyparkins@gmail.com>

```
Andy Parkins wrote:

> +               git-repo-config remote."$origin".url "$repo" ^$ &&

Is this needed? As of now git supports I think only one URL entry per remote
anyway...
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git


```

## Andy Parkins, 2006-11-26 12:10

Subject: [PATCH] Use new .git/config for storing "origin" shortcut repository
Message-ID: <200611261210.52154.andyparkins@gmail.com>
URL: https://gitlist.dev/e/200611261210.52154.andyparkins%40gmail.com
In-Reply-To: <ekbnr6$naq$2@sea.gmane.org>

```
Rather than use a separate config .git/remotes/ for remote shortcuts, this
patch adds the analagous definitions to .git/config using git-repo-config
calls.

For example what was previously .git/remotes/origin
  URL: proto://host/path
  Pull: refs/heads/master:refs/heads/origin
Is now added to .git/config as
  [remote "origin"]
  url = proto://host/path
  fetch = refs/heads/master:refs/heads/origin

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
You're absolutely correct; fixed.  This patch replaces the previous (again).

 git-clone.sh |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/git-clone.sh b/git-clone.sh
index 9ed4135..7e5dc0f 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -373,9 +373,8 @@ then
 		*)	origin_track="$remote_top/$origin"
 			git-update-ref "refs/heads/$origin" "$head_sha1" ;;
 		esac &&
-		echo >"$GIT_DIR/remotes/$origin" \
-		"URL: $repo
-Pull: refs/heads/$head_points_at:$origin_track" &&
+		git-repo-config remote."$origin".url "$repo" &&
+		git-repo-config remote."$origin".fetch "refs/heads/$head_points_at:$origin_track" ^$ &&
 		(cd "$GIT_DIR/$remote_top" && find . -type f -print) |
 		while read dotslref
 		do
@@ -389,8 +388,8 @@ Pull: refs/heads/$head_points_at:$origin_track" &&
 			then
 				continue
 			fi
-			echo "Pull: refs/heads/${name}:$remote_top/${name}"
-		done >>"$GIT_DIR/remotes/$origin" &&
+			git-repo-config remote."$origin".fetch "refs/heads/${name}:$remote_top/${name}" ^$
+		done &&
 		case "$use_separate_remote" in
 		t)
 			rm -f "refs/remotes/$origin/HEAD"
-- 
1.4.4.1.g9fd7

```

## Johannes Schindelin, 2006-11-26 13:30

Subject: Re: [PATCH] Use new .git/config for storing "origin" shortcut repository
Message-ID: <Pine.LNX.4.63.0611261429420.30004@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0611261429420.30004%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <200611261210.52154.andyparkins@gmail.com>

```
Hi,

On Sun, 26 Nov 2006, Andy Parkins wrote:

> -		echo >"$GIT_DIR/remotes/$origin" \
> -		"URL: $repo
> -Pull: refs/heads/$head_points_at:$origin_track" &&
> +		git-repo-config remote."$origin".url "$repo" &&
> +		git-repo-config remote."$origin".fetch "refs/heads/$head_points_at:$origin_track" ^$ &&

You do not need the "^$" here: this _is_ the first entry. I would even 
argue that this _has_ to replace whatever might be there (could be 
introduced by some bogus templates, for example), since the first fetch 
entry has a special meaning for pull.

Ciao,
Dscho

```
