Merge branch 'bw/ls-files-sans-the-index'
authorJunio C Hamano <gitster@pobox.com>
Sat, 24 Jun 2017 21:28:40 +0000 (14:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 24 Jun 2017 21:28:40 +0000 (14:28 -0700)
Code clean-up.

* bw/ls-files-sans-the-index:
ls-files: factor out tag calculation
ls-files: factor out debug info into a function
ls-files: convert show_files to take an index
ls-files: convert show_ce_entry to take an index
ls-files: convert prune_cache to take an index
ls-files: convert ce_excluded to take an index
ls-files: convert show_ru_info to take an index
ls-files: convert show_other_files to take an index
ls-files: convert show_killed_files to take an index
ls-files: convert write_eolinfo to take an index
ls-files: convert overlay_tree_on_cache to take an index
tree: convert read_tree to take an index parameter
convert: convert renormalize_buffer to take an index
convert: convert convert_to_git to take an index
convert: convert convert_to_git_filter_fd to take an index
convert: convert crlf_to_git to take an index
convert: convert get_cached_convert_stats_ascii to take an index

1  2 
apply.c
blame.c
builtin/commit.c
cache.h
combine-diff.c
diff.c
dir.c
merge-recursive.c
diff --combined apply.c
index 679ed7732d2385c4d7704f60335514b2b5f75c39,97afb6f60a28b8b42d36b4d376db6156757f8c80..f24014a705edf5fc1f49e22502f563a469b850ed
+++ b/apply.c
@@@ -762,6 -762,17 +762,6 @@@ static char *find_name_traditional(stru
        return find_name_common(state, line, def, p_value, line + len, 0);
  }
  
 -static int count_slashes(const char *cp)
 -{
 -      int cnt = 0;
 -      char ch;
 -
 -      while ((ch = *cp++))
 -              if (ch == '/')
 -                      cnt++;
 -      return cnt;
 -}
 -
  /*
   * Given the string after "--- " or "+++ ", guess the appropriate
   * p_value for the given patch.
@@@ -2256,7 -2267,7 +2256,7 @@@ static int read_old_data(struct stat *s
        case S_IFREG:
                if (strbuf_read_file(buf, path, st->st_size) != st->st_size)
                        return error(_("unable to open or read %s"), path);
-               convert_to_git(path, buf->buf, buf->len, buf, 0);
+               convert_to_git(&the_index, path, buf->buf, buf->len, buf, 0);
                return 0;
        default:
                return -1;
@@@ -3730,7 -3741,7 +3730,7 @@@ static int check_to_create(struct apply
                        return 0;
  
                return EXISTS_IN_WORKTREE;
 -      } else if ((errno != ENOENT) && (errno != ENOTDIR)) {
 +      } else if (!is_missing_file_error(errno)) {
                return error_errno("%s", new_name);
        }
        return 0;
diff --combined blame.c
index 194b58e96066f9620005f64a57ca9ecc618c86f4,a6f3d72df8fbc45a14214029491d5c06a73cefa5..6d57ab9715665a8bc6a2ba02015342ad851b6d2f
+++ b/blame.c
@@@ -229,7 -229,7 +229,7 @@@ static struct commit *fake_working_tree
                if (strbuf_read(&buf, 0, 0) < 0)
                        die_errno("failed to read from stdin");
        }
-       convert_to_git(path, buf.buf, buf.len, &buf, 0);
+       convert_to_git(&the_index, path, buf.buf, buf.len, &buf, 0);
        origin->file.ptr = buf.buf;
        origin->file.size = buf.len;
        pretend_sha1_file(buf.buf, buf.len, OBJ_BLOB, origin->blob_oid.hash);
@@@ -556,9 -556,9 +556,9 @@@ static struct blame_origin *find_origin
        if (is_null_oid(&origin->commit->object.oid))
                do_diff_cache(&parent->tree->object.oid, &diff_opts);
        else
 -              diff_tree_sha1(parent->tree->object.oid.hash,
 -                             origin->commit->tree->object.oid.hash,
 -                             "", &diff_opts);
 +              diff_tree_oid(&parent->tree->object.oid,
 +                            &origin->commit->tree->object.oid,
 +                            "", &diff_opts);
        diffcore_std(&diff_opts);
  
        if (!diff_queued_diff.nr) {
@@@ -625,9 -625,9 +625,9 @@@ static struct blame_origin *find_rename
        if (is_null_oid(&origin->commit->object.oid))
                do_diff_cache(&parent->tree->object.oid, &diff_opts);
        else
 -              diff_tree_sha1(parent->tree->object.oid.hash,
 -                             origin->commit->tree->object.oid.hash,
 -                             "", &diff_opts);
 +              diff_tree_oid(&parent->tree->object.oid,
 +                            &origin->commit->tree->object.oid,
 +                            "", &diff_opts);
        diffcore_std(&diff_opts);
  
        for (i = 0; i < diff_queued_diff.nr; i++) {
@@@ -1247,7 -1247,7 +1247,7 @@@ static void find_copy_in_parent(struct 
        /* Try "find copies harder" on new path if requested;
         * we do not want to use diffcore_rename() actually to
         * match things up; find_copies_harder is set only to
 -       * force diff_tree_sha1() to feed all filepairs to diff_queue,
 +       * force diff_tree_oid() to feed all filepairs to diff_queue,
         * and this code needs to be after diff_setup_done(), which
         * usually makes find-copies-harder imply copy detection.
         */
        if (is_null_oid(&target->commit->object.oid))
                do_diff_cache(&parent->tree->object.oid, &diff_opts);
        else
 -              diff_tree_sha1(parent->tree->object.oid.hash,
 -                             target->commit->tree->object.oid.hash,
 -                             "", &diff_opts);
 +              diff_tree_oid(&parent->tree->object.oid,
 +                            &target->commit->tree->object.oid,
 +                            "", &diff_opts);
  
        if (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))
                diffcore_std(&diff_opts);
