Merge branch 'bc/cocci'
authorJunio C Hamano <gitster@pobox.com>
Tue, 19 Jul 2016 20:22:16 +0000 (13:22 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 Jul 2016 20:22:16 +0000 (13:22 -0700)
Conversion from unsigned char sha1[20] to struct object_id
continues.

* bc/cocci:
diff: convert prep_temp_blob() to struct object_id
merge-recursive: convert merge_recursive_generic() to object_id
merge-recursive: convert leaf functions to use struct object_id
merge-recursive: convert struct merge_file_info to object_id
merge-recursive: convert struct stage_data to use object_id
diff: rename struct diff_filespec's sha1_valid member
diff: convert struct diff_filespec to struct object_id
coccinelle: apply object_id Coccinelle transformations
coccinelle: convert hashcpy() with null_sha1 to hashclr()
contrib/coccinelle: add basic Coccinelle transforms
hex: add oid_to_hex_r()

12 files changed:
1  2 
bisect.c
builtin/blame.c
builtin/merge.c
builtin/reset.c
cache.h
combine-diff.c
diff.c
line-log.c
notes-merge.c
submodule-config.c
submodule.c
wt-status.c
diff --combined bisect.c
index b2a75c60cfb292f750a69af900aada69cabb6fa6,ff147589c7f4520f8f9f9a228fb4952d84da9693..47cccdfb0dae4a4a4bc09461c00f0d46db9c3c81
+++ b/bisect.c
@@@ -438,12 -438,12 +438,12 @@@ static void read_bisect_paths(struct ar
        FILE *fp = fopen(filename, "r");
  
        if (!fp)
 -              die_errno("Could not open file '%s'", filename);
 +              die_errno(_("Could not open file '%s'"), filename);
  
        while (strbuf_getline_lf(&str, fp) != EOF) {
                strbuf_trim(&str);
                if (sq_dequote_to_argv_array(str.buf, array))
 -                      die("Badly quoted content in file '%s': %s",
 +                      die(_("Badly quoted content in file '%s': %s"),
                            filename, str.buf);
        }
  
@@@ -649,7 -649,7 +649,7 @@@ static void exit_if_skipped_commits(str
        print_commit_list(tried, "%s\n", "%s\n");
        if (bad)
                printf("%s\n", oid_to_hex(bad));
 -      printf("We cannot bisect more!\n");
 +      printf(_("We cannot bisect more!\n"));
        exit(2);
  }
  
@@@ -702,7 -702,7 +702,7 @@@ static struct commit *get_commit_refere
  {
        struct commit *r = lookup_commit_reference(sha1);
        if (!r)
 -              die("Not a valid commit name %s", sha1_to_hex(sha1));
 +              die(_("Not a valid commit name %s"), sha1_to_hex(sha1));
        return r;
  }
  
@@@ -726,27 -726,27 +726,27 @@@ static void handle_bad_merge_base(void
                char *bad_hex = oid_to_hex(current_bad_oid);
                char *good_hex = join_sha1_array_hex(&good_revs, ' ');
                if (!strcmp(term_bad, "bad") && !strcmp(term_good, "good")) {
 -                      fprintf(stderr, "The merge base %s is bad.\n"
 +                      fprintf(stderr, _("The merge base %s is bad.\n"
                                "This means the bug has been fixed "
 -                              "between %s and [%s].\n",
 +                              "between %s and [%s].\n"),
                                bad_hex, bad_hex, good_hex);
                } else if (!strcmp(term_bad, "new") && !strcmp(term_good, "old")) {
 -                      fprintf(stderr, "The merge base %s is new.\n"
 +                      fprintf(stderr, _("The merge base %s is new.\n"
                                "The property has changed "
 -                              "between %s and [%s].\n",
 +                              "between %s and [%s].\n"),
                                bad_hex, bad_hex, good_hex);
                } else {
 -                      fprintf(stderr, "The merge base %s is %s.\n"
 +                      fprintf(stderr, _("The merge base %s is %s.\n"
                                "This means the first '%s' commit is "
 -                              "between %s and [%s].\n",
 +                              "between %s and [%s].\n"),
                                bad_hex, term_bad, term_good, bad_hex, good_hex);
                }
                exit(3);
        }
  
 -      fprintf(stderr, "Some %s revs are not ancestor of the %s rev.\n"
 +      fprintf(stderr, _("Some %s revs are not ancestor of the %s rev.\n"
                "git bisect cannot work properly in this case.\n"
 -              "Maybe you mistook %s and %s revs?\n",
 +              "Maybe you mistook %s and %s revs?\n"),
                term_good, term_bad, term_good, term_bad);
        exit(1);
  }
  static void handle_skipped_merge_base(const unsigned char *mb)
  {
        char *mb_hex = sha1_to_hex(mb);
-       char *bad_hex = sha1_to_hex(current_bad_oid->hash);
+       char *bad_hex = oid_to_hex(current_bad_oid);
        char *good_hex = join_sha1_array_hex(&good_revs, ' ');
  
 -      warning("the merge base between %s and [%s] "
 +      warning(_("the merge base between %s and [%s] "
                "must be skipped.\n"
                "So we cannot be sure the first %s commit is "
                "between %s and %s.\n"
 -              "We continue anyway.",
 +              "We continue anyway."),
                bad_hex, good_hex, term_bad, mb_hex, bad_hex);
        free(good_hex);
  }
@@@ -792,7 -792,7 +792,7 @@@ static void check_merge_bases(int no_ch
                } else if (0 <= sha1_array_lookup(&skipped_revs, mb)) {
                        handle_skipped_merge_base(mb);
                } else {
 -                      printf("Bisecting: a merge base must be tested\n");
 +                      printf(_("Bisecting: a merge base must be tested\n"));
                        exit(bisect_checkout(mb, no_checkout));
                }
        }
@@@ -843,7 -843,7 +843,7 @@@ static void check_good_are_ancestors_of
        int fd;
  
        if (!current_bad_oid)
 -              die("a %s revision is needed", term_bad);
 +              die(_("a %s revision is needed"), term_bad);
  
        /* Check if file BISECT_ANCESTORS_OK exists. */
        if (!stat(filename, &st) && S_ISREG(st.st_mode))
        /* Create file BISECT_ANCESTORS_OK. */
        fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);
        if (fd < 0)
 -              warning_errno("could not create file '%s'",
 +              warning_errno(_("could not create file '%s'"),
                              filename);
        else
                close(fd);
@@@ -890,7 -890,6 +890,7 @@@ static void show_diff_tree(const char *
        if (!opt.diffopt.output_format)
                opt.diffopt.output_format = DIFF_FORMAT_RAW;
  
 +      setup_revisions(0, NULL, &opt, NULL);
        log_tree_commit(&opt, commit);
  }
  
@@@ -911,7 -910,7 +911,7 @@@ void read_bisect_terms(const char **rea
                        *read_good = "good";
                        return;
                } else {
 -                      die_errno("could not read file '%s'", filename);
 +                      die_errno(_("could not read file '%s'"), filename);
                }
        } else {
                strbuf_getline_lf(&str, fp);
@@@ -937,11 -936,10 +937,11 @@@ int bisect_next_all(const char *prefix
        struct commit_list *tried;
        int reaches = 0, all = 0, nr, steps;
        const unsigned char *bisect_rev;
 +      char steps_msg[32];
  
        read_bisect_terms(&term_bad, &term_good);
        if (read_bisect_refs())
 -              die("reading bisect refs failed");
 +              die(_("reading bisect refs failed"));
  
        check_good_are_ancestors_of_bad(prefix, no_checkout);
  
                 */
                exit_if_skipped_commits(tried, NULL);
  
 -              printf("%s was both %s and %s\n",
 +              printf(_("%s was both %s and %s\n"),
                       oid_to_hex(current_bad_oid),
                       term_good,
                       term_bad);
        }
  
        if (!all) {
 -              fprintf(stderr, "No testable commit found.\n"
 -                      "Maybe you started with bad path parameters?\n");
 +              fprintf(stderr, _("No testable commit found.\n"
 +                      "Maybe you started with bad path parameters?\n"));
                exit(4);
        }
  
  
        nr = all - reaches - 1;
        steps = estimate_bisect_steps(all);
 -      printf("Bisecting: %d revision%s left to test after this "
 -             "(roughly %d step%s)\n", nr, (nr == 1 ? "" : "s"),
 -             steps, (steps == 1 ? "" : "s"));
 +      xsnprintf(steps_msg, sizeof(steps_msg),
 +                Q_("(roughly %d step)", "(roughly %d steps)", steps),
 +                steps);
 +      /* 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);
  
        return bisect_checkout(bisect_rev, no_checkout);
  }
diff --combined builtin/blame.c
index 2ed83e16b63cf11435ba156a6dc201df0f46b4f8,04bc4e0eb169694cf46ab062639b70cc2f2cb1cd..8fec0e1fb31f2a71f523a4a9fd21b4b6c5fa3362
@@@ -56,7 -56,7 +56,7 @@@ static int show_progress
  static struct date_mode blame_date_mode = { DATE_ISO8601 };
  static size_t blame_date_width;
  
 -static struct string_list mailmap;
 +static struct string_list mailmap = STRING_LIST_INIT_NODUP;
  
  #ifndef DEBUG
  #define DEBUG 0
@@@ -134,7 -134,7 +134,7 @@@ struct progress_info 
        int blamed_lines;
  };
  
 -static int diff_hunks(mmfile_t *file_a, mmfile_t *file_b, long ctxlen,
 +static int diff_hunks(mmfile_t *file_a, mmfile_t *file_b,
                      xdl_emit_hunk_consume_func_t hunk_func, void *cb_data)
  {
        xpparam_t xpp = {0};
        xdemitcb_t ecb = {NULL};
  
        xpp.flags = xdl_opts;
 -      xecfg.ctxlen = ctxlen;
        xecfg.hunk_func = hunk_func;
        ecb.priv = cb_data;
        return xdi_diff(file_a, file_b, &xpp, &xecfg, &ecb);
@@@ -598,7 -599,7 +598,7 @@@ static struct origin *find_origin(struc
                            p->status);
                case 'M':
                        porigin = get_origin(sb, parent, origin->path);
-                       hashcpy(porigin->blob_sha1, p->one->sha1);
+                       hashcpy(porigin->blob_sha1, p->one->oid.hash);
                        porigin->mode = p->one->mode;
                        break;
                case 'A':
                }
        }
        diff_flush(&diff_opts);
 -      free_pathspec(&diff_opts.pathspec);
 +      clear_pathspec(&diff_opts.pathspec);
        return porigin;
  }
  
@@@ -644,13 -645,13 +644,13 @@@ static struct origin *find_rename(struc
                if ((p->status == 'R' || p->status == 'C') &&
                    !strcmp(p->two->path, origin->path)) {
                        porigin = get_origin(sb, parent, p->one->path);
-                       hashcpy(porigin->blob_sha1, p->one->sha1);
+                       hashcpy(porigin->blob_sha1, p->one->oid.hash);
                        porigin->mode = p->one->mode;
                        break;
                }
        }
        diff_flush(&diff_opts);
 -      free_pathspec(&diff_opts.pathspec);
 +      clear_pathspec(&diff_opts.pathspec);
        return porigin;
  }
  
@@@ -979,7 -980,7 +979,7 @@@ static void pass_blame_to_parent(struc
        fill_origin_blob(&sb->revs->diffopt, target, &file_o);
        num_get_patch++;
  
 -      if (diff_hunks(&file_p, &file_o, 0, blame_chunk_cb, &d))
 +      if (diff_hunks(&file_p, &file_o, blame_chunk_cb, &d))
                die("unable to generate diff (%s -> %s)",
                    oid_to_hex(&parent->commit->object.oid),
                    oid_to_hex(&target->commit->object.oid));
@@@ -1128,7 -1129,7 +1128,7 @@@ static void find_copy_in_blob(struct sc
         * file_p partially may match that image.
         */
        memset(split, 0, sizeof(struct blame_entry [3]));
 -      if (diff_hunks(file_p, &file_o, 1, handle_split_cb, &d))
 +      if (diff_hunks(file_p, &file_o, handle_split_cb, &d))
                die("unable to generate diff (%s)",
                    oid_to_hex(&parent->commit->object.oid));
        /* remainder, if any, all match the preimage */
@@@ -1308,7 -1309,7 +1308,7 @@@ static void find_copy_in_parent(struct 
                                continue;
  
                        norigin = get_origin(sb, parent, p->one->path);
-                       hashcpy(norigin->blob_sha1, p->one->sha1);
+                       hashcpy(norigin->blob_sha1, p->one->oid.hash);
                        norigin->mode = p->one->mode;
                        fill_origin_blob(&sb->revs->diffopt, norigin, &file_p);
                        if (!file_p.ptr)
        } while (unblamed);
        target->suspects = reverse_blame(leftover, NULL);
        diff_flush(&diff_opts);
 -      free_pathspec(&diff_opts.pathspec);
 +      clear_pathspec(&diff_opts.pathspec);
  }
  
  /*
@@@ -2424,7 -2425,8 +2424,7 @@@ static struct commit *find_single_final
                struct object *obj = revs->pending.objects[i].item;
                if (obj->flags & UNINTERESTING)
                        continue;
 -              while (obj->type == OBJ_TAG)
 -                      obj = deref_tag(obj, NULL, 0);
 +              obj = deref_tag(obj, NULL, 0);
                if (obj->type != OBJ_COMMIT)
                        die("Non commit %s?", revs->pending.objects[i].name);
                if (found)
@@@ -2459,7 -2461,8 +2459,7 @@@ static char *prepare_initial(struct sco
                struct object *obj = revs->pending.objects[i].item;
                if (!(obj->flags & UNINTERESTING))
                        continue;
 -              while (obj->type == OBJ_TAG)
 -                      obj = deref_tag(obj, NULL, 0);
 +              obj = deref_tag(obj, NULL, 0);
                if (obj->type != OBJ_COMMIT)
                        die("Non commit %s?", revs->pending.objects[i].name);
                if (sb->final)
@@@ -2519,12 -2522,12 +2519,12 @@@ int cmd_blame(int argc, const char **ar
        enum object_type type;
        struct commit *final_commit = NULL;
  
 -      static struct string_list range_list;
 -      static int output_option = 0, opt = 0;
 -      static int show_stats = 0;
 -      static const char *revs_file = NULL;
 -      static const char *contents_from = NULL;
 -      static const struct option options[] = {
 +      struct string_list range_list = STRING_LIST_INIT_NODUP;
 +      int output_option = 0, opt = 0;
 +      int show_stats = 0;
 +      const char *revs_file = NULL;
 +      const char *contents_from = NULL;
 +      const struct option options[] = {
                OPT_BOOL(0, "incremental", &incremental, N_("Show blame entries as we find them, incrementally")),
                OPT_BOOL('b', NULL, &blank_boundary, N_("Show blank SHA-1 for boundary commits (Default: off)")),
                OPT_BOOL(0, "root", &show_root, N_("Do not treat root commits as boundaries (Default: off)")),
diff --combined builtin/merge.c
index d82f6c19a350e72edd4dc03e30ff65d8c98d8ecb,f66d06ce25f12a8ae0d5356f21c531036b9f7d98..0dfe09eb1922750cdbf0d7cf3a4fd21b94a05cb5
@@@ -211,7 -211,7 +211,7 @@@ static struct option builtin_merge_opti
                PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, FF_ONLY },
        OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
        OPT_BOOL(0, "verify-signatures", &verify_signatures,
 -              N_("Verify that the named commit has a valid GPG signature")),
 +              N_("verify that the named commit has a valid GPG signature")),
        OPT_CALLBACK('s', "strategy", &use_strategies, N_("strategy"),
                N_("merge strategy to use"), option_parse_strategy),
        OPT_CALLBACK('X', "strategy-option", &xopts, N_("option=value"),
@@@ -501,7 -501,7 +501,7 @@@ static void merge_name(const char *remo
                if (ref_exists(truname.buf)) {
                        strbuf_addf(msg,
                                    "%s\t\tbranch '%s'%s of .\n",
-                                   sha1_to_hex(remote_head->object.oid.hash),
+                                   oid_to_hex(&remote_head->object.oid),
                                    truname.buf + 11,
                                    (early ? " (early part)" : ""));
                        strbuf_release(&truname);
                desc = merge_remote_util(remote_head);
                if (desc && desc->obj && desc->obj->type == OBJ_TAG) {
                        strbuf_addf(msg, "%s\t\t%s '%s'\n",
-                                   sha1_to_hex(desc->obj->oid.hash),
+                                   oid_to_hex(&desc->obj->oid),
                                    typename(desc->obj->type),
                                    remote);
                        goto cleanup;
        }
  
        strbuf_addf(msg, "%s\t\tcommit '%s'\n",
-               sha1_to_hex(remote_head->object.oid.hash), remote);
+               oid_to_hex(&remote_head->object.oid), remote);
  cleanup:
        strbuf_release(&buf);
        strbuf_release(&bname);
@@@ -1014,7 -1014,7 +1014,7 @@@ static int default_edit_option(void
        if (e) {
                int v = git_config_maybe_bool(name, e);
                if (v < 0)
 -                      die("Bad value '%s' in environment '%s'", e, name);
 +                      die(_("Bad value '%s' in environment '%s'"), e, name);
                return v;
        }
  
@@@ -1115,7 -1115,7 +1115,7 @@@ static void handle_fetch_head(struct co
                if (!commit) {
                        if (ptr)
                                *ptr = '\0';
 -                      die("not something we can merge in %s: %s",
 +                      die(_("not something we can merge in %s: %s"),
                            filename, merge_names->buf + pos);
                }
                remotes = &commit_list_insert(commit, remotes)->next;
@@@ -1149,7 -1149,7 +1149,7 @@@ static struct commit_list *collect_pare
                        struct commit *commit = get_merge_parent(argv[i]);
                        if (!commit)
                                help_unknown_ref(argv[i], "merge",
 -                                               "not something we can merge");
 +                                               _("not something we can merge"));
                        remotes = &commit_list_insert(commit, remotes)->next;
                }
                remoteheads = reduce_parents(head_commit, head_subsumed, remoteheads);
@@@ -1366,7 -1366,7 +1366,7 @@@ int cmd_merge(int argc, const char **ar
        for (p = remoteheads; p; p = p->next) {
                struct commit *commit = p->item;
                strbuf_addf(&buf, "GITHEAD_%s",
-                           sha1_to_hex(commit->object.oid.hash));
+                           oid_to_hex(&commit->object.oid));
                setenv(buf.buf, merge_remote_util(commit)->name, 1);
                strbuf_reset(&buf);
                if (fast_forward != FF_ONLY &&
                 * If head can reach all the merge then we are up to date.
                 * but first the most common case of merging one remote.
                 */
 -              finish_up_to_date("Already up-to-date.");
 +              finish_up_to_date(_("Already up-to-date."));
                goto done;
        } else if (fast_forward != FF_NO && !remoteheads->next &&
                        !common->next &&
-                       !hashcmp(common->item->object.oid.hash, head_commit->object.oid.hash)) {
+                       !oidcmp(&common->item->object.oid, &head_commit->object.oid)) {
                /* Again the most common case of merging one remote. */
                struct strbuf msg = STRBUF_INIT;
                struct commit *commit;
                         * HEAD^^" would be missed.
                         */
                        common_one = get_merge_bases(head_commit, j->item);
-                       if (hashcmp(common_one->item->object.oid.hash,
-                               j->item->object.oid.hash)) {
+                       if (oidcmp(&common_one->item->object.oid, &j->item->object.oid)) {
                                up_to_date = 0;
                                break;
                        }
                }
                if (up_to_date) {
 -                      finish_up_to_date("Already up-to-date. Yeeah!");
 +                      finish_up_to_date(_("Already up-to-date. Yeeah!"));
                        goto done;
                }
        }
             * Stash away the local changes so that we can try more than one.
             */
            save_state(stash))
-               hashcpy(stash, null_sha1);
+               hashclr(stash);
  
        for (i = 0; i < use_strategies_nr; i++) {
                int ret;
diff --combined builtin/reset.c
index 5c6206bc1c40dd1ac7081896232910be95d13977,cce64b53c09ae9d4de3ce8621be67a8a1ed6c5e7..9020ec66c81de0185244d478e588d4a05c2a4f1d
@@@ -103,7 -103,7 +103,7 @@@ static void print_new_head_line(struct 
        if (body) {
                const char *eol;
                size_t len;
 -              body += 2;
 +              body = skip_blank_lines(body + 2);
                eol = strchr(body, '\n');
                len = eol ? eol - body : strlen(body);
                printf(" %.*s\n", (int) len, body);
@@@ -121,7 -121,7 +121,7 @@@ static void update_index_from_diff(stru
  
        for (i = 0; i < q->nr; i++) {
                struct diff_filespec *one = q->queue[i]->one;
-               int is_missing = !(one->mode && !is_null_sha1(one->sha1));
+               int is_missing = !(one->mode && !is_null_oid(&one->oid));
                struct cache_entry *ce;
  
                if (is_missing && !intent_to_add) {
                        continue;
                }
  
-               ce = make_cache_entry(one->mode, one->sha1, one->path,
+               ce = make_cache_entry(one->mode, one->oid.hash, one->path,
                                      0, 0);
                if (!ce)
                        die(_("make_cache_entry failed for path '%s'"),
@@@ -158,7 -158,7 +158,7 @@@ static int read_from_tree(const struct 
                return 1;
        diffcore_std(&opt);
        diff_flush(&opt);
 -      free_pathspec(&opt.pathspec);
 +      clear_pathspec(&opt.pathspec);
  
        return 0;
  }
diff --combined cache.h
index f1dc289d068f554b73434e9f8bf5d723a3e78519,7bd7c472f8232693afe0d59e562e1016a5a63cb5..a93d1b7f5ddd504afa9d9de8988038e165bf6056
+++ b/cache.h
@@@ -367,8 -367,8 +367,8 @@@ extern void free_name_hash(struct index
  #define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name))
  #define remove_cache_entry_at(pos) remove_index_entry_at(&the_index, (pos))
  #define remove_file_from_cache(path) remove_file_from_index(&the_index, (path))
 -#define add_to_cache(path, st, flags) add_to_index(&the_index, (path), (st), (flags))
 -#define add_file_to_cache(path, flags) add_file_to_index(&the_index, (path), (flags))
 +#define add_to_cache(path, st, flags) add_to_index(&the_index, (path), (st), (flags), 0)
 +#define add_file_to_cache(path, flags) add_file_to_index(&the_index, (path), (flags), 0)
  #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL)
  #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
  #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))
@@@ -581,8 -581,8 +581,8 @@@ extern int remove_file_from_index(struc
  #define ADD_CACHE_IGNORE_ERRORS       4
  #define ADD_CACHE_IGNORE_REMOVAL 8
  #define ADD_CACHE_INTENT 16
 -extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags);
 -extern int add_file_to_index(struct index_state *, const char *path, int flags);
 +extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags, int force_mode);
 +extern int add_file_to_index(struct index_state *, const char *path, int flags, int force_mode);
  extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, unsigned int refresh_options);
  extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);
  extern void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);
@@@ -1193,6 -1193,7 +1193,7 @@@ extern int get_oid_hex(const char *hex
   *   printf("%s -> %s", sha1_to_hex(one), sha1_to_hex(two));
   */
  extern char *sha1_to_hex_r(char *out, const unsigned char *sha1);
+ extern char *oid_to_hex_r(char *out, const struct object_id *oid);
  extern char *sha1_to_hex(const unsigned char *sha1);  /* static buffer result! */
  extern char *oid_to_hex(const struct object_id *oid); /* same static buffer as sha1_to_hex */
  
@@@ -1604,16 -1605,6 +1605,16 @@@ extern const char *get_log_output_encod
  extern const char *get_commit_output_encoding(void);
  
  extern int git_config_parse_parameter(const char *, config_fn_t fn, void *data);
 +
 +enum config_scope {
 +      CONFIG_SCOPE_UNKNOWN = 0,
 +      CONFIG_SCOPE_SYSTEM,
 +      CONFIG_SCOPE_GLOBAL,
 +      CONFIG_SCOPE_REPO,
 +      CONFIG_SCOPE_CMDLINE,
 +};
 +
 +extern enum config_scope current_config_scope(void);
  extern const char *current_config_origin_type(void);
  extern const char *current_config_name(void);
  
@@@ -1706,8 -1697,6 +1707,8 @@@ extern int ignore_untracked_cache_confi
  struct key_value_info {
        const char *filename;
        int linenr;
 +      const char *origin_type;
 +      enum config_scope scope;
  };
  
  extern NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3)));
@@@ -1733,6 -1722,7 +1734,6 @@@ extern int copy_file(const char *dst, c
  extern int copy_file_with_time(const char *dst, const char *src, int mode);
  
  extern void write_or_die(int fd, const void *buf, size_t count);
 -extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg);
  extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg);
  extern void fsync_or_die(int fd, const char *);
  
@@@ -1783,7 -1773,7 +1784,7 @@@ void packet_trace_identity(const char *
   * return 0 if success, 1 - if addition of a file failed and
   * ADD_FILES_IGNORE_ERRORS was specified in flags
   */
 -int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int flags);
 +int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int flags, int force_mode);
  
  /* diff.c */
  extern int diff_auto_refresh_index;
diff --combined combine-diff.c
index 5920df8b8dd12ff382131a6753f40bbdec64fd37,5940dc87070c7e5f8aabbe920341fc5de1959c2c..8e2a577bdb43297c619a1f4322dab9e4a5572d6a
@@@ -44,9 -44,9 +44,9 @@@ static struct combine_diff_path *inters
                        memset(p->parent, 0,
                               sizeof(p->parent[0]) * num_parent);
  
-                       hashcpy(p->oid.hash, q->queue[i]->two->sha1);
+                       oidcpy(&p->oid, &q->queue[i]->two->oid);
                        p->mode = q->queue[i]->two->mode;
-                       hashcpy(p->parent[n].oid.hash, q->queue[i]->one->sha1);
+                       oidcpy(&p->parent[n].oid, &q->queue[i]->one->oid);
                        p->parent[n].mode = q->queue[i]->one->mode;
                        p->parent[n].status = q->queue[i]->status;
                        *tail = p;
@@@ -77,7 -77,7 +77,7 @@@
                        continue;
                }
  
-               hashcpy(p->parent[n].oid.hash, q->queue[i]->one->sha1);
+               oidcpy(&p->parent[n].oid, &q->queue[i]->one->oid);
                p->parent[n].mode = q->queue[i]->one->mode;
                p->parent[n].status = q->queue[i]->status;
  
@@@ -1268,16 -1268,16 +1268,16 @@@ static struct diff_filepair *combined_p
        for (i = 0; i < num_parent; i++) {
                pair->one[i].path = p->path;
                pair->one[i].mode = p->parent[i].mode;
-               hashcpy(pair->one[i].sha1, p->parent[i].oid.hash);
-               pair->one[i].sha1_valid = !is_null_oid(&p->parent[i].oid);
+               oidcpy(&pair->one[i].oid, &p->parent[i].oid);
+               pair->one[i].oid_valid = !is_null_oid(&p->parent[i].oid);
                pair->one[i].has_more_entries = 1;
        }
        pair->one[num_parent - 1].has_more_entries = 0;
  
        pair->two->path = p->path;
        pair->two->mode = p->mode;
-       hashcpy(pair->two->sha1, p->oid.hash);
-       pair->two->sha1_valid = !is_null_oid(&p->oid);
+       oidcpy(&pair->two->oid, &p->oid);
+       pair->two->oid_valid = !is_null_oid(&p->oid);
        return pair;
  }
  
@@@ -1525,7 -1525,7 +1525,7 @@@ void diff_tree_combined(const unsigned 
                free(tmp);
        }
  
 -      free_pathspec(&diffopts.pathspec);
 +      clear_pathspec(&diffopts.pathspec);
  }
  
  void diff_tree_combined_merge(const struct commit *commit, int dense,
diff --combined diff.c
index b66b9beabcf5372463de0c5b2349caef868a8725,8cdfdf32225102a8bfdb15c5e3551ee5956f5911..7d0341988083dae44f8833875762b0b978bbafc0
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -1933,8 -1933,8 +1933,8 @@@ static void show_dirstat(struct diff_op
  
                name = p->two->path ? p->two->path : p->one->path;
  
-               if (p->one->sha1_valid && p->two->sha1_valid)
-                       content_changed = hashcmp(p->one->sha1, p->two->sha1);
+               if (p->one->oid_valid && p->two->oid_valid)
+                       content_changed = oidcmp(&p->one->oid, &p->two->oid);
                else
                        content_changed = 1;
  
@@@ -2306,7 -2306,8 +2306,8 @@@ static void builtin_diff(const char *na
                const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
                show_submodule_summary(o->file, one->path ? one->path : two->path,
                                line_prefix,
-                               one->sha1, two->sha1, two->dirty_submodule,
+                               one->oid.hash, two->oid.hash,
+                               two->dirty_submodule,
                                meta, del, add, reset);
                return;
        }
                if (!one->data && !two->data &&
                    S_ISREG(one->mode) && S_ISREG(two->mode) &&
                    !DIFF_OPT_TST(o, BINARY)) {
-                       if (!hashcmp(one->sha1, two->sha1)) {
+                       if (!oidcmp(&one->oid, &two->oid)) {
                                if (must_show_header)
                                        fprintf(o->file, "%s", header.buf);
                                goto free_ab_and_return;
@@@ -2505,7 -2506,7 +2506,7 @@@ static void builtin_diffstat(const cha
                return;
        }
  
-       same_contents = !hashcmp(one->sha1, two->sha1);
+       same_contents = !oidcmp(&one->oid, &two->oid);
  
        if (diff_filespec_is_binary(one) || diff_filespec_is_binary(two)) {
                data->is_binary = 1;
@@@ -2638,8 -2639,8 +2639,8 @@@ void fill_filespec(struct diff_filespe
  {
        if (mode) {
                spec->mode = canon_mode(mode);
-               hashcpy(spec->sha1, sha1);
-               spec->sha1_valid = sha1_valid;
+               hashcpy(spec->oid.hash, sha1);
+               spec->oid_valid = sha1_valid;
        }
  }
  
@@@ -2721,7 -2722,8 +2722,8 @@@ static int diff_populate_gitlink(struc
        if (s->dirty_submodule)
                dirty = "-dirty";
  
-       strbuf_addf(&buf, "Subproject commit %s%s\n", sha1_to_hex(s->sha1), dirty);
+       strbuf_addf(&buf, "Subproject commit %s%s\n",
+                   oid_to_hex(&s->oid), dirty);
        s->size = buf.len;
        if (size_only) {
                s->data = NULL;
@@@ -2764,8 -2766,8 +2766,8 @@@ int diff_populate_filespec(struct diff_
        if (S_ISGITLINK(s->mode))
                return diff_populate_gitlink(s, size_only);
  
-       if (!s->sha1_valid ||
-           reuse_worktree_file(s->path, s->sha1, 0)) {
+       if (!s->oid_valid ||
+           reuse_worktree_file(s->path, s->oid.hash, 0)) {
                struct strbuf buf = STRBUF_INIT;
                struct stat st;
                int fd;
        else {
                enum object_type type;
                if (size_only || (flags & CHECK_BINARY)) {
-                       type = sha1_object_info(s->sha1, &s->size);
+                       type = sha1_object_info(s->oid.hash, &s->size);
                        if (type < 0)
-                               die("unable to read %s", sha1_to_hex(s->sha1));
+                               die("unable to read %s",
+                                   oid_to_hex(&s->oid));
                        if (size_only)
                                return 0;
                        if (s->size > big_file_threshold && s->is_binary == -1) {
                                return 0;
                        }
                }
-               s->data = read_sha1_file(s->sha1, &type, &s->size);
+               s->data = read_sha1_file(s->oid.hash, &type, &s->size);
                if (!s->data)
-                       die("unable to read %s", sha1_to_hex(s->sha1));
+                       die("unable to read %s", oid_to_hex(&s->oid));
                s->should_free = 1;
        }
        return 0;
@@@ -2863,7 -2866,7 +2866,7 @@@ void diff_free_filespec_data(struct dif
  static void prep_temp_blob(const char *path, struct diff_tempfile *temp,
                           void *blob,
                           unsigned long size,
-                          const unsigned char *sha1,
+                          const struct object_id *oid,
                           int mode)
  {
        int fd;
                die_errno("unable to write temp-file");
        close_tempfile(&temp->tempfile);
        temp->name = get_tempfile_path(&temp->tempfile);
-       sha1_to_hex_r(temp->hex, sha1);
+       oid_to_hex_r(temp->hex, oid);
        xsnprintf(temp->mode, sizeof(temp->mode), "%06o", mode);
        strbuf_release(&buf);
        strbuf_release(&template);
@@@ -2912,8 -2915,8 +2915,8 @@@ static struct diff_tempfile *prepare_te
        }
  
        if (!S_ISGITLINK(one->mode) &&
-           (!one->sha1_valid ||
-            reuse_worktree_file(name, one->sha1, 1))) {
+           (!one->oid_valid ||
+            reuse_worktree_file(name, one->oid.hash, 1))) {
                struct stat st;
                if (lstat(name, &st) < 0) {
                        if (errno == ENOENT)
                        if (strbuf_readlink(&sb, name, st.st_size) < 0)
                                die_errno("readlink(%s)", name);
                        prep_temp_blob(name, temp, sb.buf, sb.len,
-                                      (one->sha1_valid ?
-                                       one->sha1 : null_sha1),
-                                      (one->sha1_valid ?
+                                      (one->oid_valid ?
+                                       &one->oid : &null_oid),
+                                      (one->oid_valid ?
                                        one->mode : S_IFLNK));
                        strbuf_release(&sb);
                }
                else {
                        /* we can borrow from the file in the work tree */
                        temp->name = name;
-                       if (!one->sha1_valid)
+                       if (!one->oid_valid)
                                sha1_to_hex_r(temp->hex, null_sha1);
                        else
-                               sha1_to_hex_r(temp->hex, one->sha1);
+                               sha1_to_hex_r(temp->hex, one->oid.hash);
                        /* Even though we may sometimes borrow the
                         * contents from the work tree, we always want
                         * one->mode.  mode is trustworthy even when
                if (diff_populate_filespec(one, 0))
                        die("cannot read data blob for %s", one->path);
                prep_temp_blob(name, temp, one->data, one->size,
-                              one->sha1, one->mode);
+                              &one->oid, one->mode);
        }
        return temp;
  }
@@@ -3065,7 -3068,7 +3068,7 @@@ static void fill_metainfo(struct strbu
        default:
                *must_show_header = 0;
        }
-       if (one && two && hashcmp(one->sha1, two->sha1)) {
+       if (one && two && oidcmp(&one->oid, &two->oid)) {
                int abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV;
  
                if (DIFF_OPT_TST(o, BINARY)) {
                                abbrev = 40;
                }
                strbuf_addf(msg, "%s%sindex %s..", line_prefix, set,
-                           find_unique_abbrev(one->sha1, abbrev));
-               strbuf_addstr(msg, find_unique_abbrev(two->sha1, abbrev));
+                           find_unique_abbrev(one->oid.hash, abbrev));
+               strbuf_addstr(msg, find_unique_abbrev(two->oid.hash, abbrev));
                if (one->mode == two->mode)
                        strbuf_addf(msg, " %06o", one->mode);
                strbuf_addf(msg, "%s\n", reset);
@@@ -3131,20 -3134,20 +3134,20 @@@ static void run_diff_cmd(const char *pg
  static void diff_fill_sha1_info(struct diff_filespec *one)
  {
        if (DIFF_FILE_VALID(one)) {
-               if (!one->sha1_valid) {
+               if (!one->oid_valid) {
                        struct stat st;
                        if (one->is_stdin) {
-                               hashcpy(one->sha1, null_sha1);
+                               oidclr(&one->oid);
                                return;
                        }
                        if (lstat(one->path, &st) < 0)
                                die_errno("stat '%s'", one->path);
-                       if (index_path(one->sha1, one->path, &st, 0))
+                       if (index_path(one->oid.hash, one->path, &st, 0))
                                die("cannot hash %s", one->path);
                }
        }
        else
-               hashclr(one->sha1);
+               oidclr(&one->oid);
  }
  
  static void strip_prefix(int prefix_length, const char **namep, const char **otherp)
@@@ -3977,8 -3980,6 +3980,8 @@@ int diff_opt_parse(struct diff_options 
                if (!options->file)
                        die_errno("Could not open '%s'", path);
                options->close_file = 1;
 +              if (options->use_color != GIT_COLOR_ALWAYS)
 +                      options->use_color = GIT_COLOR_NEVER;
                return argcount;
        } else
                return 0;
@@@ -4120,8 -4121,9 +4123,9 @@@ static void diff_flush_raw(struct diff_
        fprintf(opt->file, "%s", diff_line_prefix(opt));
        if (!(opt->output_format & DIFF_FORMAT_NAME_STATUS)) {
                fprintf(opt->file, ":%06o %06o %s ", p->one->mode, p->two->mode,
-                       diff_unique_abbrev(p->one->sha1, opt->abbrev));
-               fprintf(opt->file, "%s ", diff_unique_abbrev(p->two->sha1, opt->abbrev));
+                       diff_unique_abbrev(p->one->oid.hash, opt->abbrev));
+               fprintf(opt->file, "%s ",
+                       diff_unique_abbrev(p->two->oid.hash, opt->abbrev));
        }
        if (p->score) {
                fprintf(opt->file, "%c%03d%c", p->status, similarity_index(p),
@@@ -4170,11 -4172,11 +4174,11 @@@ int diff_unmodified_pair(struct diff_fi
        /* both are valid and point at the same path.  that is, we are
         * dealing with a change.
         */
-       if (one->sha1_valid && two->sha1_valid &&
-           !hashcmp(one->sha1, two->sha1) &&
+       if (one->oid_valid && two->oid_valid &&
+           !oidcmp(&one->oid, &two->oid) &&
            !one->dirty_submodule && !two->dirty_submodule)
                return 1; /* no change */
-       if (!one->sha1_valid && !two->sha1_valid)
+       if (!one->oid_valid && !two->oid_valid)
                return 1; /* both look at the same file on the filesystem. */
        return 0;
  }
@@@ -4235,7 -4237,7 +4239,7 @@@ void diff_debug_filespec(struct diff_fi
                s->path,
                DIFF_FILE_VALID(s) ? "valid" : "invalid",
                s->mode,
-               s->sha1_valid ? sha1_to_hex(s->sha1) : "");
+               s->oid_valid ? oid_to_hex(&s->oid) : "");
        fprintf(stderr, "queue[%d] %s size %lu\n",
                x, one ? one : "",
                s->size);
@@@ -4305,11 -4307,11 +4309,11 @@@ static void diff_resolve_rename_copy(vo
                        else
                                p->status = DIFF_STATUS_RENAMED;
                }
-               else if (hashcmp(p->one->sha1, p->two->sha1) ||
+               else if (oidcmp(&p->one->oid, &p->two->oid) ||
                         p->one->mode != p->two->mode ||
                         p->one->dirty_submodule ||
                         p->two->dirty_submodule ||
-                        is_null_sha1(p->one->sha1))
+                        is_null_oid(&p->one->oid))
                        p->status = DIFF_STATUS_MODIFIED;
                else {
                        /* This is a "no-change" entry and should not
@@@ -4525,8 -4527,10 +4529,10 @@@ static int diff_get_patch_id(struct dif
  
                if (diff_filespec_is_binary(p->one) ||
                    diff_filespec_is_binary(p->two)) {
-                       git_SHA1_Update(&ctx, sha1_to_hex(p->one->sha1), 40);
-                       git_SHA1_Update(&ctx, sha1_to_hex(p->two->sha1), 40);
+                       git_SHA1_Update(&ctx, oid_to_hex(&p->one->oid),
+                                       40);
+                       git_SHA1_Update(&ctx, oid_to_hex(&p->two->oid),
+                                       40);
                        continue;
                }
  
@@@ -4818,7 -4822,7 +4824,7 @@@ static int diff_filespec_check_stat_unm
         */
        if (!DIFF_FILE_VALID(p->one) || /* (1) */
            !DIFF_FILE_VALID(p->two) ||
-           (p->one->sha1_valid && p->two->sha1_valid) ||
+           (p->one->oid_valid && p->two->oid_valid) ||
            (p->one->mode != p->two->mode) ||
            diff_populate_filespec(p->one, CHECK_SIZE_ONLY) ||
            diff_populate_filespec(p->two, CHECK_SIZE_ONLY) ||
@@@ -5114,8 -5118,9 +5120,9 @@@ size_t fill_textconv(struct userdiff_dr
        if (!driver->textconv)
                die("BUG: fill_textconv called with non-textconv driver");
  
-       if (driver->textconv_cache && df->sha1_valid) {
-               *outbuf = notes_cache_get(driver->textconv_cache, df->sha1,
+       if (driver->textconv_cache && df->oid_valid) {
+               *outbuf = notes_cache_get(driver->textconv_cache,
+                                         df->oid.hash,
                                          &size);
                if (*outbuf)
                        return size;
        if (!*outbuf)
                die("unable to read files to diff");
  
-       if (driver->textconv_cache && df->sha1_valid) {
+       if (driver->textconv_cache && df->oid_valid) {
                /* ignore errors, as we might be in a readonly repository */
-               notes_cache_put(driver->textconv_cache, df->sha1, *outbuf,
+               notes_cache_put(driver->textconv_cache, df->oid.hash, *outbuf,
                                size);
                /*
                 * we could save up changes and flush them all at the end,
diff --combined line-log.c
index a30c89a30966cda66f55f294b986049fdfeed34e,93407baafd12c68aedb04bc6995417d9554aef78..916e7248701dad2a8beb870887a5ed7d3874ff41
@@@ -480,7 -480,8 +480,7 @@@ static struct commit *check_single_comm
                struct object *obj = revs->pending.objects[i].item;
                if (obj->flags & UNINTERESTING)
                        continue;
 -              while (obj->type == OBJ_TAG)
 -                      obj = deref_tag(obj, NULL, 0);
 +              obj = deref_tag(obj, NULL, 0);
                if (obj->type != OBJ_COMMIT)
                        die("Non commit %s?", revs->pending.objects[i].name);
                if (commit)
@@@ -519,7 -520,7 +519,7 @@@ static void fill_line_ends(struct diff_
        char *data = NULL;
  
        if (diff_populate_filespec(spec, 0))
-               die("Cannot read blob %s", sha1_to_hex(spec->sha1));
+               die("Cannot read blob %s", oid_to_hex(&spec->oid));
  
        ALLOC_ARRAY(ends, size);
        ends[cur++] = 0;
@@@ -840,7 -841,7 +840,7 @@@ static char *get_nth_line(long line, un
  
  static void print_line(const char *prefix, char first,
                       long line, unsigned long *ends, void *data,
 -                     const char *color, const char *reset)
 +                     const char *color, const char *reset, FILE *file)
  {
        char *begin = get_nth_line(line, ends, data);
        char *end = get_nth_line(line+1, ends, data);
                had_nl = 1;
        }
  
 -      fputs(prefix, stdout);
 -      fputs(color, stdout);
 -      putchar(first);
 -      fwrite(begin, 1, end-begin, stdout);
 -      fputs(reset, stdout);
 -      putchar('\n');
 +      fputs(prefix, file);
 +      fputs(color, file);
 +      putc(first, file);
 +      fwrite(begin, 1, end-begin, file);
 +      fputs(reset, file);
 +      putc('\n', file);
        if (!had_nl)
 -              fputs("\\ No newline at end of file\n", stdout);
 +              fputs("\\ No newline at end of file\n", file);
  }
  
  static char *output_prefix(struct diff_options *opt)
@@@ -893,16 -894,16 +893,16 @@@ static void dump_diff_hacky_one(struct 
        if (!pair || !diff)
                return;
  
-       if (pair->one->sha1_valid)
+       if (pair->one->oid_valid)
                fill_line_ends(pair->one, &p_lines, &p_ends);
        fill_line_ends(pair->two, &t_lines, &t_ends);
  
 -      printf("%s%sdiff --git a/%s b/%s%s\n", prefix, c_meta, pair->one->path, pair->two->path, c_reset);
 -      printf("%s%s--- %s%s%s\n", prefix, c_meta,
 +      fprintf(opt->file, "%s%sdiff --git a/%s b/%s%s\n", prefix, c_meta, pair->one->path, pair->two->path, c_reset);
 +      fprintf(opt->file, "%s%s--- %s%s%s\n", prefix, c_meta,
-              pair->one->sha1_valid ? "a/" : "",
-              pair->one->sha1_valid ? pair->one->path : "/dev/null",
+              pair->one->oid_valid ? "a/" : "",
+              pair->one->oid_valid ? pair->one->path : "/dev/null",
               c_reset);
 -      printf("%s%s+++ b/%s%s\n", prefix, c_meta, pair->two->path, c_reset);
 +      fprintf(opt->file, "%s%s+++ b/%s%s\n", prefix, c_meta, pair->two->path, c_reset);
        for (i = 0; i < range->ranges.nr; i++) {
                long p_start, p_end;
                long t_start = range->ranges.ranges[i].start;
                }
  
                /* Now output a diff hunk for this range */
 -              printf("%s%s@@ -%ld,%ld +%ld,%ld @@%s\n",
 +              fprintf(opt->file, "%s%s@@ -%ld,%ld +%ld,%ld @@%s\n",
                       prefix, c_frag,
                       p_start+1, p_end-p_start, t_start+1, t_end-t_start,
                       c_reset);
                        int k;
                        for (; t_cur < diff->target.ranges[j].start; t_cur++)
                                print_line(prefix, ' ', t_cur, t_ends, pair->two->data,
 -                                         c_context, c_reset);
 +                                         c_context, c_reset, opt->file);
                        for (k = diff->parent.ranges[j].start; k < diff->parent.ranges[j].end; k++)
                                print_line(prefix, '-', k, p_ends, pair->one->data,
 -                                         c_old, c_reset);
 +                                         c_old, c_reset, opt->file);
                        for (; t_cur < diff->target.ranges[j].end && t_cur < t_end; t_cur++)
                                print_line(prefix, '+', t_cur, t_ends, pair->two->data,
 -                                         c_new, c_reset);
 +                                         c_new, c_reset, opt->file);
                        j++;
                }
                for (; t_cur < t_end; t_cur++)
                        print_line(prefix, ' ', t_cur, t_ends, pair->two->data,
 -                                 c_context, c_reset);
 +                                 c_context, c_reset, opt->file);
        }
  
        free(p_ends);
   */
  static void dump_diff_hacky(struct rev_info *rev, struct line_log_data *range)
  {
 -      puts(output_prefix(&rev->diffopt));
 +      fprintf(rev->diffopt.file, "%s\n", output_prefix(&rev->diffopt));
        while (range) {
                dump_diff_hacky_one(rev, range);
                range = range->next;
@@@ -1010,12 -1011,12 +1010,12 @@@ static int process_diff_filepair(struc
        if (rg->ranges.nr == 0)
                return 0;
  
-       assert(pair->two->sha1_valid);
+       assert(pair->two->oid_valid);
        diff_populate_filespec(pair->two, 0);
        file_target.ptr = pair->two->data;
        file_target.size = pair->two->size;
  
-       if (pair->one->sha1_valid) {
+       if (pair->one->oid_valid) {
                diff_populate_filespec(pair->one, 0);
                file_parent.ptr = pair->one->data;
                file_parent.size = pair->one->size;
diff --combined notes-merge.c
index b7814c9b6488825a68bf8ca20de2c6420f01e26b,62c23d8ab52111cae6dd1e004eae60224a4eaf93..1b58a14ebc30d47d942b868af1afdc8cc3195148
@@@ -41,14 -41,14 +41,14 @@@ static int verify_notes_filepair(struc
        switch (p->status) {
        case DIFF_STATUS_MODIFIED:
                assert(p->one->mode == p->two->mode);
-               assert(!is_null_sha1(p->one->sha1));
-               assert(!is_null_sha1(p->two->sha1));
+               assert(!is_null_oid(&p->one->oid));
+               assert(!is_null_oid(&p->two->oid));
                break;
        case DIFF_STATUS_ADDED:
-               assert(is_null_sha1(p->one->sha1));
+               assert(is_null_oid(&p->one->oid));
                break;
        case DIFF_STATUS_DELETED:
-               assert(is_null_sha1(p->two->sha1));
+               assert(is_null_oid(&p->two->oid));
                break;
        default:
                return -1;
@@@ -142,27 -142,27 +142,27 @@@ static struct notes_merge_pair *diff_tr
                if (verify_notes_filepair(p, obj)) {
                        trace_printf("\t\tCannot merge entry '%s' (%c): "
                               "%.7s -> %.7s. Skipping!\n", p->one->path,
-                              p->status, sha1_to_hex(p->one->sha1),
-                              sha1_to_hex(p->two->sha1));
+                              p->status, oid_to_hex(&p->one->oid),
+                              oid_to_hex(&p->two->oid));
                        continue;
                }
                mp = find_notes_merge_pair_pos(changes, len, obj, 1, &occupied);
                if (occupied) {
                        /* We've found an addition/deletion pair */
                        assert(!hashcmp(mp->obj, obj));
-                       if (is_null_sha1(p->one->sha1)) { /* addition */
+                       if (is_null_oid(&p->one->oid)) { /* addition */
                                assert(is_null_sha1(mp->remote));
-                               hashcpy(mp->remote, p->two->sha1);
-                       } else if (is_null_sha1(p->two->sha1)) { /* deletion */
+                               hashcpy(mp->remote, p->two->oid.hash);
+                       } else if (is_null_oid(&p->two->oid)) { /* deletion */
                                assert(is_null_sha1(mp->base));
-                               hashcpy(mp->base, p->one->sha1);
+                               hashcpy(mp->base, p->one->oid.hash);
                        } else
                                assert(!"Invalid existing change recorded");
                } else {
                        hashcpy(mp->obj, obj);
-                       hashcpy(mp->base, p->one->sha1);
+                       hashcpy(mp->base, p->one->oid.hash);
                        hashcpy(mp->local, uninitialized);
-                       hashcpy(mp->remote, p->two->sha1);
+                       hashcpy(mp->remote, p->two->oid.hash);
                        len++;
                }
                trace_printf("\t\tStored remote change for %s: %.7s -> %.7s\n",
                       sha1_to_hex(mp->remote));
        }
        diff_flush(&opt);
 -      free_pathspec(&opt.pathspec);
 +      clear_pathspec(&opt.pathspec);
  
        *num_changes = len;
        return changes;
@@@ -203,21 -203,21 +203,21 @@@ static void diff_tree_local(struct note
                if (verify_notes_filepair(p, obj)) {
                        trace_printf("\t\tCannot merge entry '%s' (%c): "
                               "%.7s -> %.7s. Skipping!\n", p->one->path,
-                              p->status, sha1_to_hex(p->one->sha1),
-                              sha1_to_hex(p->two->sha1));
+                              p->status, oid_to_hex(&p->one->oid),
+                              oid_to_hex(&p->two->oid));
                        continue;
                }
                mp = find_notes_merge_pair_pos(changes, len, obj, 0, &match);
                if (!match) {
                        trace_printf("\t\tIgnoring local-only change for %s: "
                               "%.7s -> %.7s\n", sha1_to_hex(obj),
-                              sha1_to_hex(p->one->sha1),
-                              sha1_to_hex(p->two->sha1));
+                              oid_to_hex(&p->one->oid),
+                              oid_to_hex(&p->two->oid));
                        continue;
                }
  
                assert(!hashcmp(mp->obj, obj));
-               if (is_null_sha1(p->two->sha1)) { /* deletion */
+               if (is_null_oid(&p->two->oid)) { /* deletion */
                        /*
                         * Either this is a true deletion (1), or it is part
                         * of an A/D pair (2), or D/A pair (3):
                         */
                        if (!hashcmp(mp->local, uninitialized))
                                hashclr(mp->local);
-               } else if (is_null_sha1(p->one->sha1)) { /* addition */
+               } else if (is_null_oid(&p->one->oid)) { /* addition */
                        /*
                         * Either this is a true addition (1), or it is part
                         * of an A/D pair (2), or D/A pair (3):
                         */
                        assert(is_null_sha1(mp->local) ||
                               !hashcmp(mp->local, uninitialized));
-                       hashcpy(mp->local, p->two->sha1);
+                       hashcpy(mp->local, p->two->oid.hash);
                } else { /* modification */
                        /*
                         * This is a true modification. p->one->sha1 shall
                         * match mp->base, and mp->local shall be uninitialized.
                         * Set mp->local to p->two->sha1.
                         */
-                       assert(!hashcmp(p->one->sha1, mp->base));
+                       assert(!hashcmp(p->one->oid.hash, mp->base));
                        assert(!hashcmp(mp->local, uninitialized));
-                       hashcpy(mp->local, p->two->sha1);
+                       hashcpy(mp->local, p->two->oid.hash);
                }
                trace_printf("\t\tStored local change for %s: %.7s -> %.7s\n",
                       sha1_to_hex(mp->obj), sha1_to_hex(mp->base),
                       sha1_to_hex(mp->local));
        }
        diff_flush(&opt);
 -      free_pathspec(&opt.pathspec);
 +      clear_pathspec(&opt.pathspec);
  }
  
  static void check_notes_merge_worktree(struct notes_merge_options *o)
diff --combined submodule-config.c
index db1847ff6893de6329bf60729b72e8f6a33188b5,a6c2710f916375a8d922ca0a27cf894472427533..077db4054f7b38b31d9c6f11e2b589e9111d4a8c
@@@ -199,7 -199,6 +199,7 @@@ static struct submodule *lookup_or_crea
        submodule->update_strategy.command = NULL;
        submodule->fetch_recurse = RECURSE_SUBMODULES_NONE;
        submodule->ignore = NULL;
 +      submodule->recommend_shallow = -1;
  
        hashcpy(submodule->gitmodules_sha1, gitmodules_sha1);
  
@@@ -354,14 -353,6 +354,14 @@@ static int parse_config(const char *var
                else if (parse_submodule_update_strategy(value,
                         &submodule->update_strategy) < 0)
                                die(_("invalid value for %s"), var);
 +      } else if (!strcmp(item.buf, "shallow")) {
 +              if (!me->overwrite && submodule->recommend_shallow != -1)
 +                      warn_multiple_config(me->commit_sha1, submodule->name,
 +                                           "shallow");
 +              else {
 +                      submodule->recommend_shallow =
 +                              git_config_bool(var, value);
 +              }
        }
  
        strbuf_release(&name);
@@@ -377,7 -368,7 +377,7 @@@ static int gitmodule_sha1_from_commit(c
        int ret = 0;
  
        if (is_null_sha1(commit_sha1)) {
-               hashcpy(gitmodules_sha1, null_sha1);
+               hashclr(gitmodules_sha1);
                return 1;
        }
  
diff --combined submodule.c
index abc2ac2a1014e27b9dd56df178cadda6a88c1270,cdccf65c6bc7b29b8de23882606326ea8bb04f1b..1b5cdfb7e784d646c15e59afb2fb43587a8ff8e9
@@@ -17,7 -17,7 +17,7 @@@
  
  static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
  static int parallel_jobs = 1;
 -static struct string_list changed_submodule_paths;
 +static struct string_list changed_submodule_paths = STRING_LIST_INIT_NODUP;
  static int initialized_fetch_ref_tips;
  static struct sha1_array ref_tips_before_fetch;
  static struct sha1_array ref_tips_after_fetch;
@@@ -445,7 -445,7 +445,7 @@@ static void collect_submodules_from_dif
                struct diff_filepair *p = q->queue[i];
                if (!S_ISGITLINK(p->two->mode))
                        continue;
-               if (submodule_needs_pushing(p->two->path, p->two->sha1))
+               if (submodule_needs_pushing(p->two->path, p->two->oid.hash))
                        string_list_insert(needs_pushing, p->two->path);
        }
  }
@@@ -577,7 -577,7 +577,7 @@@ static void submodule_collect_changed_c
                         * being moved around. */
                        struct string_list_item *path;
                        path = unsorted_string_list_lookup(&changed_submodule_paths, p->two->path);
-                       if (!path && !is_submodule_commit_present(p->two->path, p->two->sha1))
+                       if (!path && !is_submodule_commit_present(p->two->path, p->two->oid.hash))
                                string_list_append(&changed_submodule_paths, xstrdup(p->two->path));
                } else {
                        /* Submodule is new or was moved here */
diff --combined wt-status.c
index c19b52ce8708ebe997f5bc728124a4653014543f,7c2fa8cdd7eefab58625d662f15716f0ff862dd8..de62ab2149cfb75e0dab2e5093ece630ce49d913
@@@ -263,7 -263,7 +263,7 @@@ static const char *wt_status_unmerged_s
        case 7:
                return _("both modified:");
        default:
 -              die(_("bug: unhandled unmerged status %x"), stagemask);
 +              die("bug: unhandled unmerged status %x", stagemask);
        }
  }
  
@@@ -388,7 -388,7 +388,7 @@@ static void wt_status_print_change_data
        status_printf(s, color(WT_STATUS_HEADER, s), "\t");
        what = wt_status_diff_status_string(status);
        if (!what)
 -              die(_("bug: unhandled diff status %c"), status);
 +              die("bug: unhandled diff status %c", status);
        len = label_width - utf8_strwidth(what);
        assert(len >= 0);
        if (status == DIFF_STATUS_COPIED || status == DIFF_STATUS_RENAMED)
@@@ -432,7 -432,8 +432,8 @@@ static void wt_status_collect_changed_c
                        d->worktree_status = p->status;
                d->dirty_submodule = p->two->dirty_submodule;
                if (S_ISGITLINK(p->two->mode))
-                       d->new_submodule_commits = !!hashcmp(p->one->sha1, p->two->sha1);
+                       d->new_submodule_commits = !!oidcmp(&p->one->oid,
+                                                           &p->two->oid);
        }
  }
  
@@@ -1554,7 -1555,7 +1555,7 @@@ void wt_status_print(struct wt_status *
                        else
                                printf(_("nothing to commit\n"));
                } else
 -                      printf(_("nothing to commit, working directory clean\n"));
 +                      printf(_("nothing to commit, working tree clean\n"));
        }
  }