Merge branch 'ab/c-translators-comment-style'
authorJunio C Hamano <gitster@pobox.com>
Sun, 4 Jun 2017 00:55:44 +0000 (09:55 +0900)
committerJunio C Hamano <gitster@pobox.com>
Sun, 4 Jun 2017 00:55:44 +0000 (09:55 +0900)
Update the C style recommendation for notes for translators, as
recent versions of gettext tools can work with our style of
multi-line comments.

* ab/c-translators-comment-style:
C style: use standard style for "TRANSLATORS" comments

1  2 
Documentation/CodingGuidelines
bisect.c
builtin/blame.c
builtin/notes.c
notes-utils.c
ref-filter.c
sequencer.c
index 2248cf7324c712960db87cd96a4bb030d062cb81,9fd7383819930c89632e57c2694c318a2efca9bb..c4cb5ff0d477938b8fd49749c3589c5afbb04221
@@@ -24,7 -24,7 +24,7 @@@ code.  For Git in general, a few rough 
  
     "Once it _is_ in the tree, it's not really worth the patch noise to
     go and fix it up."
 -   Cf. http://article.gmane.org/gmane.linux.kernel/943020
 +   Cf. http://lkml.iu.edu/hypermail/linux/kernel/1001.3/01069.html
  
  Make your code readable and sensible, and don't try to be clever.
  
@@@ -256,12 -256,12 +256,12 @@@ For C programs
  
     Note however that a comment that explains a translatable string to
     translators uses a convention of starting with a magic token
-    "TRANSLATORS: " immediately after the opening delimiter, even when
-    it spans multiple lines.  We do not add an asterisk at the beginning
-    of each line, either.  E.g.
+    "TRANSLATORS: ", e.g.
  
-       /* TRANSLATORS: here is a comment that explains the string
-          to be translated, that follows immediately after it */
+       /*
+        * TRANSLATORS: here is a comment that explains the string to
+        * be translated, that follows immediately after it.
+        */
        _("Here is a translatable string explained by the above.");
  
   - Double negation is often harder to understand than no negation
