git-fetch: follow tag only when tracking remote branch.
Unless --no-tags flag was given, git-fetch tried to always follow remote tags that point at the commits we picked up. It is not very useful to pick up tags from remote unless storing the fetched branch head in a local tracking branch. This is especially true if the fetch is done to merge the remote branch into our current branch as one-shot basis (i.e. "please pull"), and is even harmful if the remote repository has many irrelevant tags. This proposed update disables the automated tag following unless we are storing the a fetched branch head in a local tracking branch. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Feb 22, 2006 at 13:10 UTC
6dc78e696b8597204b903073da932fc5ed0f419e
1 file changed
+19
-14
git-fetch.sh
+19
-14
@@ -368,20 +368,25 @@ fetch_main "$reflist"
368
# automated tag following
369
case "$no_tags$tags" in
370
'')
371
- taglist=$(IFS=" " &&
372
- git-ls-remote $upload_pack --tags "$remote" |
373
- sed -ne 's|^\([0-9a-f]*\)[ ]\(refs/tags/.*\)^{}$|\1 \2|p' |
374
- while read sha1 name
375
- do
376
- test -f "$GIT_DIR/$name" && continue
377
- git-check-ref-format "$name" || {
378
- echo >&2 "warning: tag ${name} ignored"
379
- continue
380
- }
381
- git-cat-file -t "$sha1" >/dev/null 2>&1 || continue
382
- echo >&2 "Auto-following $name"
383
- echo ".${name}:${name}"
384
- done)
371
+ case "$reflist" in
372
+ *:refs/*)
373
+ # effective only when we are following remote branch
374
+ # using local tracking branch.
375
+ taglist=$(IFS=" " &&
376
+ git-ls-remote $upload_pack --tags "$remote" |
377
+ sed -ne 's|^\([0-9a-f]*\)[ ]\(refs/tags/.*\)^{}$|\1 \2|p' |
378
+ while read sha1 name
379
+ do
380
+ test -f "$GIT_DIR/$name" && continue
381
+ git-check-ref-format "$name" || {
382
+ echo >&2 "warning: tag ${name} ignored"
383
+ continue
384
+ }
385
+ git-cat-file -t "$sha1" >/dev/null 2>&1 || continue
386
+ echo >&2 "Auto-following $name"
387
+ echo ".${name}:${name}"
388
+ done)
389
+ esac
390
case "$taglist" in
391
'') ;;
392
?*)