Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/gitPublic

Commitf170e4b

Browse files
Junio C HamanoLinus Torvalds
Junio C Hamano
authored and
Linus Torvalds
committed
[PATCH] fetch/pull: short-hand notation for remote repositories.
Since pull and fetch are done often against the same remoterepository repeatedly, keeping the URL to pull from along withthe name of the head to use in $GIT_DIR/branches/$name makes alot of sense. Adopt that convention from Cogito, and try to becompatible when possible; storing a partial URL and completingit with a trailing path may not be understood by Cogito.While we are at it, fix pulling a tag. Earlier, we updated onlyrefs/tags/$tag without updating FETCH_HEAD, and calledresolve-script using a stale (or absent) FETCH_HEAD.Signed-off-by: Junio C Hamano <junkio@cox.net>Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent02d57da commitf170e4b

File tree

4 files changed

+104
-32
lines changed

4 files changed

+104
-32
lines changed

‎Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ SCRIPTS=git git-apply-patch-script git-merge-one-file-script git-prune-script \
3636
git-reset-script git-add-script git-checkout-script git-clone-script\
3737
gitk git-cherry git-rebase-script git-relink-script git-repack-script\
3838
git-format-patch-script git-sh-setup-script git-push-script\
39-
git-branch-script
39+
git-branch-script git-parse-remote
4040

4141
PROG= git-update-cache git-diff-files git-init-db git-write-tree\
4242
git-read-tree git-commit-tree git-cat-file git-fsck-cache\

‎git-fetch-script

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
#!/bin/sh
22
#
3-
destination=FETCH_HEAD
4-
5-
merge_repo=$1
6-
merge_name=${2:-HEAD}
7-
if ["$2"="tag" ];then
8-
merge_name="refs/tags/$3"
9-
destination="$merge_name"
10-
fi
11-
123
. git-sh-setup-script|| die"Not a git archive"
4+
. git-parse-remote"$@"
5+
merge_repo="$_remote_repo"
6+
merge_head="$_remote_head"
7+
merge_store="$_remote_store"
138

149
TMP_HEAD="$GIT_DIR/TMP_HEAD"
1510

1611
case"$merge_repo"in
1712
http://*)
18-
head=$(wget -q -O -"$merge_repo/$merge_name")||exit 1
19-
echo Fetching$head using http
20-
git-http-pull -v -a"$head""$merge_repo/"
13+
head=$(wget -q -O -"$merge_repo/$merge_head")||exit 1
14+
echo Fetching"$merge_head" using http
15+
git-http-pull -v -a"$merge_head""$merge_repo/"
2116
;;
2217
rsync://*)
23-
rsync -L"$merge_repo/$merge_name""$TMP_HEAD"||exit 1
18+
rsync -L"$merge_repo/$merge_head""$TMP_HEAD"||exit 1
2419
head=$(git-rev-parse TMP_HEAD)
2520
rm -f"$TMP_HEAD"
2621
rsync -avz --ignore-existing"$merge_repo/objects/""$GIT_OBJECT_DIRECTORY/"
2722
;;
2823
*)
29-
head=$(git-fetch-pack"$merge_repo""$merge_name")
24+
head=$(git-fetch-pack"$merge_repo""$merge_head")
3025
;;
3126
esac||exit 1
27+
3228
git-rev-parse --verify"$head"> /dev/null||exit 1
33-
echo"$head">"$GIT_DIR/$destination"
29+
30+
case"$merge_store"in
31+
'')
32+
echo"$head">"$GIT_DIR/$merge_store"
33+
esac&&
34+
35+
# FETCH_HEAD is fed to git-resolve-script which will eventually be
36+
# passed to git-commit-tree as one of the parents. Make sure we do
37+
# not give a tag object ID.
38+
39+
git-rev-parse"$head^0">"$GIT_DIR/FETCH_HEAD"

‎git-parse-remote

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
: To be included in git-pull and git-fetch scripts.
2+
3+
# A remote repository can be specified on the command line
4+
# in one of the following formats:
5+
#
6+
#<repo>
7+
#<repo> <head>
8+
#<repo> tag <tag>
9+
#
10+
# where <repo> could be one of:
11+
#
12+
#a URL (including absolute or local pathname)
13+
#a short-hand
14+
#a short-hand followed by a trailing path
15+
#
16+
# A short-hand <name> has a corresponding file $GIT_DIR/branches/<name>,
17+
# whose contents is a URL, possibly followed by a URL fragment #<head>
18+
# to name the default branch on the remote side to fetch from.
19+
20+
_remote_repo= _remote_store= _remote_head= _remote_name=
21+
22+
case "$1" in
23+
*:* | /* | ../* | ./* )
24+
_remote_repo="$1"
25+
;;
26+
* )
27+
# otherwise, it is a short hand.
28+
case "$1" in
29+
*/*)
30+
# a short-hand followed by a trailing path
31+
_token=$(expr "$1" : '\([^/]*\)/')
32+
_rest=$(expr "$1" : '[^/]*\(/.*\)$')
33+
;;
34+
*)
35+
_token="$1"
36+
_rest=
37+
_remote_store="refs/heads/$_token"
38+
;;
39+
esac
40+
test -f "$GIT_DIR/branches/$_token" ||
41+
die "No such remote branch: $_token"
42+
43+
_remote_repo=$(cat "$GIT_DIR/branches/$_token")"$_rest"
44+
;;
45+
esac
46+
47+
case "$_remote_repo" in
48+
*"#"*)
49+
_remote_head=`expr "$_remote_repo" : '.*#\(.*\)$'`
50+
_remote_repo=`expr "$_remote_repo" : '\(.*\)#'`
51+
;;
52+
esac
53+
54+
_remote_name=$(echo "$_remote_repo" | sed 's|\.git/*$||')
55+
56+
case "$2" in
57+
tag)
58+
_remote_name="tag '$3' of $_remote_name"
59+
_remote_head="refs/tags/$3"
60+
_remote_store="$_remote_head"
61+
;;
62+
?*)
63+
# command line specified a head explicitly; do not
64+
# store the fetched head as a branch head.
65+
_remote_name="head '$2' of $_remote_name"
66+
_remote_head="refs/heads/$2"
67+
_remote_store=''
68+
;;
69+
'')
70+
case "$_remote_head" in
71+
'')
72+
_remote_head=HEAD ;;
73+
*)
74+
_remote_head="refs/heads/$_remote_head"
75+
_remote_name="head '$_remote_head' of $_remote_name"
76+
;;
77+
esac
78+
;;
79+
esac

‎git-pull-script

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
#!/bin/sh
22
#
33
. git-sh-setup-script|| die"Not a git archive"
4+
. git-parse-remote"$@"
5+
merge_name="$_remote_name"
46

5-
merge_repo=$1
6-
7-
merge_name=$(echo"$1"| sed's:\.git/*$::')
8-
merge_head=HEAD
9-
type=head
10-
if ["$2"="tag" ];then
11-
type=tag
12-
shift
13-
fi
14-
if ["$2" ]
15-
then
16-
merge_name="$type '$2' of$merge_name"
17-
merge_head="refs/${type}s/$2"
18-
fi
19-
20-
git-fetch-script"$merge_repo""$merge_head"||exit 1
7+
git-fetch-script"$@"||exit 1
218

229
git-resolve-script \
2310
"$(cat"$GIT_DIR"/HEAD)" \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp