Skip to contentSkip to conversation

suggestion: store the URL somewhere in .git/

PATCH Jeff Carr 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore

Jeff Carr

author
#0 lore raw

It would be nice if the URL could be stored somewhere in .git/ This makes it a lot easier to update repositories because you don't always have to go and track down where you got it in the first place. Something like this perhaps:

~$ cat .git/location rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git/ ~$ git-pull-script

Then something like below could be added to handle that easy enough.

Jeff

git-pull-script renamed from git-pull-script.orig +13 -2
@@ -4,13 +4,24 @@
 # cogito.]
 #
 
+LOCATION="$@"
+
+if [ ! $LOCATION ]
+then
+	if [ -f .git/location ]
+	then
+		LOCATION=`cat .git/location`
+	fi
+fi
+
 . git-sh-setup-script || die "Not a git archive"
-. git-parse-remote "$@"
+. git-parse-remote "$LOCATION"
 merge_name="$_remote_name"
 
-git-fetch-script "$@" || exit 1
+git-fetch-script "$LOCATION" || exit 1
 
 git-resolve-script \
 	"$(cat "$GIT_DIR"/HEAD)" \
 	"$(cat "$GIT_DIR"/FETCH_HEAD)" \
 	"Merge $merge_name"
+
#1 lore raw

Hi,

Quoted 3 lines · Jeff Carr

It would be nice if the URL could be stored somewhere in .git/ This makes it a lot easier to update repositories because you don't always have to go and track down where you got it in the first place.

This is why your original target (when you clone) is stored as "origin".

Hth,
Dscho

author
#2 lore raw
Quoted 11 lines · Johannes Schindelin

Hi,

Quoted 3 lines · Jeff Carr

It would be nice if the URL could be stored somewhere in .git/ This makes it a lot easier to update repositories because you don't always have to go and track down where you got it in the first place.

This is why your original target (when you clone) is stored as "origin".

OK. I rsync'ed the repository directly so a origin file wasn't created. That explains that. So my small "feature" request reduces to adding something like this to git-pull-script. Thanks, Jeff

git-pull-script +12 -2
@@ -1,10 +1,20 @@
 #!/bin/sh
 #
+ORIGIN="$@"
+
+if [ ! $ORIGIN ]
+then
+	if [ -f .git/branches/origin ]
+	then
+		ORIGIN=`cat .git/branches/origin`
+	fi
+fi
+
 . git-sh-setup-script || die "Not a git archive"
-. git-parse-remote "$@"
+. git-parse-remote "$ORIGIN"
 merge_name="$_remote_name"
 
-git-fetch-script "$@" || exit 1
+git-fetch-script "$ORIGIN" || exit 1
 
 git-resolve-script \
 	"$(cat "$GIT_DIR"/HEAD)" \
#3 lore raw
Quoted 2 lines · Jeff Carr

So my small "feature" request reduces to adding something like this to git-pull-script. Thanks, Jeff

Somebody else earlier asked for fetch and pull to default to "origin" URL, and the necessary change is already in the proposed updates branch.