diff --combined builtin/commit.c
index e3c9e190b06a63250a9c7eff3e256efcb10660f7,78ef319a2418066a34f1f3c47049b7500f3f0f07..5968970b6519a8ed1a8b80ff6341a3ad1e6f542e
@@@ -253,7 -253,8 +253,8 @@@ static int list_paths(struct string_lis
  
        if (with_tree) {
                char *max_prefix = common_prefix(pattern);
-               overlay_tree_on_cache(with_tree, max_prefix ? max_prefix : prefix);
+               overlay_tree_on_index(&the_index, with_tree,
+                                     max_prefix ? max_prefix : prefix);
                free(max_prefix);
        }
  
@@@ -1699,7 -1700,10 +1700,7 @@@ int cmd_commit(int argc, const char **a
                if (!reflog_msg)
                        reflog_msg = "commit (merge)";
                pptr = commit_list_append(current_head, pptr);
 -              fp = fopen(git_path_merge_head(), "r");
 -              if (fp == NULL)
 -                      die_errno(_("could not open '%s' for reading"),
 -                                git_path_merge_head());
 +              fp = xfopen(git_path_merge_head(), "r");
                while (strbuf_getline_lf(&m, fp) != EOF) {
                        struct commit *parent;
  
                cfg = init_copy_notes_for_rewrite("amend");
                if (cfg) {
                        /* we are amending, so current_head is not NULL */
 -                      copy_note_for_rewrite(cfg, current_head->object.oid.hash, oid.hash);
 +                      copy_note_for_rewrite(cfg, &current_head->object.oid, &oid);
                        finish_copy_notes_for_rewrite(cfg, "Notes added by 'git commit --amend'");
                }
                run_rewrite_hook(&current_head->object.oid, &oid);
diff --combined cache.h
index d6ba8a2f11a63d4d9ec5257a75532414d22526c0,5a0e0a9e5d59a46b06058778c1f078a55e64edea..a666aaf9fd0b211954f14fbefa68d2cc440072f5
+++ b/cache.h
@@@ -1026,13 -1026,6 +1026,13 @@@ static inline void oidcpy(struct object
        hashcpy(dst->hash, src->hash);
  }
  
 +static inline struct object_id *oiddup(const struct object_id *src)
 +{
 +      struct object_id *dst = xmalloc(sizeof(struct object_id));
 +      oidcpy(dst, src);
 +      return dst;
 +}
 +
  static inline void hashclr(unsigned char *hash)
  {
        memset(hash, 0, GIT_SHA1_RAWSZ);
@@@ -2193,7 -2186,8 +2193,8 @@@ extern int ws_blank_line(const char *li
  #define ws_tab_width(rule)     ((rule) & WS_TAB_WIDTH_MASK)
  
  /* ls-files */
- void overlay_tree_on_cache(const char *tree_name, const char *prefix);
+ void overlay_tree_on_index(struct index_state *istate,
+                          const char *tree_name, const char *prefix);
  
  char *alias_lookup(const char *alias);
  int split_cmdline(char *cmdline, const char ***argv);
diff --combined combine-diff.c
index ec9d930440993b265fe74aacd2a3fdb768dccf64,74f723af3d08937a852a572c437605408dc0e30e..9e163d5adabd93fd48a6b563c5f31c32740e01c7
@@@ -302,7 -302,7 +302,7 @@@ static char *grab_blob(const struct obj
                return xcalloc(1, 1);
        } else if (textconv) {
                struct diff_filespec *df = alloc_filespec(path);
 -              fill_filespec(df, oid->hash, 1, mode);
 +              fill_filespec(df, oid, 1, mode);
                *size = fill_textconv(textconv, df, &blob);
                free_filespec(df);
        } else {
@@@ -1022,7 -1022,7 +1022,7 @@@ static void show_patch_diff(struct comb
                                                   &result_size, NULL, NULL);
                } else if (textconv) {
                        struct diff_filespec *df = alloc_filespec(elem->path);
 -                      fill_filespec(df, null_sha1, 0, st.st_mode);
 +                      fill_filespec(df, &null_oid, 0, st.st_mode);
                        result_size = fill_textconv(textconv, df, &result);
                        free_filespec(df);
                } else if (0 <= (fd = open(elem->path, O_RDONLY))) {
                        if (is_file) {
                                struct strbuf buf = STRBUF_INIT;
  
-                               if (convert_to_git(elem->path, result, len, &buf, safe_crlf)) {
+                               if (convert_to_git(&the_index, elem->path, result, len, &buf, safe_crlf)) {
                                        free(result);
                                        result = strbuf_detach(&buf, &len);
                                        result_size = len;
@@@ -1311,7 -1311,7 +1311,7 @@@ static const char *path_path(void *obj
  
  
  /* find set of paths that every parent touches */
 -static struct combine_diff_path *find_paths_generic(const unsigned char *sha1,
 +static struct combine_diff_path *find_paths_generic(const struct object_id *oid,
        const struct oid_array *parents, struct diff_options *opt)
  {
        struct combine_diff_path *paths = NULL;
                        opt->output_format = stat_opt;
                else
                        opt->output_format = DIFF_FORMAT_NO_OUTPUT;
 -              diff_tree_sha1(parents->oid[i].hash, sha1, "", opt);
 +              diff_tree_oid(&parents->oid[i], oid, "", opt);
                diffcore_std(opt);
                paths = intersect_paths(paths, i, num_parent);
  
   * rename/copy detection, etc, comparing all trees simultaneously (= faster).
   */
  static struct combine_diff_path *find_paths_multitree(
 -      const unsigned char *sha1, const struct oid_array *parents,
 +      const struct object_id *oid, const struct oid_array *parents,
        struct diff_options *opt)
  {
        int i, nparent = parents->nr;
 -      const unsigned char **parents_sha1;
 +      const struct object_id **parents_oid;
        struct combine_diff_path paths_head;
        struct strbuf base;
  
 -      ALLOC_ARRAY(parents_sha1, nparent);
 +      ALLOC_ARRAY(parents_oid, nparent);
        for (i = 0; i < nparent; i++)
 -              parents_sha1[i] = parents->oid[i].hash;
 +              parents_oid[i] = &parents->oid[i];
  
        /* fake list head, so worker can assume it is non-NULL */
        paths_head.next = NULL;
  
        strbuf_init(&base, PATH_MAX);
 -      diff_tree_paths(&paths_head, sha1, parents_sha1, nparent, &base, opt);
 +      diff_tree_paths(&paths_head, oid, parents_oid, nparent, &base, opt);
  
        strbuf_release(&base);
 -      free(parents_sha1);
 +      free(parents_oid);
        return paths_head.next;
  }
  
  
 -void diff_tree_combined(const unsigned char *sha1,
 +void diff_tree_combined(const struct object_id *oid,
                        const struct oid_array *parents,
                        int dense,
                        struct rev_info *rev)
                 * diff(sha1,parent_i) for all i to do the job, specifically
                 * for parent0.
                 */
 -              paths = find_paths_generic(sha1, parents, &diffopts);
 +              paths = find_paths_generic(oid, parents, &diffopts);
        }
        else {
                int stat_opt;
 -              paths = find_paths_multitree(sha1, parents, &diffopts);
 +              paths = find_paths_multitree(oid, parents, &diffopts);
  
                /*
                 * show stat against the first parent even
                if (stat_opt) {
                        diffopts.output_format = stat_opt;
  
 -                      diff_tree_sha1(parents->oid[0].hash, sha1, "", &diffopts);
 +                      diff_tree_oid(&parents->oid[0], oid, "", &diffopts);
                        diffcore_std(&diffopts);
                        if (opt->orderfile)
                                diffcore_order(opt->orderfile);
@@@ -1539,6 -1539,6 +1539,6 @@@ void diff_tree_combined_merge(const str
                oid_array_append(&parents, &parent->item->object.oid);
                parent = parent->next;
        }
 -      diff_tree_combined(commit->object.oid.hash, &parents, dense, rev);
 +      diff_tree_combined(&commit->object.oid, &parents, dense, rev);
        oid_array_clear(&parents);
  }
diff --combined diff.c
index acedf86aecc151112898ff54575151f157776281,976a6f91b189914570d1c688525a9ca5e3ef6505..e3d7e915783dd3a76d7fdc88cad5624fb009776c
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -2702,13 -2702,13 +2702,13 @@@ void free_filespec(struct diff_filespe
        }
  }
  
 -void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
 -                 int sha1_valid, unsigned short mode)
 +void fill_filespec(struct diff_filespec *spec, const struct object_id *oid,
 +                 int oid_valid, unsigned short mode)
  {
        if (mode) {
                spec->mode = canon_mode(mode);
 -              hashcpy(spec->oid.hash, sha1);
 -              spec->oid_valid = sha1_valid;
 +              oidcpy(&spec->oid, oid);
 +              spec->oid_valid = oid_valid;
        }
  }
  
   * the work tree has that object contents, return true, so that
   * prepare_temp_file() does not have to inflate and extract.
   */
 -static int reuse_worktree_file(const char *name, const unsigned char *sha1, int want_file)
 +static int reuse_worktree_file(const char *name, const struct object_id *oid, int want_file)
  {
        const struct cache_entry *ce;
        struct stat st;
         * objects however would tend to be slower as they need
         * to be individually opened and inflated.
         */
 -      if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1))
 +      if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(oid->hash))
                return 0;
  
        /*
         * Similarly, if we'd have to convert the file contents anyway, that
         * makes the optimization not worthwhile.
         */
-       if (!want_file && would_convert_to_git(name))
+       if (!want_file && would_convert_to_git(&the_index, name))
                return 0;
  
        len = strlen(name);
         * This is not the sha1 we are looking for, or
         * unreusable because it is not a regular file.
         */
 -      if (hashcmp(sha1, ce->oid.hash) || !S_ISREG(ce->ce_mode))
 +      if (oidcmp(oid, &ce->oid) || !S_ISREG(ce->ce_mode))
                return 0;
  
        /*
@@@ -2842,7 -2842,7 +2842,7 @@@ int diff_populate_filespec(struct diff_
                return diff_populate_gitlink(s, size_only);
  
        if (!s->oid_valid ||
 -          reuse_worktree_file(s->path, s->oid.hash, 0)) {
 +          reuse_worktree_file(s->path, &s->oid, 0)) {
                struct strbuf buf = STRBUF_INIT;
                struct stat st;
                int fd;
                 * point if the path requires us to run the content
                 * conversion.
                 */
-               if (size_only && !would_convert_to_git(s->path))
+               if (size_only && !would_convert_to_git(&the_index, s->path))
                        return 0;
  
                /*
                /*
                 * Convert from working tree format to canonical git format
                 */
-               if (convert_to_git(s->path, s->data, s->size, &buf, crlf_warn)) {
+               if (convert_to_git(&the_index, s->path, s->data, s->size, &buf, crlf_warn)) {
                        size_t size = 0;
                        munmap(s->data, s->size);
                        s->should_munmap = 0;
@@@ -3008,7 -3008,7 +3008,7 @@@ static struct diff_tempfile *prepare_te
  
        if (!S_ISGITLINK(one->mode) &&
            (!one->oid_valid ||
 -           reuse_worktree_file(name, one->oid.hash, 1))) {
 +           reuse_worktree_file(name, &one->oid, 1))) {
                struct stat st;
                if (lstat(name, &st) < 0) {
                        if (errno == ENOENT)
                        /* we can borrow from the file in the work tree */
                        temp->name = name;
                        if (!one->oid_valid)
 -                              sha1_to_hex_r(temp->hex, null_sha1);
 +                              oid_to_hex_r(temp->hex, &null_oid);
                        else
                                oid_to_hex_r(temp->hex, &one->oid);
                        /* Even though we may sometimes borrow the
                         * contents from the work tree, we always want
                         * one->mode.  mode is trustworthy even when
 -                       * !(one->sha1_valid), as long as
 +                       * !(one->oid_valid), as long as
                         * DIFF_FILE_VALID(one).
                         */
                        xsnprintf(temp->mode, sizeof(temp->mode), "%06o", one->mode);
@@@ -3239,7 -3239,7 +3239,7 @@@ static void run_diff_cmd(const char *pg
                fprintf(o->file, "* Unmerged path %s\n", name);
  }
  
 -static void diff_fill_sha1_info(struct diff_filespec *one)
 +static void diff_fill_oid_info(struct diff_filespec *one)
  {
        if (DIFF_FILE_VALID(one)) {
                if (!one->oid_valid) {
@@@ -3298,8 -3298,8 +3298,8 @@@ static void run_diff(struct diff_filepa
                return;
        }
  
 -      diff_fill_sha1_info(one);
 -      diff_fill_sha1_info(two);
 +      diff_fill_oid_info(one);
 +      diff_fill_oid_info(two);
  
        if (!pgm &&
            DIFF_FILE_VALID(one) && DIFF_FILE_VALID(two) &&
@@@ -3344,8 -3344,8 +3344,8 @@@ static void run_diffstat(struct diff_fi
        if (o->prefix_length)
                strip_prefix(o->prefix_length, &name, &other);
  
 -      diff_fill_sha1_info(p->one);
 -      diff_fill_sha1_info(p->two);
 +      diff_fill_oid_info(p->one);
 +      diff_fill_oid_info(p->two);
  
        builtin_diffstat(name, other, p->one, p->two, diffstat, o, p);
  }
@@@ -3368,8 -3368,8 +3368,8 @@@ static void run_checkdiff(struct diff_f
        if (o->prefix_length)
                strip_prefix(o->prefix_length, &name, &other);
  
 -      diff_fill_sha1_info(p->one);
 -      diff_fill_sha1_info(p->two);
 +      diff_fill_oid_info(p->one);
 +      diff_fill_oid_info(p->two);
  
        builtin_checkdiff(name, other, attr_path, p->one, p->two, o);
  }
@@@ -4071,7 -4071,9 +4071,7 @@@ int diff_opt_parse(struct diff_options 
                DIFF_OPT_CLR(options, FUNCCONTEXT);
        else if ((argcount = parse_long_opt("output", av, &optarg))) {
                char *path = prefix_filename(prefix, optarg);
 -              options->file = fopen(path, "w");
 -              if (!options->file)
 -                      die_errno("Could not open '%s'", path);
 +              options->file = xfopen(path, "w");
                options->close_file = 1;
                if (options->use_color != GIT_COLOR_ALWAYS)
                        options->use_color = GIT_COLOR_NEVER;
@@@ -4582,7 -4584,7 +4582,7 @@@ static void patch_id_add_mode(git_SHA_C
  }
  
  /* returns 0 upon success, and writes result into sha1 */
 -static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1, int diff_header_only)
 +static int diff_get_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only)
  {
        struct diff_queue_struct *q = &diff_queued_diff;
        int i;
                if (DIFF_PAIR_UNMERGED(p))
                        continue;
  
 -              diff_fill_sha1_info(p->one);
 -              diff_fill_sha1_info(p->two);
 +              diff_fill_oid_info(p->one);
 +              diff_fill_oid_info(p->two);
  
                len1 = remove_space(p->one->path, strlen(p->one->path));
                len2 = remove_space(p->two->path, strlen(p->two->path));
                if (diff_filespec_is_binary(p->one) ||
                    diff_filespec_is_binary(p->two)) {
                        git_SHA1_Update(&ctx, oid_to_hex(&p->one->oid),
 -                                      40);
 +                                      GIT_SHA1_HEXSZ);
                        git_SHA1_Update(&ctx, oid_to_hex(&p->two->oid),
 -                                      40);
 +                                      GIT_SHA1_HEXSZ);
                        continue;
                }
  
                                     p->one->path);
        }
  
 -      git_SHA1_Final(sha1, &ctx);
 +      git_SHA1_Final(oid->hash, &ctx);
        return 0;
  }
  
 -int diff_flush_patch_id(struct diff_options *options, unsigned char *sha1, int diff_header_only)
 +int diff_flush_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only)
  {
        struct diff_queue_struct *q = &diff_queued_diff;
        int i;
 -      int result = diff_get_patch_id(options, sha1, diff_header_only);
 +      int result = diff_get_patch_id(options, oid, diff_header_only);
  
        for (i = 0; i < q->nr; i++)
                diff_free_filepair(q->queue[i]);
@@@ -4805,7 -4807,9 +4805,7 @@@ void diff_flush(struct diff_options *op
                 */
                if (options->close_file)
                        fclose(options->file);
 -              options->file = fopen("/dev/null", "w");
 -              if (!options->file)
 -                      die_errno("Could not open /dev/null");
 +              options->file = xfopen("/dev/null", "w");
                options->close_file = 1;
                for (i = 0; i < q->nr; i++) {
                        struct diff_filepair *p = q->queue[i];
@@@ -5077,8 -5081,8 +5077,8 @@@ static int is_submodule_ignored(const c
  
  void diff_addremove(struct diff_options *options,
                    int addremove, unsigned mode,
 -                  const unsigned char *sha1,
 -                  int sha1_valid,
 +                  const struct object_id *oid,
 +                  int oid_valid,
                    const char *concatpath, unsigned dirty_submodule)
  {
        struct diff_filespec *one, *two;
        two = alloc_filespec(concatpath);
  
        if (addremove != '+')
 -              fill_filespec(one, sha1, sha1_valid, mode);
 +              fill_filespec(one, oid, oid_valid, mode);
        if (addremove != '-') {
 -              fill_filespec(two, sha1, sha1_valid, mode);
 +              fill_filespec(two, oid, oid_valid, mode);
                two->dirty_submodule = dirty_submodule;
        }
  
  
  void diff_change(struct diff_options *options,
                 unsigned old_mode, unsigned new_mode,
 -               const unsigned char *old_sha1,
 -               const unsigned char *new_sha1,
 -               int old_sha1_valid, int new_sha1_valid,
 +               const struct object_id *old_oid,
 +               const struct object_id *new_oid,
 +               int old_oid_valid, int new_oid_valid,
                 const char *concatpath,
                 unsigned old_dirty_submodule, unsigned new_dirty_submodule)
  {
  
        if (DIFF_OPT_TST(options, REVERSE_DIFF)) {
                SWAP(old_mode, new_mode);
 -              SWAP(old_sha1, new_sha1);
 -              SWAP(old_sha1_valid, new_sha1_valid);
 +              SWAP(old_oid, new_oid);
 +              SWAP(old_oid_valid, new_oid_valid);
                SWAP(old_dirty_submodule, new_dirty_submodule);
        }
  
  
        one = alloc_filespec(concatpath);
        two = alloc_filespec(concatpath);
 -      fill_filespec(one, old_sha1, old_sha1_valid, old_mode);
 -      fill_filespec(two, new_sha1, new_sha1_valid, new_mode);
 +      fill_filespec(one, old_oid, old_oid_valid, old_mode);
 +      fill_filespec(two, new_oid, new_oid_valid, new_mode);
        one->dirty_submodule = old_dirty_submodule;
        two->dirty_submodule = new_dirty_submodule;
        p = diff_queue(&diff_queued_diff, one, two);
@@@ -5277,7 -5281,7 +5277,7 @@@ int textconv_object(const char *path
        struct userdiff_driver *textconv;
  
        df = alloc_filespec(path);
 -      fill_filespec(df, oid->hash, oid_valid, mode);
 +      fill_filespec(df, oid, oid_valid, mode);
        textconv = get_textconv(df);
        if (!textconv) {
                free_filespec(df);
diff --combined dir.c
index 5f1afb56bc6e6d5dc5300380f980f4b2699ab08d,f673b86f31eb841ce0ecc34f49ab9ece2dd4d128..6687d84dbc8dfb4f6d39028e2b9636278a6146e2
--- 1/dir.c
--- 2/dir.c
+++ b/dir.c
@@@ -52,15 -52,6 +52,15 @@@ static enum path_treatment read_directo
  static int get_dtype(struct dirent *de, struct index_state *istate,
                     const char *path, int len);
  
 +int count_slashes(const char *s)
 +{
 +      int cnt = 0;
 +      while (*s)
 +              if (*s++ == '/')
 +                      cnt++;
 +      return cnt;
 +}
 +
  int fspathcmp(const char *a, const char *b)
  {
        return ignore_case ? strcasecmp(a, b) : strcmp(a, b);
@@@ -761,9 -752,9 +761,9 @@@ static int add_excludes(const char *fna
  
        fd = open(fname, O_RDONLY);
        if (fd < 0 || fstat(fd, &st) < 0) {
 -              if (errno != ENOENT)
 -                      warn_on_inaccessible(fname);
 -              if (0 <= fd)
 +              if (fd < 0)
 +                      warn_on_fopen_errors(fname);
 +              else
                        close(fd);
                if (!istate ||
                    (buf = read_skip_worktree_file_from_index(istate, fname, &size, sha1_stat)) == NULL)
                                 (pos = index_name_pos(istate, fname, strlen(fname))) >= 0 &&
                                 !ce_stage(istate->cache[pos]) &&
                                 ce_uptodate(istate->cache[pos]) &&
-                                !would_convert_to_git(fname))
+                                !would_convert_to_git(istate, fname))
                                hashcpy(sha1_stat->sha1,
                                        istate->cache[pos]->oid.hash);
                        else
@@@ -2346,7 -2337,7 +2346,7 @@@ int remove_path(const char *name
  {
        char *slash;
  
 -      if (unlink(name) && errno != ENOENT && errno != ENOTDIR)
 +      if (unlink(name) && !is_missing_file_error(errno))
                return -1;
  
        slash = strrchr(name, '/');
diff --combined merge-recursive.c
index 5cc86df2d15729e9b0e8b36fdb151d5986f42a10,eac12d4888993ebf4fde5194e19704db885824ee..ce48ed7e86137710283f775d4152c9870cfabeea
@@@ -528,7 -528,7 +528,7 @@@ static struct string_list *get_renames(
        opts.show_rename_progress = o->show_rename_progress;
        opts.output_format = DIFF_FORMAT_NO_OUTPUT;
        diff_setup_done(&opts);
 -      diff_tree_sha1(o_tree->object.oid.hash, tree->object.oid.hash, "", &opts);
 +      diff_tree_oid(&o_tree->object.oid, &tree->object.oid, "", &opts);
        diffcore_std(&opts);
        if (opts.needed_rename_limit > o->needed_rename_limit)
                o->needed_rename_limit = opts.needed_rename_limit;
@@@ -1639,8 -1639,8 +1639,8 @@@ static int blob_unchanged(struct merge_
         * performed.  Comparison can be skipped if both files are
         * unchanged since their sha1s have already been compared.
         */
-       if (renormalize_buffer(path, o.buf, o.len, &o) |
-           renormalize_buffer(path, a.buf, a.len, &a))
+       if (renormalize_buffer(&the_index, path, o.buf, o.len, &o) |
+           renormalize_buffer(&the_index, path, a.buf, a.len, &a))
                ret = (o.len == a.len && !memcmp(o.buf, a.buf, o.len));
  
  error_return: