Merge branch 'ot/pretty'
authorJunio C Hamano <gitster@pobox.com>
Wed, 27 Dec 2017 19:16:29 +0000 (11:16 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Dec 2017 19:16:29 +0000 (11:16 -0800)
Code clean-up.

* ot/pretty:
format: create docs for pretty.h
format: create pretty.h file

1  2 
builtin/notes.c
builtin/reset.c
builtin/show-branch.c
diff --combined builtin/notes.c
index 1a2c7d92ad7e73246be8dc64946feb00c16f7261,166bb3f766936faf394f46fee04d206092d63650..7c8176164561be1d57771ad2fdeb9260cc1d8c87
@@@ -12,7 -12,7 +12,7 @@@
  #include "builtin.h"
  #include "notes.h"
  #include "blob.h"
- #include "commit.h"
+ #include "pretty.h"
  #include "refs.h"
  #include "exec_cmd.h"
  #include "run-command.h"
@@@ -33,7 -33,7 +33,7 @@@ static const char * const git_notes_usa
        N_("git notes merge --commit [-v | -q]"),
        N_("git notes merge --abort [-v | -q]"),
        N_("git notes [--ref <notes-ref>] remove [<object>...]"),
 -      N_("git notes [--ref <notes-ref>] prune [-n | -v]"),
 +      N_("git notes [--ref <notes-ref>] prune [-n] [-v]"),
        N_("git notes [--ref <notes-ref>] get-ref"),
        NULL
  };
