All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Santi Béjar" <sbejar@gmail.com>
To: Git Mailing List <git@vger.kernel.org>, Paolo Bonzini <bonzini@gnu.org>
Cc: "Junio C. Hamano" <junkio@cox.net>
Subject: [PATCH 2/3] git-fetch: Support the local remote "."
Date: Tue, 13 Mar 2007 17:28:24 +0100	[thread overview]
Message-ID: <87bqixf6qf.fsf@gmail.com> (raw)


To this end, git-parse-remote is grown with a new kind of remote,
`builtin'. This returns all the local branches in
get_remote_default_refs_for_fetch. This is equivalent to having a
fake remote as:

[remote "local"]
url = .
fetch = refs/*

Based on a patch from Paolo Bonzini.

Signed-off-by: Santi Béjar <sbejar@gmail.com>
---
 Documentation/config.txt     |    4 ++++
 git-parse-remote.sh          |   12 +++++++++++-
 t/t5515-fetch-merge-logic.sh |    2 ++
 t/t5515/fetch.br-.           |    6 ++++++
 t/t5515/fetch.br-.-merge     |    6 ++++++
 t/t5515/fetch.br-.-merge_.   |    6 ++++++
 t/t5515/fetch.br-.-octopus   |    6 ++++++
 t/t5515/fetch.br-.-octopus_. |    6 ++++++
 t/t5515/fetch.br-._.         |    6 ++++++
 t/t5515/fetch.br-unconfig_.  |    5 +++++
 t/t5515/fetch.master_.       |    5 +++++
 t/t5520-pull.sh              |   13 +++++++++++++
 12 files changed, 76 insertions(+), 1 deletions(-)
 create mode 100644 t/t5515/fetch.br-.
 create mode 100644 t/t5515/fetch.br-.-merge
 create mode 100644 t/t5515/fetch.br-.-merge_.
 create mode 100644 t/t5515/fetch.br-.-octopus
 create mode 100644 t/t5515/fetch.br-.-octopus_.
 create mode 100644 t/t5515/fetch.br-._.

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 5408dd6..28899d9 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -272,6 +272,10 @@ branch.<name>.merge::
 	`git fetch`) to lookup the default branch for merging. Without
 	this option, `git pull` defaults to merge the first refspec fetched.
 	Specify multiple values to get an octopus merge.
+	If you wish to setup `git pull` so that it merges into <name> from
+	another branch in the local repository, you can point
+	branch.<name>.merge to the desired branch, and use the special setting
+	`.` (a period) for branch.<name>.remote.
 
 color.branch::
 	A boolean to enable/disable color in the output of
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 99e7184..84c2c89 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -9,6 +9,9 @@ get_data_source () {
 	*/*)
 		echo ''
 		;;
+	.)
+		echo builtin
+		;;
 	*)
 		if test "$(git-config --get "remote.$1.url")"
 		then
@@ -31,6 +34,9 @@ get_remote_url () {
 	'')
 		echo "$1"
 		;;
+	builtin)
+		echo "$1"
+		;;
 	config)
 		git-config --get "remote.$1.url"
 		;;
@@ -57,7 +63,7 @@ get_default_remote () {
 get_remote_default_refs_for_push () {
 	data_source=$(get_data_source "$1")
 	case "$data_source" in
-	'' | branches)
+	'' | branches | builtin)
 		;; # no default push mapping, just send matching refs.
 	config)
 		git-config --get-all "remote.$1.push" ;;
@@ -128,6 +134,10 @@ get_remote_default_refs_for_fetch () {
 	case "$data_source" in
 	'')
 		set explicit "HEAD:" ;;
+	builtin)
+		set glob $(for name in $(git-show-ref |
+			sed -n 's,.*[      ]refs/,refs/,p')
+		    do echo "$name:" ; done);;
 	config)
 		set $(expand_refs_wildcard "$1" \
 			$(git-config --get-all "remote.$1.fetch")) ;;
diff --git a/t/t5515-fetch-merge-logic.sh b/t/t5515-fetch-merge-logic.sh
index 9759959..e840fe0 100755
--- a/t/t5515-fetch-merge-logic.sh
+++ b/t/t5515-fetch-merge-logic.sh
@@ -78,6 +78,8 @@ test_expect_success setup '
 	echo "../.git#one" > .git/branches/branches-one &&
 	remotes="$remotes branches-one" &&
 
+	remotes="$remotes ." &&
+
 	for remote in $remotes ; do
 		git config branch.br-$remote.remote $remote &&
 		git config branch.br-$remote-merge.remote $remote &&
diff --git a/t/t5515/fetch.br-. b/t/t5515/fetch.br-.
new file mode 100644
index 0000000..8878a73
--- /dev/null
+++ b/t/t5515/fetch.br-.
@@ -0,0 +1,6 @@
+# br-.
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/HEAD' of .
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f	not-for-merge	remote branch 'origin/master' of .
+8e32a6d901327a23ef831511badce7bf3bf46689	not-for-merge	remote branch 'origin/one' of .
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/three' of .
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8	not-for-merge	remote branch 'origin/two' of .
diff --git a/t/t5515/fetch.br-.-merge b/t/t5515/fetch.br-.-merge
new file mode 100644
index 0000000..b851578
--- /dev/null
+++ b/t/t5515/fetch.br-.-merge
@@ -0,0 +1,6 @@
+# br-.-merge
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/HEAD' of .
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f	not-for-merge	remote branch 'origin/master' of .
+8e32a6d901327a23ef831511badce7bf3bf46689	not-for-merge	remote branch 'origin/one' of .
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/three' of .
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8	not-for-merge	remote branch 'origin/two' of .
diff --git a/t/t5515/fetch.br-.-merge_. b/t/t5515/fetch.br-.-merge_.
new file mode 100644
index 0000000..2484570
--- /dev/null
+++ b/t/t5515/fetch.br-.-merge_.
@@ -0,0 +1,6 @@
+# br-.-merge .
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/HEAD' of .
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f	not-for-merge	remote branch 'origin/master' of .
+8e32a6d901327a23ef831511badce7bf3bf46689	not-for-merge	remote branch 'origin/one' of .
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/three' of .
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8	not-for-merge	remote branch 'origin/two' of .
diff --git a/t/t5515/fetch.br-.-octopus b/t/t5515/fetch.br-.-octopus
new file mode 100644
index 0000000..3f440b1
--- /dev/null
+++ b/t/t5515/fetch.br-.-octopus
@@ -0,0 +1,6 @@
+# br-.-octopus
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/HEAD' of .
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f	not-for-merge	remote branch 'origin/master' of .
+8e32a6d901327a23ef831511badce7bf3bf46689	not-for-merge	remote branch 'origin/one' of .
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/three' of .
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8	not-for-merge	remote branch 'origin/two' of .
diff --git a/t/t5515/fetch.br-.-octopus_. b/t/t5515/fetch.br-.-octopus_.
new file mode 100644
index 0000000..938e9ed
--- /dev/null
+++ b/t/t5515/fetch.br-.-octopus_.
@@ -0,0 +1,6 @@
+# br-.-octopus .
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/HEAD' of .
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f	not-for-merge	remote branch 'origin/master' of .
+8e32a6d901327a23ef831511badce7bf3bf46689	not-for-merge	remote branch 'origin/one' of .
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/three' of .
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8	not-for-merge	remote branch 'origin/two' of .
diff --git a/t/t5515/fetch.br-._. b/t/t5515/fetch.br-._.
new file mode 100644
index 0000000..9d43858
--- /dev/null
+++ b/t/t5515/fetch.br-._.
@@ -0,0 +1,6 @@
+# br-. .
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/HEAD' of .
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f	not-for-merge	remote branch 'origin/master' of .
+8e32a6d901327a23ef831511badce7bf3bf46689	not-for-merge	remote branch 'origin/one' of .
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/three' of .
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8	not-for-merge	remote branch 'origin/two' of .
diff --git a/t/t5515/fetch.br-unconfig_. b/t/t5515/fetch.br-unconfig_.
index 73c937d..455a0ce 100644
--- a/t/t5515/fetch.br-unconfig_.
+++ b/t/t5515/fetch.br-unconfig_.
@@ -1 +1,6 @@
 # br-unconfig .
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/HEAD' of .
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f	not-for-merge	remote branch 'origin/master' of .
+8e32a6d901327a23ef831511badce7bf3bf46689	not-for-merge	remote branch 'origin/one' of .
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/three' of .
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8	not-for-merge	remote branch 'origin/two' of .
diff --git a/t/t5515/fetch.master_. b/t/t5515/fetch.master_.
index ad16cdc..967d057 100644
--- a/t/t5515/fetch.master_.
+++ b/t/t5515/fetch.master_.
@@ -1 +1,6 @@
 # master .
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/HEAD' of .
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f	not-for-merge	remote branch 'origin/master' of .
+8e32a6d901327a23ef831511badce7bf3bf46689	not-for-merge	remote branch 'origin/one' of .
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b	not-for-merge	remote branch 'origin/three' of .
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8	not-for-merge	remote branch 'origin/two' of .
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 7eb3783..c424e5b 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -29,5 +29,18 @@ test_expect_success 'checking the results' '
 	diff file cloned/file
 '
 
+test_expect_success 'test . as a remote' '
+
+	git branch copy master &&
+	git config branch.copy.remote . &&
+	git config branch.copy.merge refs/heads/master &&
+	echo updated >file &&
+	git commit -a -m updated &&
+	git checkout copy &&
+	test `cat file` = file &&
+	git pull &&
+	test `cat file` = updated
+'
+
 test_done
 
-- 
1.5.0.3.1021.g5897

             reply	other threads:[~2007-03-13 16:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-13 16:28 Santi Béjar [this message]
2007-03-13 16:53 ` [PATCH 2/3] git-fetch: Support the local remote "." Paolo Bonzini
2007-03-13 23:01   ` Santi Béjar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bqixf6qf.fsf@gmail.com \
    --to=sbejar@gmail.com \
    --cc=bonzini@gnu.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.