Merge branch 'pw/completion-stash' into maint
[gitweb.git] / builtin / log.c
index dda671d975255494a6987e82e2ccf23f7f69f7ee..e00cea75cca8bbde28ba45359c28b5a13a1b75e7 100644 (file)
@@ -552,7 +552,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
                const char *name = objects[i].name;
                switch (o->type) {
                case OBJ_BLOB:
-                       ret = show_blob_object(o->sha1, &rev, name);
+                       ret = show_blob_object(o->oid.hash, &rev, name);
                        break;
                case OBJ_TAG: {
                        struct tag *t = (struct tag *)o;
@@ -563,14 +563,14 @@ int cmd_show(int argc, const char **argv, const char *prefix)
                                        diff_get_color_opt(&rev.diffopt, DIFF_COMMIT),
                                        t->tag,
                                        diff_get_color_opt(&rev.diffopt, DIFF_RESET));
-                       ret = show_tag_object(o->sha1, &rev);
+                       ret = show_tag_object(o->oid.hash, &rev);
                        rev.shown_one = 1;
                        if (ret)
                                break;
-                       o = parse_object(t->tagged->sha1);
+                       o = parse_object(t->tagged->oid.hash);
                        if (!o)
                                ret = error(_("Could not read object %s"),
-                                           sha1_to_hex(t->tagged->sha1));
+                                           oid_to_hex(&t->tagged->oid));
                        objects[i].item = o;
                        i--;
                        break;
@@ -830,8 +830,8 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
        o2 = rev->pending.objects[1].item;
        flags1 = o1->flags;
        flags2 = o2->flags;
-       c1 = lookup_commit_reference(o1->sha1);
-       c2 = lookup_commit_reference(o2->sha1);
+       c1 = lookup_commit_reference(o1->oid.hash);
+       c2 = lookup_commit_reference(o2->oid.hash);
 
        if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))
                die(_("Not a range."));
@@ -896,8 +896,8 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)
 static char *find_branch_name(struct rev_info *rev)
 {
        int i, positive = -1;
-       unsigned char branch_sha1[20];
-       const unsigned char *tip_sha1;
+       struct object_id branch_oid;
+       const struct object_id *tip_oid;
        const char *ref, *v;
        char *full_ref, *branch = NULL;
 
@@ -912,10 +912,10 @@ static char *find_branch_name(struct rev_info *rev)
        if (positive < 0)
                return NULL;
        ref = rev->cmdline.rev[positive].name;
-       tip_sha1 = rev->cmdline.rev[positive].item->sha1;
-       if (dwim_ref(ref, strlen(ref), branch_sha1, &full_ref) &&
+       tip_oid = &rev->cmdline.rev[positive].item->oid;
+       if (dwim_ref(ref, strlen(ref), branch_oid.hash, &full_ref) &&
            skip_prefix(full_ref, "refs/heads/", &v) &&
-           !hashcmp(tip_sha1, branch_sha1))
+           !oidcmp(tip_oid, &branch_oid))
                branch = xstrdup(v);
        free(full_ref);
        return branch;
@@ -993,8 +993,8 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 
        diff_setup_done(&opts);
 
-       diff_tree_sha1(origin->tree->object.sha1,
-                      head->tree->object.sha1,
+       diff_tree_sha1(origin->tree->object.oid.hash,
+                      head->tree->object.oid.hash,
                       "", &opts);
        diffcore_std(&opts);
        diff_flush(&opts);
@@ -1196,6 +1196,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        int cover_letter = -1;
        int boundary_count = 0;
        int no_binary_diff = 0;
+       int zero_commit = 0;
        struct commit *origin = NULL;
        const char *in_reply_to = NULL;
        struct patch_ids ids;
@@ -1236,6 +1237,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                            PARSE_OPT_NOARG | PARSE_OPT_NONEG, keep_callback },
                OPT_BOOL(0, "no-binary", &no_binary_diff,
                         N_("don't output binary diffs")),
+               OPT_BOOL(0, "zero-commit", &zero_commit,
+                        N_("output all-zero hash in From header")),
                OPT_BOOL(0, "ignore-if-in-upstream", &ignore_if_in_upstream,
                         N_("don't include a patch matching a commit upstream")),
                { OPTION_SET_INT, 'p', "no-stat", &use_patch_format, NULL,
@@ -1380,6 +1383,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        /* Always generate a patch */
        rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
 
+       rev.zero_commit = zero_commit;
+
        if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)
                DIFF_OPT_SET(&rev.diffopt, BINARY);
 
@@ -1443,7 +1448,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                /* Don't say anything if head and upstream are the same. */
                if (rev.pending.nr == 2) {
                        struct object_array_entry *o = rev.pending.objects;
-                       if (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0)
+                       if (oidcmp(&o[0].item->oid, &o[1].item->oid) == 0)
                                return 0;
                }
                get_patch_ids(&rev, &ids);
@@ -1550,7 +1555,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                                        string_list_append(rev.ref_message_ids,
                                                           rev.message_id);
                        }
-                       gen_message_id(&rev, sha1_to_hex(commit->object.sha1));
+                       gen_message_id(&rev, oid_to_hex(&commit->object.oid));
                }
 
                if (!use_stdout &&
@@ -1612,12 +1617,12 @@ static void print_commit(char sign, struct commit *commit, int verbose,
 {
        if (!verbose) {
                printf("%c %s\n", sign,
-                      find_unique_abbrev(commit->object.sha1, abbrev));
+                      find_unique_abbrev(commit->object.oid.hash, abbrev));
        } else {
                struct strbuf buf = STRBUF_INIT;
                pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
                printf("%c %s %s\n", sign,
-                      find_unique_abbrev(commit->object.sha1, abbrev),
+                      find_unique_abbrev(commit->object.oid.hash, abbrev),
                       buf.buf);
                strbuf_release(&buf);
        }
@@ -1675,7 +1680,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
        /* Don't say anything if head and upstream are the same. */
        if (revs.pending.nr == 2) {
                struct object_array_entry *o = revs.pending.objects;
-               if (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0)
+               if (oidcmp(&o[0].item->oid, &o[1].item->oid) == 0)
                        return 0;
        }