aboutsummaryrefslogtreecommitdiffstats
path: root/git-fetch.sh
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2005-09-29 14:35:15 -0700
committerJunio C Hamano <junkio@cox.net>2005-10-01 23:18:38 -0700
commited1aadf1b0cb4afc7cb0aaf4cec4f5ad84e3307d (patch)
tree0070a92e774fb78aaa589a26f04b74df68c124aa /git-fetch.sh
parent4fa2197e614950279527b14825d1e9572454a48c (diff)
downloadgit-ed1aadf1b0cb4afc7cb0aaf4cec4f5ad84e3307d.tar.gz
[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>
Diffstat (limited to 'git-fetch.sh')
-rwxr-xr-xgit-fetch.sh25
1 files changed, 24 insertions, 1 deletions
diff --git a/git-fetch.sh b/git-fetch.sh
index 27407c1d35..61da6a9e31 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -5,6 +5,7 @@
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+tags=
append=
force=
update_head_ok=
@@ -17,6 +18,9 @@ do
-f|--f|--fo|--for|--forc|--force)
force=t
;;
+ -t|--t|--ta|--tag|--tags)
+ tags=t
+ ;;
-u|--u|--up|--upd|--upda|--updat|--update|--update-|--update-h|\
--update-he|--update-hea|--update-head|--update-head-|\
--update-head-o|--update-head-ok)
@@ -158,7 +162,26 @@ case "$update_head_ok" in
;;
esac
-for ref in $(get_remote_refs_for_fetch "$@")
+# If --tags (and later --heads or --all) is specified, then we are
+# not talking about defaults stored in Pull: line of remotes or
+# branches file, and just fetch those and refspecs explicitly given.
+# Otherwise we do what we always did.
+
+reflist=$(get_remote_refs_for_fetch "$@")
+if test "$tags"
+then
+ taglist=$(git-ls-remote --tags "$remote" | awk '{ print "."$2":"$2 }')
+ if test "$#" -gt 1
+ then
+ # remote URL plus explicit refspecs; we need to merge them.
+ reflist="$reflist $taglist"
+ else
+ # No explicit refspecs; fetch tags only.
+ reflist=$taglist
+ fi
+fi
+
+for ref in $reflist
do
refs="$refs $ref"