summaryrefslogtreecommitdiff
path: root/git-parse-remote.sh
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-09-28 05:23:12 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-09-28 05:23:12 (GMT)
commit2958d9b5dbebeb82e7230bbfd3f421781d90f3f7 (patch)
tree881c16a7442a1829d8959aee272f50065c53b582 /git-parse-remote.sh
parent194db7e3bbab9669c511133549e6ae74481c9a4f (diff)
parent51b2dd4e3f730f6be6c19faf3b4a04caea9e0420 (diff)
downloadgit-2958d9b5dbebeb82e7230bbfd3f421781d90f3f7.zip
git-2958d9b5dbebeb82e7230bbfd3f421781d90f3f7.tar.gz
git-2958d9b5dbebeb82e7230bbfd3f421781d90f3f7.tar.bz2
Merge branch 'master' into lj/refs
* master: (72 commits) runstatus: do not recurse into subdirectories if not needed grep: fix --fixed-strings combined with expression. grep: free expressions and patterns when done. Corrected copy-and-paste thinko in ignore executable bit test case. An illustration of rev-list --parents --pretty=raw Allow git-checkout when on a non-existant branch. gitweb: Decode long title for link tooltips git-svn: Fix fetch --no-ignore-externals with GIT_SVN_NO_LIB=1 Ignore executable bit when adding files if filemode=0. Remove empty ref directories that prevent creating a ref. Use const for interpolate arguments git-archive: update documentation Deprecate merge-recursive.py gitweb: fix over-eager application of esc_html(). Allow '(no author)' in git-svn's authors file. Allow 'svn fetch' on '(no date)' revisions in Subversion. git-repack: allow git-repack to run in subdirectory Remove upload-tar and make git-tar-tree a thin wrapper to git-archive git-tar-tree: Move code for git-archive --format=tar to archive-tar.c git-tar-tree: Remove duplicate git_config() call ...
Diffstat (limited to 'git-parse-remote.sh')
-rwxr-xr-xgit-parse-remote.sh43
1 files changed, 35 insertions, 8 deletions
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 187f088..c325ef7 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -68,6 +68,12 @@ get_remote_url () {
esac
}
+get_default_remote () {
+ curr_branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')
+ origin=$(git-repo-config --get "branch.$curr_branch.remote")
+ echo ${origin:-origin}
+}
+
get_remote_default_refs_for_push () {
data_source=$(get_data_source "$1")
case "$data_source" in
@@ -86,9 +92,22 @@ 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
+ # If called from get_remote_default_refs_for_fetch
+ # leave the branches in branch.${curr_branch}.merge alone,
+ # or the first one otherwise; add prefix . to the rest
# to prevent the secondary branches to be merged by default.
- dot_prefix=
+ merge_branches=
+ if test "$1" = "-d"
+ then
+ shift ; remote="$1" ; shift
+ if test "$remote" = "$(get_default_remote)"
+ then
+ curr_branch=$(git-symbolic-ref HEAD | \
+ sed -e 's|^refs/heads/||')
+ merge_branches=$(git-repo-config \
+ --get-all "branch.${curr_branch}.merge")
+ fi
+ fi
for ref
do
force=
@@ -101,6 +120,18 @@ 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=.
+ if test -z "$merge_branches"
+ then
+ merge_branches=$remote
+ dot_prefix=
+ else
+ for merge_branch in $merge_branches
+ do
+ [ "$remote" = "$merge_branch" ] &&
+ dot_prefix= && break
+ done
+ fi
case "$remote" in
'') remote=HEAD ;;
refs/heads/* | refs/tags/* | refs/remotes/*) ;;
@@ -120,7 +151,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
}
@@ -131,7 +161,7 @@ get_remote_default_refs_for_fetch () {
'' | config-partial | branches-partial)
echo "HEAD:" ;;
config)
- canon_refs_list_for_fetch \
+ canon_refs_list_for_fetch -d "$1" \
$(git-repo-config --get-all "remote.$1.fetch") ;;
branches)
remote_branch=$(sed -ne '/#/s/.*#//p' "$GIT_DIR/branches/$1")
@@ -139,10 +169,7 @@ get_remote_default_refs_for_fetch () {
echo "refs/heads/${remote_branch}:refs/heads/$1"
;;
remotes)
- # This prefixes the second and later default refspecs
- # with a '.', to signal git-fetch to mark them
- # not-for-merge.
- canon_refs_list_for_fetch $(sed -ne '/^Pull: */{
+ canon_refs_list_for_fetch -d "$1" $(sed -ne '/^Pull: */{
s///p
}' "$GIT_DIR/remotes/$1")
;;