@@@ -686,7 -686,7 +686,7 @@@ static int merge_abort(struct notes_mer
  
        if (delete_ref(NULL, "NOTES_MERGE_PARTIAL", NULL, 0))
                ret += error(_("failed to delete ref NOTES_MERGE_PARTIAL"));
 -      if (delete_ref(NULL, "NOTES_MERGE_REF", NULL, REF_NODEREF))
 +      if (delete_ref(NULL, "NOTES_MERGE_REF", NULL, REF_NO_DEREF))
                ret += error(_("failed to delete ref NOTES_MERGE_REF"));
        if (notes_merge_abort(o))
                ret += error(_("failed to remove 'git notes merge' worktree"));
@@@ -724,7 -724,7 +724,7 @@@ static int merge_commit(struct notes_me
        init_notes(t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0);
  
        o->local_ref = local_ref_to_free =
 -              resolve_refdup("NOTES_MERGE_REF", 0, oid.hash, NULL);
 +              resolve_refdup("NOTES_MERGE_REF", 0, &oid, NULL);
        if (!o->local_ref)
                die(_("failed to resolve NOTES_MERGE_REF"));
  
        format_commit_message(partial, "%s", &msg, &pretty_ctx);
        strbuf_trim(&msg);
        strbuf_insert(&msg, 0, "notes: ", 7);
 -      update_ref(msg.buf, o->local_ref, oid.hash,
 -                 is_null_oid(&parent_oid) ? NULL : parent_oid.hash,
 +      update_ref(msg.buf, o->local_ref, &oid,
 +                 is_null_oid(&parent_oid) ? NULL : &parent_oid,
                   0, UPDATE_REFS_DIE_ON_ERR);
  
        free_notes(t);
@@@ -850,12 -850,12 +850,12 @@@ static int merge(int argc, const char *
  
        if (result >= 0) /* Merge resulted (trivially) in result_oid */
                /* Update default notes ref with new commit */
 -              update_ref(msg.buf, default_notes_ref(), result_oid.hash, NULL,
 -                         0, UPDATE_REFS_DIE_ON_ERR);
 +              update_ref(msg.buf, default_notes_ref(), &result_oid, NULL, 0,
 +                         UPDATE_REFS_DIE_ON_ERR);
        else { /* Merge has unresolved conflicts */
                const struct worktree *wt;
                /* Update .git/NOTES_MERGE_PARTIAL with partial merge result */
 -              update_ref(msg.buf, "NOTES_MERGE_PARTIAL", result_oid.hash, NULL,
 +              update_ref(msg.buf, "NOTES_MERGE_PARTIAL", &result_oid, NULL,
                           0, UPDATE_REFS_DIE_ON_ERR);
                /* Store ref-to-be-updated into .git/NOTES_MERGE_REF */
                wt = find_shared_symref("NOTES_MERGE_REF", default_notes_ref());
diff --combined builtin/reset.c
index 906e5416582301233cb275fb102a63cb6d1dd139,43c8514695db9a2112bf4ab4361dcbcbfd420132..e15f595799c40933e31f909715e35b4d0a665fc0
@@@ -12,7 -12,7 +12,7 @@@
  #include "lockfile.h"
  #include "tag.h"
  #include "object.h"
- #include "commit.h"
+ #include "pretty.h"
  #include "run-command.h"
  #include "refs.h"
  #include "diff.h"
@@@ -166,7 -166,7 +166,7 @@@ static int read_from_tree(const struct 
        opt.output_format = DIFF_FORMAT_CALLBACK;
        opt.format_callback = update_index_from_diff;
        opt.format_callback_data = &intent_to_add;
 -      opt.flags |= DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;
 +      opt.flags.override_submodule_config = 1;
  
        if (do_diff_cache(tree_oid, &opt))
                return 1;
@@@ -266,12 -266,12 +266,12 @@@ static int reset_refs(const char *rev, 
        if (!get_oid("HEAD", &oid_orig)) {
                orig = &oid_orig;
                set_reflog_message(&msg, "updating ORIG_HEAD", NULL);
 -              update_ref_oid(msg.buf, "ORIG_HEAD", orig, old_orig, 0,
 +              update_ref(msg.buf, "ORIG_HEAD", orig, old_orig, 0,
                           UPDATE_REFS_MSG_ON_ERR);
        } else if (old_orig)
 -              delete_ref(NULL, "ORIG_HEAD", old_orig->hash, 0);
 +              delete_ref(NULL, "ORIG_HEAD", old_orig, 0);
        set_reflog_message(&msg, "updating HEAD", rev);
 -      update_ref_status = update_ref_oid(msg.buf, "HEAD", oid, orig, 0,
 +      update_ref_status = update_ref(msg.buf, "HEAD", oid, orig, 0,
                                       UPDATE_REFS_MSG_ON_ERR);
        strbuf_release(&msg);
        return update_ref_status;
diff --combined builtin/show-branch.c
index 2e24b5c330e8eb17a8755e9b47fa3c66810981d3,f4069d6ec8e2821537150767d5d0277ecd60ab8c..e8a4aa40cb4b6cf8787af3dd35d833a92a85bba3
@@@ -1,6 -1,6 +1,6 @@@
  #include "cache.h"
  #include "config.h"
- #include "commit.h"
+ #include "pretty.h"
  #include "refs.h"
  #include "builtin.h"
  #include "color.h"
@@@ -705,8 -705,8 +705,8 @@@ int cmd_show_branch(int ac, const char 
                        static const char *fake_av[2];
  
                        fake_av[0] = resolve_refdup("HEAD",
 -                                                  RESOLVE_REF_READING,
 -                                                  oid.hash, NULL);
 +                                                  RESOLVE_REF_READING, &oid,
 +                                                  NULL);
                        fake_av[1] = NULL;
                        av = fake_av;
                        ac = 1;
                        die(Q_("only %d entry can be shown at one time.",
                               "only %d entries can be shown at one time.",
                               MAX_REVS), MAX_REVS);
 -              if (!dwim_ref(*av, strlen(*av), oid.hash, &ref))
 +              if (!dwim_ref(*av, strlen(*av), &oid, &ref))
                        die(_("no such ref %s"), *av);
  
                /* Has the base been specified? */
                                /* Ah, that is a date spec... */
                                timestamp_t at;
                                at = approxidate(reflog_base);
 -                              read_ref_at(ref, flags, at, -1, oid.hash, NULL,
 +                              read_ref_at(ref, flags, at, -1, &oid, NULL,
                                            NULL, NULL, &base);
                        }
                }
                        timestamp_t timestamp;
                        int tz;
  
 -                      if (read_ref_at(ref, flags, 0, base+i, oid.hash, &logmsg,
 +                      if (read_ref_at(ref, flags, 0, base + i, &oid, &logmsg,
                                        &timestamp, &tz, NULL)) {
                                reflog = i;
                                break;
        }
  
        head = resolve_refdup("HEAD", RESOLVE_REF_READING,
 -                            head_oid.hash, NULL);
 +                            &head_oid, NULL);
  
        if (with_current_branch && head) {
                int has_head = 0;