Re: git fetch --tags doesn't quite do what I expect
- From
Junio C Hamano <junkio@cox.net>
- Date
- Nov 18, 2005, 20:06 UTC
- Message-ID
- <7v1x1diuuy.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <12c511ca0511181114jf4ca3c0p195a128fa541b8f2@mail.gmail.com>
Tony Luck <tony.luck@gmail.com> writes:
> Is this intended behaivour? If so, the "--tags" entry on the > git-fetch(1) man page needs a little extra text to say that > --tags limits the fetch to only commits reachable from the > tags.
I think both Linus (who did the initial implementation of "git fetch --tags") and I are in "tags do not matter until you care" camp, and the expected usage pattern is that you frequently do "git fetch" or "git pull", but "git fetch --tags" is done only every once in a while, just to give you known anchors to compare against or specify a known bottom for log, whatchanged and friends. The branch heads are necessary for your day to day work, the tags are less essential. That is what I mean by "tags do not matter until you care".
A tag usually points at somewhere in the commit chain leading to branch heads [*1*], and if your branch heads are up to date, "git fetch --tags" does not download anything other than the tags themselves, finds the commits they point at are already available and complete, and stops there.
Now it happens that "git fetch --tags" slurps commits you do not yet have _if_ your branch heads are behind, because git barebone Porcelain is designed to keep your object database complete (i.e. it does not just fetch and store tags under refs/tags/ without making sure you have everything they connect to). What you saw that is a side effect of the above design assumption.
I am not good at documenting things, so I'd appreciate if somebody paraphrased the above and send it back to me in a patch form to update the document ;-).
[Footnote]
*1* This is not necessarily true; tags can point at anything, and indeed v1.0rc3 tag point at another tag and junio-gpg-tag points at a freestanding blob. Even a tag pointing at a commit, as Daniel suggested in
<Pine.LNX.4.64.0511041745480.25300@iabervon.org>
I could do the "pu" branch as a tag without exposing the actual branch. Then that tag would point at a chain of commits not connected to any branch head.