Merge branch 'ef/mingw-write'
authorJunio C Hamano <gitster@pobox.com>
Mon, 27 Jan 2014 18:44:59 +0000 (10:44 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Jan 2014 18:44:59 +0000 (10:44 -0800)
* ef/mingw-write:
mingw: remove mingw_write
prefer xwrite instead of write

1  2 
builtin/merge.c
streaming.c
transport-helper.c
diff --combined builtin/merge.c
index 4941a6c36ab215fdb709ac58a3aea69218025dbb,a6a38ee5baccebcd2c818ae9014a6da35ce60f1a..e576a7fdc619303a65e859920a1ab6936db2626c
@@@ -367,7 -367,7 +367,7 @@@ static void squash_message(struct commi
                        sha1_to_hex(commit->object.sha1));
                pretty_print_commit(&ctx, commit, &out);
        }
-       if (write(fd, out.buf, out.len) < 0)
+       if (write_in_full(fd, out.buf, out.len) != out.len)
                die_errno(_("Writing SQUASH_MSG"));
        if (close(fd))
                die_errno(_("Finishing SQUASH_MSG"));
@@@ -446,17 -446,17 +446,17 @@@ static void merge_name(const char *remo
                die(_("'%s' does not point to a commit"), remote);
  
        if (dwim_ref(remote, strlen(remote), branch_head, &found_ref) > 0) {
 -              if (!prefixcmp(found_ref, "refs/heads/")) {
 +              if (starts_with(found_ref, "refs/heads/")) {
                        strbuf_addf(msg, "%s\t\tbranch '%s' of .\n",
                                    sha1_to_hex(branch_head), remote);
                        goto cleanup;
                }
 -              if (!prefixcmp(found_ref, "refs/tags/")) {
 +              if (starts_with(found_ref, "refs/tags/")) {
                        strbuf_addf(msg, "%s\t\ttag '%s' of .\n",
                                    sha1_to_hex(branch_head), remote);
                        goto cleanup;
                }
 -              if (!prefixcmp(found_ref, "refs/remotes/")) {
 +              if (starts_with(found_ref, "refs/remotes/")) {
                        strbuf_addf(msg, "%s\t\tremote-tracking branch '%s' of .\n",
                                    sha1_to_hex(branch_head), remote);
                        goto cleanup;
@@@ -570,8 -570,8 +570,8 @@@ static int git_merge_config(const char 
  {
        int status;
  
 -      if (branch && !prefixcmp(k, "branch.") &&
 -              !prefixcmp(k + 7, branch) &&
 +      if (branch && starts_with(k, "branch.") &&
 +              starts_with(k + 7, branch) &&
                !strcmp(k + 7 + strlen(branch), ".mergeoptions")) {
                free(branch_mergeoptions);
                branch_mergeoptions = xstrdup(v);
@@@ -1106,7 -1106,7 +1106,7 @@@ int cmd_merge(int argc, const char **ar
         * current branch.
         */
        branch = branch_to_free = resolve_refdup("HEAD", head_sha1, 0, &flag);
 -      if (branch && !prefixcmp(branch, "refs/heads/"))
 +      if (branch && starts_with(branch, "refs/heads/"))
                branch += 11;
        if (!branch || is_null_sha1(head_sha1))
                head_commit = NULL;
diff --combined streaming.c
index 9659f18be263a3412a2f3e5d13eb4f4bcd25cee3,e3d697b88e8cc1449348c02b742af48306a71b2a..d7c9f32f0ce98112ddd4d4a8499b227b181e09e6
@@@ -113,7 -113,7 +113,7 @@@ static enum input_source istream_source
  
        oi->typep = type;
        oi->sizep = &size;
 -      status = sha1_object_info_extended(sha1, oi);
 +      status = sha1_object_info_extended(sha1, oi, 0);
        if (status < 0)
                return stream_error;
  
@@@ -538,7 -538,7 +538,7 @@@ int stream_blob_to_fd(int fd, unsigned 
                        goto close_and_exit;
        }
        if (kept && (lseek(fd, kept - 1, SEEK_CUR) == (off_t) -1 ||
-                    write(fd, "", 1) != 1))
+                    xwrite(fd, "", 1) != 1))
                goto close_and_exit;
        result = 0;
  
diff --combined transport-helper.c
index 087f617d39d79be946bdd60c05890eda28c9675c,ea34b39a818cc8995aec17f0a92500ed2560d005..ad72fbd53cb7bfc7fc037d98288b0cc831ea949a
@@@ -190,7 -190,7 +190,7 @@@ static struct child_process *get_helper
                        data->export = 1;
                else if (!strcmp(capname, "check-connectivity"))
                        data->check_connectivity = 1;
 -              else if (!data->refspecs && !prefixcmp(capname, "refspec ")) {
 +              else if (!data->refspecs && starts_with(capname, "refspec ")) {
                        ALLOC_GROW(refspecs,
                                   refspec_nr + 1,
                                   refspec_alloc);
                        data->connect = 1;
                } else if (!strcmp(capname, "signed-tags")) {
                        data->signed_tags = 1;
 -              } else if (!prefixcmp(capname, "export-marks ")) {
 +              } else if (starts_with(capname, "export-marks ")) {
                        struct strbuf arg = STRBUF_INIT;
                        strbuf_addstr(&arg, "--export-marks=");
                        strbuf_addstr(&arg, capname + strlen("export-marks "));
                        data->export_marks = strbuf_detach(&arg, NULL);
 -              } else if (!prefixcmp(capname, "import-marks")) {
 +              } else if (starts_with(capname, "import-marks")) {
                        struct strbuf arg = STRBUF_INIT;
                        strbuf_addstr(&arg, "--import-marks=");
                        strbuf_addstr(&arg, capname + strlen("import-marks "));
                        data->import_marks = strbuf_detach(&arg, NULL);
 -              } else if (!prefixcmp(capname, "no-private-update")) {
 +              } else if (starts_with(capname, "no-private-update")) {
                        data->no_private_update = 1;
                } else if (mandatory) {
                        die("Unknown mandatory capability %s. This remote "
@@@ -311,7 -311,7 +311,7 @@@ static int set_helper_option(struct tra
  
        if (!strcmp(buf.buf, "ok"))
                ret = 0;
 -      else if (!prefixcmp(buf.buf, "error")) {
 +      else if (starts_with(buf.buf, "error")) {
                ret = -1;
        } else if (!strcmp(buf.buf, "unsupported"))
                ret = 1;
@@@ -360,12 -360,6 +360,12 @@@ static int fetch_with_fetch(struct tran
            data->transport_options.check_self_contained_and_connected)
                set_helper_option(transport, "check-connectivity", "true");
  
 +      if (transport->cloning)
 +              set_helper_option(transport, "cloning", "true");
 +
 +      if (data->transport_options.update_shallow)
 +              set_helper_option(transport, "update-shallow", "true");
 +
        for (i = 0; i < nr_heads; i++) {
                const struct ref *posn = to_fetch[i];
                if (posn->status & REF_STATUS_UPTODATE)
        while (1) {
                recvline(data, &buf);
  
 -              if (!prefixcmp(buf.buf, "lock ")) {
 +              if (starts_with(buf.buf, "lock ")) {
                        const char *name = buf.buf + 5;
                        if (transport->pack_lockfile)
                                warning("%s also locked %s", data->name, name);
@@@ -652,10 -646,10 +652,10 @@@ static int push_update_ref_status(struc
        char *refname, *msg;
        int status;
  
 -      if (!prefixcmp(buf->buf, "ok ")) {
 +      if (starts_with(buf->buf, "ok ")) {
                status = REF_STATUS_OK;
                refname = buf->buf + 3;
 -      } else if (!prefixcmp(buf->buf, "error ")) {
 +      } else if (starts_with(buf->buf, "error ")) {
                status = REF_STATUS_REMOTE_REJECT;
                refname = buf->buf + 6;
        } else
@@@ -1135,9 -1129,8 +1135,8 @@@ static int udt_do_write(struct unidirec
                return 0;       /* Nothing to write. */
  
        transfer_debug("%s is writable", t->dest_name);
-       bytes = write(t->dest, t->buf, t->bufuse);
-       if (bytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN &&
-               errno != EINTR) {
+       bytes = xwrite(t->dest, t->buf, t->bufuse);
+       if (bytes < 0 && errno != EWOULDBLOCK) {
                error("write(%s) failed: %s", t->dest_name, strerror(errno));
                return -1;
        } else if (bytes > 0) {