Code

Merge branch 'maint'
[git.git] / builtin-fetch--tool.c
index 1e43d792216248c1abe3504c239ccd325f8d5ef1..ed60847d9fcd0ad8803c432af8d0bc2dd3567768 100644 (file)
@@ -25,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)";
@@ -61,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))
@@ -131,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;
 
@@ -435,9 +435,7 @@ static int pick_rref(int sha1_only, const char *rref, const char *ls_remote_resu
                                cp++;
                        if (!*cp)
                                break;
-                       np = strchr(cp, '\n');
-                       if (!np)
-                               np = cp + strlen(cp);
+                       np = strchrnul(cp, '\n');
                        if (pass) {
                                lrr_list[i].line = cp;
                                lrr_list[i].name = cp + 41;
@@ -461,9 +459,7 @@ static int pick_rref(int sha1_only, const char *rref, const char *ls_remote_resu
                        rref++;
                if (!*rref)
                        break;
-               next = strchr(rref, '\n');
-               if (!next)
-                       next = rref + strlen(rref);
+               next = strchrnul(rref, '\n');
                rreflen = next - rref;
 
                for (i = 0; i < lrr_count; i++) {