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

Subsystems: the rest

DORMANTno replies

4 messages, 3 authors, 2016-08-11 · open the first message on its own page

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

From: Andy Parkins <hidden>
Date: 2016-08-11 20:26:00

If .git/remotes/ is now deprecated, then git-clone shouldn't use it.
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 <redacted>
---
I'm not sure if I'm correct in thinking that .git/remotes is deprecated.  If it is,
this patch makes git-clone use .git/config instead.

Personally I like it, I think there should be as small a number of places for 
configuring the repository as possible.


 git-clone.sh |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/git-clone.sh b/git-clone.sh
index 9ed4135..1057a26 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.gb38c-dirty

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

From: Andy Parkins <hidden>
Date: 2016-08-11 19:17:07

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?

I'll fix it anyway.


Andy

-- 
Dr Andrew Parkins, M Eng (Hons), AMIEE

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

From: Johannes Schindelin <hidden>
Date: 2016-08-11 19:29:14

Hi,

On Sun, 26 Nov 2006, Andy Parkins wrote:
quoted hunk
-			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 &&
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.)

Ciao,
Dscho

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

From: Shawn Pearce <hidden>
Date: 2016-08-11 19:49:47

Andy Parkins [off-list ref] wrote:
If .git/remotes/ is now deprecated, then git-clone shouldn't use it.
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 <redacted>
---
I'm not sure if I'm correct in thinking that .git/remotes is deprecated.  If it is,
this patch makes git-clone use .git/config instead.

Personally I like it, I think there should be as small a number of places for 
configuring the repository as possible.
I agree.  There's all sorts of advantages to setting up remotes by
the config file.  Its also easier to load and work with in git-gui.
:-)

I've switched to the config file syntax completely, and a few folks
I work with have done the same, citing that it is easier to have
everything in one file.

-- 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help