git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fetch: get the remote branches to merge from the branch properties.
@ 2006-09-22 23:41 Santi Béjar
  2006-09-23  0:45 ` Junio C Hamano
  2006-09-23  0:47 ` Santi
  0 siblings, 2 replies; 4+ messages in thread
From: Santi Béjar @ 2006-09-22 23:41 UTC (permalink / raw)
  To: git

If in branch "foo" and this in config:

[branch "foo"]
       merge=bar

"git fetch": fetch from the default repository and program the "bar"
             branch to be merged with pull.

Signed-off-by: Santi Béjar <sbejar@gmail.com>
---
 Documentation/config.txt |    4 ++++
 git-parse-remote.sh      |   13 ++++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index fa20e28..b4de243 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -122,6 +122,10 @@ apply.whitespace::
 branch.<name>.remote::
        When in branch <name>, it tells `git pull` which remote to fetch.

+branch.<name>.merge::
+       When in branch <name>, it tells `git fetch` the remote branch to be
+       merged.
+
 pager.color::
        A boolean to enable/disable colored output when the pager is in
        use (default is true).
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 187f088..0b14606 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -86,9 +86,12 @@ get_remote_default_refs_for_push () {
 
 # Subroutine to canonicalize remote:local notation.
 canon_refs_list_for_fetch () {
-	# Leave only the first one alone; add prefix . to the rest
+	# Leave the branches in branch.${curr_branch}.merge alone,
+	# or the first one; add prefix . to the rest
 	# to prevent the secondary branches to be merged by default.
-	dot_prefix=
+	curr_branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')
+	merge_branches=$(git-repo-config --get-all "branch.${curr_branch}.merge")
+	[ -z "$merge_branches" ] && merge_branches=$1
 	for ref
 	do
 		force=
@@ -101,6 +104,11 @@ canon_refs_list_for_fetch () {
 		expr "z$ref" : 'z.*:' >/dev/null || ref="${ref}:"
 		remote=$(expr "z$ref" : 'z\([^:]*\):')
 		local=$(expr "z$ref" : 'z[^:]*:\(.*\)')
+		dot_prefix=.
+		for merge_branch in $merge_branches
+		do
+		    [ "$remote" = "$merge_branch" ] && dot_prefix= && break
+		done
 		case "$remote" in
 		'') remote=HEAD ;;
 		refs/heads/* | refs/tags/* | refs/remotes/*) ;;
@@ -120,7 +128,6 @@ canon_refs_list_for_fetch () {
 		   die "* refusing to create funny ref '$local_ref_name' locally"
 		fi
 		echo "${dot_prefix}${force}${remote}:${local}"
-		dot_prefix=.
 	done
 }
 
-- 
1.4.2.1.g4b5cd

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-09-23  0:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-22 23:41 [PATCH] Fetch: get the remote branches to merge from the branch properties Santi Béjar
2006-09-23  0:45 ` Junio C Hamano
2006-09-23  0:53   ` Santi
2006-09-23  0:47 ` Santi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).