[PATCH] git fetch --tags
You can do git fetch --tags <linus-kernel-repo> and it should fetch all my tags automatically. [jc: The original by Linus fetched and overwrote branch heads with --all, which felt dangerous and wrong, so I removed it. Also this version does not use any refs that resulted as --tags for later merge. ] Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Linus Torvalds committed
Sep 29, 2005 at 14:35 UTC
ed1aadf1b0cb4afc7cb0aaf4cec4f5ad84e3307d
1 file changed
+24
-1
git-fetch.sh
+24
-1
@@ -5,6 +5,7 @@
5
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
6
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
7
8
+tags=
9
append=
10
force=
11
update_head_ok=
@@ -17,6 +18,9 @@ do
18
-f|--f|--fo|--for|--forc|--force)
19
force=t
20
;;
21
+ -t|--t|--ta|--tag|--tags)
22
+ tags=t
23
+ ;;
24
-u|--u|--up|--upd|--upda|--updat|--update|--update-|--update-h|\
25
--update-he|--update-hea|--update-head|--update-head-|\
26
--update-head-o|--update-head-ok)
@@ -158,7 +162,26 @@ case "$update_head_ok" in
162
;;
163
esac
164
161
-for ref in $(get_remote_refs_for_fetch "$@")
165
+# If --tags (and later --heads or --all) is specified, then we are
166
+# not talking about defaults stored in Pull: line of remotes or
167
+# branches file, and just fetch those and refspecs explicitly given.
168
+# Otherwise we do what we always did.
169
+
170
+reflist=$(get_remote_refs_for_fetch "$@")
171
+if test "$tags"
172
+then
173
+ taglist=$(git-ls-remote --tags "$remote" | awk '{ print "."$2":"$2 }')
174
+ if test "$#" -gt 1
175
+ then
176
+ # remote URL plus explicit refspecs; we need to merge them.
177
+ reflist="$reflist $taglist"
178
+ else
179
+ # No explicit refspecs; fetch tags only.
180
+ reflist=$taglist
181
+ fi
182
+fi
183
+
184
+for ref in $reflist
185
do
186
refs="$refs $ref"
187