builtin/apply: make add_conflicted_stages_file() return -1 on error
[gitweb.git] / walker.c
index 4eb4df8ff3c66dae1dd0aba1d1fc27b5bc229e42..2c86e406f92d9bf0063e6be4f9d76fdbbac17c89 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -9,10 +9,14 @@
 
 static unsigned char current_commit_sha1[20];
 
-void walker_say(struct walker *walker, const char *fmt, const char *hex)
+void walker_say(struct walker *walker, const char *fmt, ...)
 {
-       if (walker->get_verbosely)
-               fprintf(stderr, fmt, hex);
+       if (walker->get_verbosely) {
+               va_list ap;
+               va_start(ap, fmt);
+               vfprintf(stderr, fmt, ap);
+               va_end(ap);
+       }
 }
 
 static void report_missing(const struct object *obj)
@@ -43,12 +47,12 @@ static int process_tree(struct walker *walker, struct tree *tree)
                if (S_ISGITLINK(entry.mode))
                        continue;
                if (S_ISDIR(entry.mode)) {
-                       struct tree *tree = lookup_tree(entry.sha1);
+                       struct tree *tree = lookup_tree(entry.oid->hash);
                        if (tree)
                                obj = &tree->object;
                }
                else {
-                       struct blob *blob = lookup_blob(entry.sha1);
+                       struct blob *blob = lookup_blob(entry.oid->hash);
                        if (blob)
                                obj = &blob->object;
                }
@@ -78,7 +82,7 @@ static int process_commit(struct walker *walker, struct commit *commit)
        if (commit->object.flags & COMPLETE)
                return 0;
 
-       hashcpy(current_commit_sha1, get_object_hash(commit->object));
+       hashcpy(current_commit_sha1, commit->object.oid.hash);
 
        walker_say(walker, "walk %s\n", oid_to_hex(&commit->object.oid));
 
@@ -146,7 +150,7 @@ static int process(struct walker *walker, struct object *obj)
        else {
                if (obj->flags & COMPLETE)
                        return 0;
-               walker->prefetch(walker, get_object_hash(*obj));
+               walker->prefetch(walker, obj->oid.hash);
        }
 
        object_list_insert(obj, process_queue_end);
@@ -170,13 +174,13 @@ static int loop(struct walker *walker)
                 * the queue because we needed to fetch it first.
                 */
                if (! (obj->flags & TO_SCAN)) {
-                       if (walker->fetch(walker, get_object_hash(*obj))) {
+                       if (walker->fetch(walker, obj->oid.hash)) {
                                report_missing(obj);
                                return -1;
                        }
                }
                if (!obj->type)
-                       parse_object(get_object_hash(*obj));
+                       parse_object(obj->oid.hash);
                if (process_object(walker, obj))
                        return -1;
        }
@@ -220,7 +224,7 @@ int walker_targets_stdin(char ***target, const char ***write_ref)
                char *rf_one = NULL;
                char *tg_one;
 
-               if (strbuf_getline(&buf, stdin, '\n') == EOF)
+               if (strbuf_getline_lf(&buf, stdin) == EOF)
                        break;
                tg_one = buf.buf;
                rf_one = strchr(tg_one, '\t');