diff --combined bisect.c
index d88f9bc3dc1f78535b8a801c7f123340bb9c161a,c5d5a2b64befe41aed40f12e21deaae33adb9613..c952df692bef9ba1638e55448050db33ba76d399
+++ b/bisect.c
@@@ -546,7 -546,7 +546,7 @@@ static unsigned get_prn(unsigned count
  
  /*
   * Custom integer square root from
 - * http://en.wikipedia.org/wiki/Integer_square_root
 + * https://en.wikipedia.org/wiki/Integer_square_root
   */
  static int sqrti(int val)
  {
@@@ -705,7 -705,7 +705,7 @@@ static int bisect_checkout(const unsign
  
  static struct commit *get_commit_reference(const struct object_id *oid)
  {
 -      struct commit *r = lookup_commit_reference(oid->hash);
 +      struct commit *r = lookup_commit_reference(oid);
        if (!r)
                die(_("Not a valid commit name %s"), oid_to_hex(oid));
        return r;
@@@ -995,8 -995,10 +995,10 @@@ int bisect_next_all(const char *prefix
  
        steps_msg = xstrfmt(Q_("(roughly %d step)", "(roughly %d steps)",
                  steps), steps);
-       /* TRANSLATORS: the last %s will be replaced with
-          "(roughly %d steps)" translation */
+       /*
+        * TRANSLATORS: the last %s will be replaced with "(roughly %d
+        * steps)" translation.
+        */
        printf(Q_("Bisecting: %d revision left to test after this %s\n",
                  "Bisecting: %d revisions left to test after this %s\n",
                  nr), nr, steps_msg);
diff --combined builtin/blame.c
index 1043e5376f35bd56f498f9078676c08ffcff687d,ca9ebe40e7d4dac16a7b325e18857e9f1bfb316c..9cb96101157651c74d367c2160beed9841073731
@@@ -563,7 -563,7 +563,7 @@@ static struct origin *find_origin(struc
        diff_setup_done(&diff_opts);
  
        if (is_null_oid(&origin->commit->object.oid))
 -              do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
 +              do_diff_cache(&parent->tree->object.oid, &diff_opts);
        else
                diff_tree_sha1(parent->tree->object.oid.hash,
                               origin->commit->tree->object.oid.hash,
@@@ -633,7 -633,7 +633,7 @@@ static struct origin *find_rename(struc
        diff_setup_done(&diff_opts);
  
        if (is_null_oid(&origin->commit->object.oid))
 -              do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
 +              do_diff_cache(&parent->tree->object.oid, &diff_opts);
        else
                diff_tree_sha1(parent->tree->object.oid.hash,
                               origin->commit->tree->object.oid.hash,
@@@ -1272,7 -1272,7 +1272,7 @@@ static void find_copy_in_parent(struct 
                DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);
  
        if (is_null_oid(&target->commit->object.oid))
 -              do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
 +              do_diff_cache(&parent->tree->object.oid, &diff_opts);
        else
                diff_tree_sha1(parent->tree->object.oid.hash,
                               target->commit->tree->object.oid.hash,
@@@ -1561,13 -1561,13 +1561,13 @@@ finish
  struct commit_info {
        struct strbuf author;
        struct strbuf author_mail;
 -      unsigned long author_time;
 +      timestamp_t author_time;
        struct strbuf author_tz;
  
        /* filled only when asked for details */
        struct strbuf committer;
        struct strbuf committer_mail;
 -      unsigned long committer_time;
 +      timestamp_t committer_time;
        struct strbuf committer_tz;
  
        struct strbuf summary;
   */
  static void get_ac_line(const char *inbuf, const char *what,
        struct strbuf *name, struct strbuf *mail,
 -      unsigned long *time, struct strbuf *tz)
 +      timestamp_t *time, struct strbuf *tz)
  {
        struct ident_split ident;
        size_t len, maillen, namelen;
@@@ -1727,11 -1727,11 +1727,11 @@@ static int emit_one_suspect_detail(stru
        get_commit_info(suspect->commit, &ci, 1);
        printf("author %s\n", ci.author.buf);
        printf("author-mail %s\n", ci.author_mail.buf);
 -      printf("author-time %lu\n", ci.author_time);
 +      printf("author-time %"PRItime"\n", ci.author_time);
        printf("author-tz %s\n", ci.author_tz.buf);
        printf("committer %s\n", ci.committer.buf);
        printf("committer-mail %s\n", ci.committer_mail.buf);
 -      printf("committer-time %lu\n", ci.committer_time);
 +      printf("committer-time %"PRItime"\n", ci.committer_time);
        printf("committer-tz %s\n", ci.committer_tz.buf);
        printf("summary %s\n", ci.summary.buf);
        if (suspect->commit->object.flags & UNINTERESTING)
@@@ -1837,14 -1837,14 +1837,14 @@@ static void assign_blame(struct scorebo
        stop_progress(&pi.progress);
  }
  
 -static const char *format_time(unsigned long time, const char *tz_str,
 +static const char *format_time(timestamp_t time, const char *tz_str,
                               int show_raw_time)
  {
        static struct strbuf time_buf = STRBUF_INIT;
  
        strbuf_reset(&time_buf);
        if (show_raw_time) {
 -              strbuf_addf(&time_buf, "%lu %s", time, tz_str);
 +              strbuf_addf(&time_buf, "%"PRItime" %s", time, tz_str);
        }
        else {
                const char *time_str;
@@@ -2253,7 -2253,7 +2253,7 @@@ static struct commit_list **append_pare
  {
        struct commit *parent;
  
 -      parent = lookup_commit_reference(oid->hash);
 +      parent = lookup_commit_reference(oid);
        if (!parent)
                die("no such commit %s", oid_to_hex(oid));
        return &commit_list_insert(parent, tail)->next;
@@@ -2461,7 -2461,7 +2461,7 @@@ static const char *dwim_reverse_initial
         */
        struct object *obj;
        struct commit *head_commit;
 -      unsigned char head_sha1[20];
 +      struct object_id head_oid;
  
        if (sb->revs->pending.nr != 1)
                return NULL;
                return NULL;
  
        /* Do we have HEAD? */
 -      if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_sha1, NULL))
 +      if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL))
                return NULL;
 -      head_commit = lookup_commit_reference_gently(head_sha1, 1);
 +      head_commit = lookup_commit_reference_gently(&head_oid, 1);
        if (!head_commit)
                return NULL;
  
@@@ -2688,12 -2688,15 +2688,15 @@@ parse_done
                blame_date_width = sizeof("2006-10-19");
                break;
        case DATE_RELATIVE:
-               /* TRANSLATORS: This string is used to tell us the maximum
-                  display width for a relative timestamp in "git blame"
-                  output.  For C locale, "4 years, 11 months ago", which
-                  takes 22 places, is the longest among various forms of
-                  relative timestamps, but your language may need more or
-                  fewer display columns. */
+               /*
+                * TRANSLATORS: This string is used to tell us the
+                * maximum display width for a relative timestamp in
+                * "git blame" output.  For C locale, "4 years, 11
+                * months ago", which takes 22 places, is the longest
+                * among various forms of relative timestamps, but
+                * your language may need more or fewer display
+                * columns.
+                */
                blame_date_width = utf8_strwidth(_("4 years, 11 months ago")) + 1; /* add the null */
                break;
        case DATE_NORMAL:
diff --combined builtin/notes.c
index f2847c41e00996f6ff129774961b5fafca513972,fb856e53b610087128094e3fc4deb7bab2106801..7196bff0eb2454eee86f87241706523c0266e66e
@@@ -340,8 -340,10 +340,10 @@@ static struct notes_tree *init_notes_ch
  
        ref = (flags & NOTES_INIT_WRITABLE) ? t->update_ref : t->ref;
        if (!starts_with(ref, "refs/notes/"))
-               /* TRANSLATORS: the first %s will be replaced by a
-                  git notes command: 'add', 'merge', 'remove', etc.*/
+               /*
+                * TRANSLATORS: the first %s will be replaced by a git
+                * notes command: 'add', 'merge', 'remove', etc.
+                */
                die(_("refusing to %s notes in %s (outside of refs/notes/)"),
                    subcommand, ref);
        return t;
@@@ -706,7 -708,7 +708,7 @@@ static int merge_commit(struct notes_me
  
        if (get_oid("NOTES_MERGE_PARTIAL", &oid))
                die(_("failed to read ref NOTES_MERGE_PARTIAL"));
 -      else if (!(partial = lookup_commit_reference(oid.hash)))
 +      else if (!(partial = lookup_commit_reference(&oid)))
                die(_("could not find commit from NOTES_MERGE_PARTIAL."));
        else if (parse_commit(partial))
                die(_("could not parse commit from NOTES_MERGE_PARTIAL."));
diff --combined notes-utils.c
index 325ff3daa37c5a0ce26c608b2e7bfd8a94b7f396,8f9ad7d1f85015cafc9175408d8264d08ea9581f..031503d7b2ba9217cffa52652b57aa063208fb1a
@@@ -7,18 -7,18 +7,18 @@@ void create_notes_commit(struct notes_t
                         const char *msg, size_t msg_len,
                         unsigned char *result_sha1)
  {
 -      unsigned char tree_sha1[20];
 +      struct object_id tree_oid;
  
        assert(t->initialized);
  
 -      if (write_notes_tree(t, tree_sha1))
 +      if (write_notes_tree(t, tree_oid.hash))
                die("Failed to write notes tree to database");
  
        if (!parents) {
                /* Deduce parent commit from t->ref */
 -              unsigned char parent_sha1[20];
 -              if (!read_ref(t->ref, parent_sha1)) {
 -                      struct commit *parent = lookup_commit(parent_sha1);
 +              struct object_id parent_oid;
 +              if (!read_ref(t->ref, parent_oid.hash)) {
 +                      struct commit *parent = lookup_commit(&parent_oid);
                        if (parse_commit(parent))
                                die("Failed to find/parse commit %s", t->ref);
                        commit_list_insert(parent, &parents);
                /* else: t->ref points to nothing, assume root/orphan commit */
        }
  
 -      if (commit_tree(msg, msg_len, tree_sha1, parents, result_sha1, NULL, NULL))
 +      if (commit_tree(msg, msg_len, tree_oid.hash, parents, result_sha1, NULL, NULL))
                die("Failed to commit notes tree to database");
  }
  
  void commit_notes(struct notes_tree *t, const char *msg)
  {
        struct strbuf buf = STRBUF_INIT;
 -      unsigned char commit_sha1[20];
 +      struct object_id commit_oid;
  
        if (!t)
                t = &default_notes_tree;
@@@ -46,9 -46,9 +46,9 @@@
        strbuf_addstr(&buf, msg);
        strbuf_complete_line(&buf);
  
 -      create_notes_commit(t, NULL, buf.buf, buf.len, commit_sha1);
 +      create_notes_commit(t, NULL, buf.buf, buf.len, commit_oid.hash);
        strbuf_insert(&buf, 0, "notes: ", 7); /* commit message starts at index 7 */
 -      update_ref(buf.buf, t->update_ref, commit_sha1, NULL, 0,
 +      update_ref(buf.buf, t->update_ref, commit_oid.hash, NULL, 0,
                   UPDATE_REFS_DIE_ON_ERR);
  
        strbuf_release(&buf);
@@@ -132,8 -132,11 +132,11 @@@ struct notes_rewrite_cfg *init_copy_not
                c->mode_from_env = 1;
                c->combine = parse_combine_notes_fn(rewrite_mode_env);
                if (!c->combine)
-                       /* TRANSLATORS: The first %s is the name of the
-                          environment variable, the second %s is its value */
+                       /*
+                        * TRANSLATORS: The first %s is the name of
+                        * the environment variable, the second %s is
+                        * its value.
+                        */
                        error(_("Bad %s value: '%s'"), GIT_NOTES_REWRITE_MODE_ENVIRONMENT,
                                        rewrite_mode_env);
        }
diff --combined ref-filter.c
index 3742abbf85ce4044641bc937a70504c059ed8822,563284175380cbd8cb3c503390b52781b16cf739..af5c0edb483a3975e17685fdc06bae2ff58d59e4
@@@ -93,7 -93,6 +93,7 @@@ static struct used_atom 
                        unsigned int length;
                } objectname;
                struct refname_atom refname;
 +              char *head;
        } u;
  } *used_atom;
  static int used_atom_cnt, need_tagged, need_symref;
@@@ -288,12 -287,6 +288,12 @@@ static void if_atom_parser(struct used_
        }
  }
  
 +static void head_atom_parser(struct used_atom *atom, const char *arg)
 +{
 +      struct object_id unused;
 +
 +      atom->u.head = resolve_refdup("HEAD", RESOLVE_REF_READING, unused.hash, NULL);
 +}
  
  static struct {
        const char *name;
        { "push", FIELD_STR, remote_ref_atom_parser },
        { "symref", FIELD_STR, refname_atom_parser },
        { "flag" },
 -      { "HEAD" },
 +      { "HEAD", FIELD_STR, head_atom_parser },
        { "color", FIELD_STR, color_atom_parser },
        { "align", FIELD_STR, align_atom_parser },
        { "end" },
@@@ -358,7 -351,7 +358,7 @@@ struct ref_formatting_state 
  struct atom_value {
        const char *s;
        void (*handler)(struct atom_value *atomv, struct ref_formatting_state *state);
 -      unsigned long ul; /* used for sorting when not FIELD_STR */
 +      uintmax_t value; /* used for sorting when not FIELD_STR */
        struct used_atom *atom;
  };
  
@@@ -684,13 -677,13 +684,13 @@@ int verify_ref_format(const char *forma
   * by the "struct object" representation, set *eaten as well---it is a
   * signal from parse_object_buffer to us not to free the buffer.
   */
 -static void *get_obj(const unsigned char *sha1, struct object **obj, unsigned long *sz, int *eaten)
 +static void *get_obj(const struct object_id *oid, struct object **obj, unsigned long *sz, int *eaten)
  {
        enum object_type type;
 -      void *buf = read_sha1_file(sha1, &type, sz);
 +      void *buf = read_sha1_file(oid->hash, &type, sz);
  
        if (buf)
 -              *obj = parse_object_buffer(sha1, type, *sz, buf, eaten);
 +              *obj = parse_object_buffer(oid, type, *sz, buf, eaten);
        else
                *obj = NULL;
        return buf;
@@@ -730,7 -723,7 +730,7 @@@ static void grab_common_values(struct a
                if (!strcmp(name, "objecttype"))
                        v->s = typename(obj->type);
                else if (!strcmp(name, "objectsize")) {
 -                      v->ul = sz;
 +                      v->value = sz;
                        v->s = xstrfmt("%lu", sz);
                }
                else if (deref)
@@@ -777,8 -770,8 +777,8 @@@ static void grab_commit_values(struct a
                        v->s = xstrdup(oid_to_hex(&commit->tree->object.oid));
                }
                else if (!strcmp(name, "numparent")) {
 -                      v->ul = commit_list_count(commit->parents);
 -                      v->s = xstrfmt("%lu", v->ul);
 +                      v->value = commit_list_count(commit->parents);
 +                      v->s = xstrfmt("%lu", (unsigned long)v->value);
                }
                else if (!strcmp(name, "parent")) {
                        struct commit_list *parents;
@@@ -856,7 -849,7 +856,7 @@@ static void grab_date(const char *buf, 
  {
        const char *eoemail = strstr(buf, "> ");
        char *zone;
 -      unsigned long timestamp;
 +      timestamp_t timestamp;
        long tz;
        struct date_mode date_mode = { DATE_NORMAL };
        const char *formatp;
  
        if (!eoemail)
                goto bad;
 -      timestamp = strtoul(eoemail + 2, &zone, 10);
 -      if (timestamp == ULONG_MAX)
 +      timestamp = parse_timestamp(eoemail + 2, &zone, 10);
 +      if (timestamp == TIME_MAX)
                goto bad;
        tz = strtol(zone, NULL, 10);
        if ((tz == LONG_MIN || tz == LONG_MAX) && errno == ERANGE)
                goto bad;
        v->s = xstrdup(show_date(timestamp, tz, &date_mode));
 -      v->ul = timestamp;
 +      v->value = timestamp;
        return;
   bad:
        v->s = "";
 -      v->ul = 0;
 +      v->value = 0;
  }
  
  /* See grab_values */
@@@ -1258,13 -1251,17 +1258,17 @@@ char *get_head_description(void
                            state.branch);
        else if (state.detached_from) {
                if (state.detached_at)
-                       /* TRANSLATORS: make sure this matches
-                          "HEAD detached at " in wt-status.c */
+                       /*
+                        * TRANSLATORS: make sure this matches "HEAD
+                        * detached at " in wt-status.c
+                        */
                        strbuf_addf(&desc, _("(HEAD detached at %s)"),
                                state.detached_from);
                else
-                       /* TRANSLATORS: make sure this matches
-                          "HEAD detached from " in wt-status.c */
+                       /*
+                        * TRANSLATORS: make sure this matches "HEAD
+                        * detached from " in wt-status.c
+                        */
                        strbuf_addf(&desc, _("(HEAD detached from %s)"),
                                state.detached_from);
        }
@@@ -1300,7 -1297,7 +1304,7 @@@ static void populate_value(struct ref_a
        struct object *obj;
        int eaten, i;
        unsigned long size;
 -      const unsigned char *tagged;
 +      const struct object_id *tagged;
  
        ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
  
                                v->s = xstrdup(buf + 1);
                        }
                        continue;
 -              } else if (!deref && grab_objectname(name, ref->objectname, v, atom)) {
 +              } else if (!deref && grab_objectname(name, ref->objectname.hash, v, atom)) {
                        continue;
                } else if (!strcmp(name, "HEAD")) {
 -                      const char *head;
 -                      unsigned char sha1[20];
 -
 -                      head = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
 -                                                sha1, NULL);
 -                      if (head && !strcmp(ref->refname, head))
 +                      if (atom->u.head && !strcmp(ref->refname, atom->u.head))
                                v->s = "*";
                        else
                                v->s = " ";
        return;
  
   need_obj:
 -      buf = get_obj(ref->objectname, &obj, &size, &eaten);
 +      buf = get_obj(&ref->objectname, &obj, &size, &eaten);
        if (!buf)
                die(_("missing object %s for %s"),
 -                  sha1_to_hex(ref->objectname), ref->refname);
 +                  oid_to_hex(&ref->objectname), ref->refname);
        if (!obj)
                die(_("parse_object_buffer failed on %s for %s"),
 -                  sha1_to_hex(ref->objectname), ref->refname);
 +                  oid_to_hex(&ref->objectname), ref->refname);
  
        grab_values(ref->value, 0, obj, buf, size);
        if (!eaten)
         * If it is a tag object, see if we use a value that derefs
         * the object, and if we do grab the object it refers to.
         */
 -      tagged = ((struct tag *)obj)->tagged->oid.hash;
 +      tagged = &((struct tag *)obj)->tagged->oid;
  
        /*
         * NEEDSWORK: This derefs tag only once, which
        buf = get_obj(tagged, &obj, &size, &eaten);
        if (!buf)
                die(_("missing object %s for %s"),
 -                  sha1_to_hex(tagged), ref->refname);
 +                  oid_to_hex(tagged), ref->refname);
        if (!obj)
                die(_("parse_object_buffer failed on %s for %s"),
 -                  sha1_to_hex(tagged), ref->refname);
 +                  oid_to_hex(tagged), ref->refname);
        grab_values(ref->value, 1, obj, buf, size);
        if (!eaten)
                free(buf);
@@@ -1689,7 -1691,7 +1693,7 @@@ static const struct object_id *match_po
  
        if (oid_array_lookup(points_at, oid) >= 0)
                return oid;
 -      obj = parse_object(oid->hash);
 +      obj = parse_object(oid);
        if (!obj)
                die(_("malformed object at '%s'"), refname);
        if (obj->type == OBJ_TAG)
@@@ -1706,7 -1708,7 +1710,7 @@@ static struct ref_array_item *new_ref_a
  {
        struct ref_array_item *ref;
        FLEX_ALLOC_STR(ref, refname, refname);
 -      hashcpy(ref->objectname, objectname);
 +      hashcpy(ref->objectname.hash, objectname);
        ref->flag = flag;
  
        return ref;
@@@ -1784,7 -1786,7 +1788,7 @@@ static int ref_filter_handler(const cha
         * non-commits early. The actual filtering is done later.
         */
        if (filter->merge_commit || filter->with_commit || filter->no_commit || filter->verbose) {
 -              commit = lookup_commit_reference_gently(oid->hash, 1);
 +              commit = lookup_commit_reference_gently(oid, 1);
                if (!commit)
                        return 0;
                /* We perform the filtering for the '--contains' option... */
@@@ -1943,9 -1945,9 +1947,9 @@@ static int cmp_ref_sorting(struct ref_s
        else if (cmp_type == FIELD_STR)
                cmp = cmp_fn(va->s, vb->s);
        else {
 -              if (va->ul < vb->ul)
 +              if (va->value < vb->value)
                        cmp = -1;
 -              else if (va->ul == vb->ul)
 +              else if (va->value == vb->value)
                        cmp = cmp_fn(a->refname, b->refname);
                else
                        cmp = 1;
@@@ -2092,7 -2094,7 +2096,7 @@@ int parse_opt_ref_sorting(const struct 
  int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
  {
        struct ref_filter *rf = opt->value;
 -      unsigned char sha1[20];
 +      struct object_id oid;
        int no_merged = starts_with(opt->long_name, "no");
  
        if (rf->merge) {
                ? REF_FILTER_MERGED_OMIT
                : REF_FILTER_MERGED_INCLUDE;
  
 -      if (get_sha1(arg, sha1))
 +      if (get_oid(arg, &oid))
                die(_("malformed object name %s"), arg);
  
 -      rf->merge_commit = lookup_commit_reference_gently(sha1, 0);
 +      rf->merge_commit = lookup_commit_reference_gently(&oid, 0);
        if (!rf->merge_commit)
                return opterror(opt, "must point to a commit", 0);
  
diff --combined sequencer.c
index a23b948ac148304dbebfe38955ec8b40cab3e1e5,b77f359ca294aa5c5e929a14a1af46a874c3ae68..924fb1d0c3c84dd823393d7dea21af2d70a8d54e
@@@ -344,7 -344,7 +344,7 @@@ static int read_oneliner(struct strbuf 
  
  static struct tree *empty_tree(void)
  {
 -      return lookup_tree(EMPTY_TREE_SHA1_BIN);
 +      return lookup_tree(&empty_tree_oid);
  }
  
  static int error_dirty_index(struct replay_opts *opts)
@@@ -374,7 -374,7 +374,7 @@@ static void update_abort_safety_file(vo
                write_file(git_path_abort_safety_file(), "%s", "");
  }
  
 -static int fast_forward_to(const unsigned char *to, const unsigned char *from,
 +static int fast_forward_to(const struct object_id *to, const struct object_id *from,
                        int unborn, struct replay_opts *opts)
  {
        struct ref_transaction *transaction;
        transaction = ref_transaction_begin(&err);
        if (!transaction ||
            ref_transaction_update(transaction, "HEAD",
 -                                 to, unborn ? null_sha1 : from,
 +                                 to->hash, unborn ? null_sha1 : from->hash,
                                   0, sb.buf, &err) ||
            ref_transaction_commit(transaction, &err)) {
                ref_transaction_free(transaction);
@@@ -426,7 -426,7 +426,7 @@@ void append_conflicts_hint(struct strbu
  
  static int do_recursive_merge(struct commit *base, struct commit *next,
                              const char *base_label, const char *next_label,
 -                            unsigned char *head, struct strbuf *msgbuf,
 +                            struct object_id *head, struct strbuf *msgbuf,
                              struct replay_opts *opts)
  {
        struct merge_options o;
  
        if (active_cache_changed &&
            write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
-               /* TRANSLATORS: %s will be "revert", "cherry-pick" or
+               /*
+                * TRANSLATORS: %s will be "revert", "cherry-pick" or
                 * "rebase -i".
                 */
                return error(_("%s: Unable to write new index file"),
  
  static int is_index_unchanged(void)
  {
 -      unsigned char head_sha1[20];
 +      struct object_id head_oid;
        struct commit *head_commit;
  
 -      if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_sha1, NULL))
 +      if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL))
                return error(_("could not resolve HEAD commit\n"));
  
 -      head_commit = lookup_commit(head_sha1);
 +      head_commit = lookup_commit(&head_oid);
  
        /*
         * If head_commit is NULL, check_commit, called from
                if (cache_tree_update(&the_index, 0))
                        return error(_("unable to update cache tree\n"));
  
 -      return !hashcmp(active_cache_tree->sha1, head_commit->tree->object.oid.hash);
 +      return !oidcmp(&active_cache_tree->oid,
 +                     &head_commit->tree->object.oid);
  }
  
  static int write_author_script(const char *message)
@@@ -835,13 -835,13 +836,13 @@@ static int update_squash_messages(enum 
                strbuf_splice(&buf, 0, eol - buf.buf, header.buf, header.len);
                strbuf_release(&header);
        } else {
 -              unsigned char head[20];
 +              struct object_id head;
                struct commit *head_commit;
                const char *head_message, *body;
  
 -              if (get_sha1("HEAD", head))
 +              if (get_oid("HEAD", &head))
                        return error(_("need a HEAD to fixup"));
 -              if (!(head_commit = lookup_commit_reference(head)))
 +              if (!(head_commit = lookup_commit_reference(&head)))
                        return error(_("could not read HEAD"));
                if (!(head_message = get_commit_buffer(head_commit, NULL)))
                        return error(_("could not read HEAD's commit message"));
@@@ -935,7 -935,7 +936,7 @@@ static int do_pick_commit(enum todo_com
  {
        unsigned int flags = opts->edit ? EDIT_MSG : 0;
        const char *msg_file = opts->edit ? NULL : git_path_merge_msg();
 -      unsigned char head[20];
 +      struct object_id head;
        struct commit *base, *next, *parent;
        const char *base_label, *next_label;
        struct commit_message msg = { NULL, NULL, NULL, NULL };
                 * that represents the "current" state for merge-recursive
                 * to work on.
                 */
 -              if (write_cache_as_tree(head, 0, NULL))
 +              if (write_cache_as_tree(head.hash, 0, NULL))
                        return error(_("your index file is unmerged."));
        } else {
 -              unborn = get_sha1("HEAD", head);
 +              unborn = get_oid("HEAD", &head);
                if (unborn)
 -                      hashcpy(head, EMPTY_TREE_SHA1_BIN);
 +                      oidcpy(&head, &empty_tree_oid);
                if (index_differs_from(unborn ? EMPTY_TREE_SHA1_HEX : "HEAD", 0, 0))
                        return error_dirty_index(opts);
        }
                        oid_to_hex(&commit->object.oid));
  
        if (opts->allow_ff && !is_fixup(command) &&
 -          ((parent && !hashcmp(parent->object.oid.hash, head)) ||
 +          ((parent && !oidcmp(&parent->object.oid, &head)) ||
             (!parent && unborn))) {
                if (is_rebase_i(opts))
                        write_author_script(msg.message);
 -              res = fast_forward_to(commit->object.oid.hash, head, unborn,
 +              res = fast_forward_to(&commit->object.oid, &head, unborn,
                        opts);
                if (res || command != TODO_REWORD)
                        goto leave;
                        strbuf_addstr(&msgbuf, p);
  
                if (opts->record_origin) {
 +                      strbuf_complete_line(&msgbuf);
                        if (!has_conforming_footer(&msgbuf, NULL, 0))
                                strbuf_addch(&msgbuf, '\n');
                        strbuf_addstr(&msgbuf, cherry_picked_prefix);
                res = -1;
        else if (!opts->strategy || !strcmp(opts->strategy, "recursive") || command == TODO_REVERT) {
                res = do_recursive_merge(base, next, base_label, next_label,
 -                                       head, &msgbuf, opts);
 +                                       &head, &msgbuf, opts);
                if (res < 0)
                        return res;
                res |= write_message(msgbuf.buf, msgbuf.len,
                commit_list_insert(next, &remotes);
                res |= try_merge_command(opts->strategy,
                                         opts->xopts_nr, (const char **)opts->xopts,
 -                                      common, sha1_to_hex(head), remotes);
 +                                      common, oid_to_hex(&head), remotes);
                free_commit_list(common);
                free_commit_list(remotes);
        }
@@@ -1223,7 -1222,7 +1224,7 @@@ static struct todo_item *append_new_tod
  
  static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)
  {
 -      unsigned char commit_sha1[20];
 +      struct object_id commit_oid;
        char *end_of_object_name;
        int i, saved, status, padding;
  
        end_of_object_name = (char *) bol + strcspn(bol, " \t\n");
        saved = *end_of_object_name;
        *end_of_object_name = '\0';
 -      status = get_sha1(bol, commit_sha1);
 +      status = get_oid(bol, &commit_oid);
        *end_of_object_name = saved;
  
        item->arg = end_of_object_name + strspn(end_of_object_name, " \t");
        if (status < 0)
                return -1;
  
 -      item->commit = lookup_commit_reference(commit_sha1);
 +      item->commit = lookup_commit_reference(&commit_oid);
        return !item->commit;
  }
  
@@@ -1915,13 -1914,11 +1916,13 @@@ static int apply_autostash(struct repla
        strbuf_trim(&stash_sha1);
  
        child.git_cmd = 1;
 +      child.no_stdout = 1;
 +      child.no_stderr = 1;
        argv_array_push(&child.args, "stash");
        argv_array_push(&child.args, "apply");
        argv_array_push(&child.args, stash_sha1.buf);
        if (!run_command(&child))
 -              printf(_("Applied autostash."));
 +              printf(_("Applied autostash.\n"));
        else {
                struct child_process store = CHILD_PROCESS_INIT;
  
@@@ -2092,7 -2089,6 +2093,7 @@@ cleanup_head_ref
                                res = error(_("could not read orig-head"));
                                goto cleanup_head_ref;
                        }
 +                      strbuf_reset(&buf);
                        if (!read_oneliner(&buf, rebase_path_onto(), 0)) {
                                res = error(_("could not read 'onto'"));
                                goto cleanup_head_ref;
@@@ -2285,7 -2281,7 +2286,7 @@@ static int single_pick(struct commit *c
  int sequencer_pick_revisions(struct replay_opts *opts)
  {
        struct todo_list todo_list = TODO_LIST_INIT;
 -      unsigned char sha1[20];
 +      struct object_id oid;
        int i, res;
  
        assert(opts->revs);
                return -1;
  
        for (i = 0; i < opts->revs->pending.nr; i++) {
 -              unsigned char sha1[20];
 +              struct object_id oid;
                const char *name = opts->revs->pending.objects[i].name;
  
                /* This happens when using --stdin. */
                if (!strlen(name))
                        continue;
  
 -              if (!get_sha1(name, sha1)) {
 -                      if (!lookup_commit_reference_gently(sha1, 1)) {
 -                              enum object_type type = sha1_object_info(sha1, NULL);
 +              if (!get_oid(name, &oid)) {
 +                      if (!lookup_commit_reference_gently(&oid, 1)) {
 +                              enum object_type type = sha1_object_info(oid.hash, NULL);
                                return error(_("%s: can't cherry-pick a %s"),
                                        name, typename(type));
                        }
        if (walk_revs_populate_todo(&todo_list, opts) ||
                        create_seq_dir() < 0)
                return -1;
 -      if (get_sha1("HEAD", sha1) && (opts->action == REPLAY_REVERT))
 +      if (get_oid("HEAD", &oid) && (opts->action == REPLAY_REVERT))
                return error(_("can't revert as initial commit"));
 -      if (save_head(sha1_to_hex(sha1)))
 +      if (save_head(oid_to_hex(&oid)))
                return -1;
        if (save_opts(opts))
                return -1;
@@@ -2362,9 -2358,6 +2363,9 @@@ void append_signoff(struct strbuf *msgb
                                getenv("GIT_COMMITTER_EMAIL")));
        strbuf_addch(&sob, '\n');
  
 +      if (!ignore_footer)
 +              strbuf_complete_line(msgbuf);
 +
        /*
         * If the whole message buffer is equal to the sob, pretend that we
         * found a conforming footer with a matching sob
                         * the title and body to be filled in by the user.
                         */
                        append_newlines = "\n\n";
 -              } else if (msgbuf->buf[len - 1] != '\n') {
 -                      /*
 -                       * Incomplete line.  Complete the line and add a
 -                       * blank one so that there is an empty line between
 -                       * the message body and the sob.
 -                       */
 -                      append_newlines = "\n\n";
                } else if (len == 1) {
                        /*
                         * Buffer contains a single newline.  Add another