After importing new commits on top of refs/remotes/* the
ref was overwritten with the local refs/heads/master, because the name
of the remote reference to fetch, i.e. refs/heads/master, was used to
retrieve old_sha1 for it's local counterpart. Therefore, old_sha1 pointed
to the local head which was not contained in the remote branch and couldn't
be updated (printing a warning ..).

There are some points that are still not completely clear to me:
- I found, that the remote ref I need is stored in ref->peer_ref. There
  is one little comment on peer_ref saying /* when renaming */. That doesn't 
say much
  to me. Is peer_ref the correct solution?
- fast-import's commit command does already add a commit to a branch. The
  remote ref was already correct, but got overwritten by store_updated_refs
  after fast import terminated. (I figured that out using strace).
  So the update is somewhat redundant. But probably only in this special 

Signed-off-by: Florian Achleitner <>
 transport-helper.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/transport-helper.c b/transport-helper.c
index d6daad5..a0f05ce 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -485,8 +485,10 @@ static int fetch_with_import(struct transport *transport,
                if (data->refspecs)
                        private = apply_refspecs(data->refspecs, 
data->refspec_nr, posn->name);
+               else if (posn->peer_ref)
+                       private = xstrdup(posn->peer_ref->name);
-                       private = xstrdup(posn->name);
+                       private = NULL;
                if (private) {
                        read_ref(private, posn->old_sha1);

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to