Replace uses of strdup with xstrdup.
[gitweb.git] / builtin-rev-list.c
index 63bad0e96ade657bef21d9ca0e0de2e0ba8af61c..8437454fbe4e3237aaa6aaecefe54caefb621f1b 100644 (file)
@@ -39,9 +39,9 @@ static const char rev_list_usage[] =
 
 static struct rev_info revs;
 
-static int bisect_list = 0;
-static int show_timestamp = 0;
-static int hdr_termination = 0;
+static int bisect_list;
+static int show_timestamp;
+static int hdr_termination;
 static const char *header_prefix;
 
 static void show_commit(struct commit *commit)
@@ -85,7 +85,7 @@ static void show_commit(struct commit *commit)
                static char pretty_header[16384];
                pretty_print_commit(revs.commit_format, commit, ~0,
                                    pretty_header, sizeof(pretty_header),
-                                   revs.abbrev, NULL, NULL);
+                                   revs.abbrev, NULL, NULL, revs.relative_date);
                printf("%s%c", pretty_header, hdr_termination);
        }
        fflush(stdout);
@@ -93,10 +93,8 @@ static void show_commit(struct commit *commit)
                free_commit_list(commit->parents);
                commit->parents = NULL;
        }
-       if (commit->buffer) {
-               free(commit->buffer);
-               commit->buffer = NULL;
-       }
+       free(commit->buffer);
+       commit->buffer = NULL;
 }
 
 static void process_blob(struct blob *blob,
@@ -111,7 +109,7 @@ static void process_blob(struct blob *blob,
        if (obj->flags & (UNINTERESTING | SEEN))
                return;
        obj->flags |= SEEN;
-       name = strdup(name);
+       name = xstrdup(name);
        add_object(obj, p, path, name);
 }
 
@@ -132,7 +130,7 @@ static void process_tree(struct tree *tree,
        if (parse_tree(tree) < 0)
                die("bad tree object %s", sha1_to_hex(obj->sha1));
        obj->flags |= SEEN;
-       name = strdup(name);
+       name = xstrdup(name);
        add_object(obj, p, path, name);
        me.up = path;
        me.elem = name;
@@ -167,16 +165,16 @@ static void show_commit_list(struct rev_info *revs)
                const char *name = pending->name;
                if (obj->flags & (UNINTERESTING | SEEN))
                        continue;
-               if (obj->type == TYPE_TAG) {
+               if (obj->type == OBJ_TAG) {
                        obj->flags |= SEEN;
                        add_object_array(obj, name, &objects);
                        continue;
                }
-               if (obj->type == TYPE_TREE) {
+               if (obj->type == OBJ_TREE) {
                        process_tree((struct tree *)obj, &objects, NULL, name);
                        continue;
                }
-               if (obj->type == TYPE_BLOB) {
+               if (obj->type == OBJ_BLOB) {
                        process_blob((struct blob *)obj, &objects, NULL, name);
                        continue;
                }
@@ -306,12 +304,12 @@ static void mark_edges_uninteresting(struct commit_list *list)
        }
 }
 
-int cmd_rev_list(int argc, const char **argv, char **envp)
+int cmd_rev_list(int argc, const char **argv, const char *prefix)
 {
        struct commit_list *list;
        int i;
 
-       init_revisions(&revs);
+       init_revisions(&revs, prefix);
        revs.abbrev = 0;
        revs.commit_format = CMIT_FMT_UNSPECIFIED;
        argc = setup_revisions(argc, argv, &revs, NULL);