fetch: opportunistically update tracking refs
commitf269048754f3b835f4f7287c5a132714a059efce
authorJeff King <peff@peff.net>
Sat, 11 May 2013 16:16:52 +0000 (11 18:16 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 12 May 2013 22:23:48 +0000 (12 15:23 -0700)
tree12b7debaf9d79eae12a9aedb44762a7484508b33
parent900f2814b8da951a450f5762dabb1b248dd77abc
fetch: opportunistically update tracking refs

When we run a regular "git fetch" without arguments, we
update the tracking refs according to the configured
refspec. However, when we run "git fetch origin master" (or
"git pull origin master"), we do not look at the configured
refspecs at all, and just update FETCH_HEAD.

We miss an opportunity to update "refs/remotes/origin/master"
(or whatever the user has configured). Some users find this
confusing, because they would want to do further comparisons
against the old state of the remote master, like:

  $ git pull origin master
  $ git log HEAD...origin/master

In the currnet code, they are comparing against whatever
commit happened to be in origin/master from the last time
they did a complete "git fetch".  This patch will update a
ref from the RHS of a configured refspec whenever we happen
to be fetching its LHS. That makes the case above work.

The downside is that any users who really care about whether
and when their tracking branches are updated may be
surprised.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/pull-fetch-param.txt
builtin/fetch.c
t/t5510-fetch.sh