OSDN Git Service

reduce git-pack-objects memory usage a little more
[git-core/git.git] / builtin-fetch--tool.c
index be341c1..ed4d5de 100644 (file)
@@ -6,11 +6,11 @@
 
 static char *get_stdin(void)
 {
-       int offset = 0;
+       size_t offset = 0;
        char *data = xmalloc(CHUNK_SIZE);
 
        while (1) {
-               int cnt = xread(0, data + offset, CHUNK_SIZE);
+               ssize_t cnt = xread(0, data + offset, CHUNK_SIZE);
                if (cnt < 0)
                        die("error reading standard input: %s",
                            strerror(errno));
@@ -35,17 +35,14 @@ static int update_ref(const char *action,
                      unsigned char *sha1,
                      unsigned char *oldval)
 {
-       int len;
        char msg[1024];
        char *rla = getenv("GIT_REFLOG_ACTION");
        static struct ref_lock *lock;
 
        if (!rla)
                rla = "(reflog update)";
-       len = snprintf(msg, sizeof(msg), "%s: %s", rla, action);
-       if (sizeof(msg) <= len)
-               die("insanely long action");
-       lock = lock_any_ref_for_update(refname, oldval);
+       snprintf(msg, sizeof(msg), "%s: %s", rla, action);
+       lock = lock_any_ref_for_update(refname, oldval, 0);
        if (!lock)
                return 1;
        if (write_ref_sha1(lock, sha1, msg) < 0)
@@ -571,9 +568,13 @@ int cmd_fetch__tool(int argc, const char **argv, const char *prefix)
                return parse_reflist(reflist);
        }
        if (!strcmp("pick-rref", argv[1])) {
+               const char *ls_remote_result;
                if (argc != 4)
                        return error("pick-rref takes 2 args");
-               return pick_rref(sopt, argv[2], argv[3]);
+               ls_remote_result = argv[3];
+               if (!strcmp(ls_remote_result, "-"))
+                       ls_remote_result = get_stdin();
+               return pick_rref(sopt, argv[2], ls_remote_result);
        }
        if (!strcmp("expand-refs-wildcard", argv[1])) {
                const char *reflist;