Code

Merge branch 'master' into db/fetch-pack
[git.git] / builtin-fetch--tool.c
index 90bdc32d13babeec7693cc27b48d5b1faf4b8dca..1e43d792216248c1abe3504c239ccd325f8d5ef1 100644 (file)
@@ -2,7 +2,6 @@
 #include "cache.h"
 #include "refs.h"
 #include "commit.h"
-#include "strbuf.h"
 
 static char *get_stdin(void)
 {
@@ -11,7 +10,7 @@ static char *get_stdin(void)
        if (strbuf_read(&buf, 0, 1024) < 0) {
                die("error reading standard input: %s", strerror(errno));
        }
-       return strbuf_detach(&buf);
+       return strbuf_detach(&buf, NULL);
 }
 
 static void show_new(enum object_type type, unsigned char *sha1_new)
@@ -223,19 +222,15 @@ static char *find_local_name(const char *remote_name, const char *refs,
                }
                if (!strncmp(remote_name, ref, len) && ref[len] == ':') {
                        const char *local_part = ref + len + 1;
-                       char *ret;
                        int retlen;
 
                        if (!next)
                                retlen = strlen(local_part);
                        else
                                retlen = next - local_part;
-                       ret = xmalloc(retlen + 1);
-                       memcpy(ret, local_part, retlen);
-                       ret[retlen] = 0;
                        *force_p = single_force;
                        *not_for_merge_p = not_for_merge;
-                       return ret;
+                       return xmemdupz(local_part, retlen);
                }
                ref = next;
        }