clone: better error when --reference is a linked checkout
[gitweb.git] / transport.c
index 025439435629ad45c48840112a6ba672ffc39655..2d51348f3f3a5be03b2d00ec6530ac4cabfbf7c6 100644 (file)
@@ -291,7 +291,7 @@ static int write_one_ref(const char *name, const struct object_id *oid,
 
        strbuf_addstr(buf, name);
        if (safe_create_leading_directories(buf->buf) ||
-           write_file_gently(buf->buf, "%s\n", oid_to_hex(oid)))
+           write_file_gently(buf->buf, "%s", oid_to_hex(oid)))
                return error("problems writing temporary file %s: %s",
                             buf->buf, strerror(errno));
        strbuf_setlen(buf, len);
@@ -476,9 +476,6 @@ static int set_git_option(struct git_transport_options *opts,
                                die("transport: invalid depth option '%s'", value);
                }
                return 0;
-       } else if (!strcmp(name, TRANS_OPT_PUSH_CERT)) {
-               opts->push_cert = !!value;
-               return 0;
        }
        return 1;
 }
@@ -829,10 +826,16 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
        args.progress = transport->progress;
        args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
        args.porcelain = !!(flags & TRANSPORT_PUSH_PORCELAIN);
-       args.push_cert = !!(flags & TRANSPORT_PUSH_CERT);
        args.atomic = !!(flags & TRANSPORT_PUSH_ATOMIC);
        args.url = transport->url;
 
+       if (flags & TRANSPORT_PUSH_CERT_ALWAYS)
+               args.push_cert = SEND_PACK_PUSH_CERT_ALWAYS;
+       else if (flags & TRANSPORT_PUSH_CERT_IF_ASKED)
+               args.push_cert = SEND_PACK_PUSH_CERT_IF_ASKED;
+       else
+               args.push_cert = SEND_PACK_PUSH_CERT_NEVER;
+
        ret = send_pack(&args, data->fd, data->conn, remote_refs,
                        &data->extra_have);