Skip to content

Commit 5fca669

Browse files
author
Linus Torvalds
committed
Make "git fetch" able to fetch a named tag
Use "git fetch <repo> tag <tagname>" to get the named tag and everything it points to.
1 parent 170774a commit 5fca669

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

git-fetch-script

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
#!/bin/sh
22
#
3+
destination=FETCH_HEAD
4+
35
merge_repo=$1
46
merge_name=${2:-HEAD}
7+
if [ "$2" = "tag" ]; then
8+
merge_name="refs/tags/$3"
9+
destination="$merge_name"
10+
fi
511

612
: ${GIT_DIR=.git}
713
: ${GIT_OBJECT_DIRECTORY="${SHA1_FILE_DIRECTORY-"$GIT_DIR/objects"}"}
@@ -35,7 +41,7 @@ download_objects () {
3541
}
3642

3743
echo "Getting remote $merge_name"
38-
download_one "$merge_repo/$merge_name" "$GIT_DIR"/FETCH_HEAD || exit 1
44+
download_one "$merge_repo/$merge_name" "$GIT_DIR/$destination" || exit 1
3945

4046
echo "Getting object database"
41-
download_objects "$merge_repo" "$(cat "$GIT_DIR"/FETCH_HEAD)" || exit 1
47+
download_objects "$merge_repo" "$(cat "$GIT_DIR/$destination")" || exit 1

0 commit comments

Comments
 (0)