git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob e3f6195281087c1d9937f160d8e81d1178a8083a 1326 bytes (raw)
name: git-parse-remote.sh 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
# This is a shell library to calculate the remote repository and
# upstream branch that should be pulled by "git pull" from the current
# branch.

get_default_remote () {
	curr_branch=$(git symbolic-ref -q HEAD)
	curr_branch="${curr_branch#refs/heads/}"
	origin=$(git config --get "branch.$curr_branch.remote")
	echo ${origin:-origin}
}

get_remote_merge_branch () {
	case "$#" in
	0|1)
	    origin="$1"
	    default=$(get_default_remote)
	    test -z "$origin" && origin=$default
	    curr_branch=$(git symbolic-ref -q HEAD) &&
	    [ "$origin" = "$default" ] &&
	    echo $(git for-each-ref --format='%(upstream)' $curr_branch)
	    ;;
	*)
	    repo=$1
	    shift
	    ref=$1
	    # FIXME: It should return the tracking branch
	    #        Currently only works with the default mapping
	    case "$ref" in
	    +*)
		ref=$(expr "z$ref" : 'z+\(.*\)')
		;;
	    esac
	    expr "z$ref" : 'z.*:' >/dev/null || ref="${ref}:"
	    remote=$(expr "z$ref" : 'z\([^:]*\):')
	    case "$remote" in
	    '' | HEAD ) remote=HEAD ;;
	    heads/*) remote=${remote#heads/} ;;
	    refs/heads/*) remote=${remote#refs/heads/} ;;
	    refs/* | tags/* | remotes/* ) remote=
	    esac
	    [ -n "$remote" ] && case "$repo" in
		.)
		    echo "refs/heads/$remote"
		    ;;
		*)
		    echo "refs/remotes/$repo/$remote"
		    ;;
	    esac
	esac
}

debug log:

solving e3f6195281 ...
found e3f6195281 in https://public-inbox.org/git/20201111151754.31527-3-avarab@gmail.com/
found 6b743cda17 in https://public-inbox.org/git/20201111151754.31527-2-avarab@gmail.com/
found d3c39980f3 in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100644 d3c39980f3fe2c346e4264d4b99a49acf7140301	git-parse-remote.sh

applying [1/2] https://public-inbox.org/git/20201111151754.31527-2-avarab@gmail.com/
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index d3c39980f3..6b743cda17 100644


applying [2/2] https://public-inbox.org/git/20201111151754.31527-3-avarab@gmail.com/
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 6b743cda17..e3f6195281 100644

Checking patch git-parse-remote.sh...
Applied patch git-parse-remote.sh cleanly.
Checking patch git-parse-remote.sh...
Applied patch git-parse-remote.sh cleanly.

index at:
100644 e3f6195281087c1d9937f160d8e81d1178a8083a	git-parse-remote.sh

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).