get_sha1(): fix error status regression
[gitweb.git] / transport-helper.c
index 07131261fefeab2066636a7f83bce05796329a54..6f227e253bf638de37ce74347213657c23185afa 100644 (file)
@@ -446,8 +446,10 @@ static int fetch_with_import(struct transport *transport,
                        private = apply_refspecs(data->refspecs, data->refspec_nr, posn->name);
                else
                        private = xstrdup(posn->name);
-               read_ref(private, posn->old_sha1);
-               free(private);
+               if (private) {
+                       read_ref(private, posn->old_sha1);
+                       free(private);
+               }
        }
        strbuf_release(&buf);
        return 0;