static void report_missing(const struct object *obj)
 {
        char missing_hex[41];
-       strcpy(missing_hex, sha1_to_hex(obj->sha1));;
+       strcpy(missing_hex, sha1_to_hex(obj->sha1));
        fprintf(stderr, "Cannot obtain needed %s %s\n",
                obj->type ? typename(obj->type): "object", missing_hex);
        if (!is_null_sha1(current_commit_sha1))
        free(tree->buffer);
        tree->buffer = NULL;
        tree->size = 0;
+       tree->object.parsed = 0;
        return 0;
 }
 
 {
        if (!get_sha1_hex(target, sha1))
                return 0;
-       if (!check_ref_format(target)) {
-               if (!walker->fetch_ref(walker, target, sha1)) {
+       if (!check_refname_format(target, 0)) {
+               struct ref *ref = alloc_ref(target);
+               if (!walker->fetch_ref(walker, ref)) {
+                       hashcpy(sha1, ref->old_sha1);
+                       free(ref);
                        return 0;
                }
+               free(ref);
        }
        return -1;
 }
        struct commit *commit = lookup_commit_reference_gently(sha1, 1);
        if (commit) {
                commit->object.flags |= COMPLETE;
-               insert_by_date(commit, &complete);
+               commit_list_insert_by_date(commit, &complete);
        }
        return 0;
 }
 int walker_targets_stdin(char ***target, const char ***write_ref)
 {
        int targets = 0, targets_alloc = 0;
-       struct strbuf buf;
+       struct strbuf buf = STRBUF_INIT;
        *target = NULL; *write_ref = NULL;
-       strbuf_init(&buf, 0);
        while (1) {
                char *rf_one = NULL;
                char *tg_one;
 {
        while (targets--) {
                free(target[targets]);
-               if (write_ref && write_ref[targets])
+               if (write_ref)
                        free((char *) write_ref[targets]);
        }
 }
        int i;
 
        save_commit_buffer = 0;
-       track_object_refs = 0;
 
        for (i = 0; i < targets; i++) {
                if (!write_ref || !write_ref[i])
 
        for (i = 0; i < targets; i++) {
                if (interpret_target(walker, target[i], &sha1[20 * i])) {
-                       error("Could not interpret %s as something to pull", target[i]);
+                       error("Could not interpret response from server '%s' as something to pull", target[i]);
                        goto unlock_and_fail;
                }
                if (process(walker, lookup_unknown_object(&sha1[20 * i])))