fetch: only opportunistically update references based on command line
commit0281c930f17042473e973f39810c8f7c93955d7d
authorMichael Haggerty <mhagger@alum.mit.edu>
Wed, 30 Oct 2013 05:32:58 +0000 (30 06:32 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 Oct 2013 21:16:35 +0000 (30 14:16 -0700)
tree39adeeb0b048065ff28aaa73f51f12411dffdc04
parente31a17f7416a85ee8c3260f8c8b7519ff7ea82b6
fetch: only opportunistically update references based on command line

The old code processed (tags == TAGS_SET) before adding the entries
used to opportunistically update references mentioned on the command
line.  The result was that all tags were also considered candidates
for opportunistic updating.

This is harmless for two reasons: (a) because it would only add
entries if there is a configured refspec that covers tags *and* both
--tags and another refspec appear on the command-line; (b) because any
extra entries would be deleted later by the call to
ref_remove_duplicates() anyway.

But, to avoid extra work and extra memory usage, and to make the
implementation better match the intention, change the algorithm
slightly: compute the opportunistic refspecs based only on the
command-line arguments, storing the results into a separate temporary
list.  Then add the tags (which have to come earlier in the list so
that they are not de-duped in favor of an opportunistic entry).  Then
concatenate the temporary list onto the main list.

This change will also make later changes easier.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c