Code

use only the $PATH for exec'ing git commands
[git.git] / builtin-fetch--tool.c
index 90bdc32d13babeec7693cc27b48d5b1faf4b8dca..6a78517958567e9dee4bfb00236caf5c3d1c3d67 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)
@@ -26,7 +25,7 @@ static int update_ref_env(const char *action,
                      unsigned char *oldval)
 {
        char msg[1024];
-       char *rla = getenv("GIT_REFLOG_ACTION");
+       const char *rla = getenv("GIT_REFLOG_ACTION");
 
        if (!rla)
                rla = "(reflog update)";
@@ -62,7 +61,7 @@ static int update_local_ref(const char *name,
        }
 
        if (get_sha1(name, sha1_old)) {
-               char *msg;
+               const char *msg;
        just_store:
                /* new ref */
                if (!strncmp(name, "refs/tags/", 10))
@@ -132,7 +131,7 @@ static int append_fetch_head(FILE *fp,
 
        if (get_sha1(head, sha1))
                return error("Not a valid object name: %s", head);
-       commit = lookup_commit_reference(sha1);
+       commit = lookup_commit_reference_gently(sha1, 1);
        if (!commit)
                not_for_merge = 1;
 
@@ -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;
        }