Merge branch 'ar/diff-args-osx-precompose'
authorJunio C Hamano <gitster@pobox.com>
Mon, 23 May 2016 21:54:35 +0000 (14:54 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 May 2016 21:54:35 +0000 (14:54 -0700)
Many commands normalize command line arguments from NFD to NFC
variant of UTF-8 on OSX, but commands in the "diff" family did
not, causing "git diff $path" to complain that no such path is
known to Git.  They have been taught to do the normalization.

* ar/diff-args-osx-precompose:
  diff: run arguments through precompose_argv

1  2 
builtin/diff-tree.c
builtin/diff.c

diff --combined builtin/diff-tree.c
@@@ -49,9 -49,9 +49,9 @@@ static int stdin_diff_trees(struct tre
        tree2 = lookup_tree(sha1);
        if (!tree2 || parse_tree(tree2))
                return -1;
 -      printf("%s %s\n", sha1_to_hex(tree1->object.sha1),
 -                        sha1_to_hex(tree2->object.sha1));
 -      diff_tree_sha1(tree1->object.sha1, tree2->object.sha1,
 +      printf("%s %s\n", oid_to_hex(&tree1->object.oid),
 +                        oid_to_hex(&tree2->object.oid));
 +      diff_tree_sha1(tree1->object.oid.hash, tree2->object.oid.hash,
                       "", &log_tree_opt.diffopt);
        log_tree_diff_flush(&log_tree_opt);
        return 0;
@@@ -114,6 -114,8 +114,8 @@@ int cmd_diff_tree(int argc, const char 
        opt->disable_stdin = 1;
        memset(&s_r_opt, 0, sizeof(s_r_opt));
        s_r_opt.tweak = diff_tree_tweak_rev;
+       precompose_argv(argc, argv);
        argc = setup_revisions(argc, argv, opt, &s_r_opt);
  
        while (--argc > 0) {
                break;
        case 1:
                tree1 = opt->pending.objects[0].item;
 -              diff_tree_commit_sha1(tree1->sha1);
 +              diff_tree_commit_sha1(tree1->oid.hash);
                break;
        case 2:
                tree1 = opt->pending.objects[0].item;
                        tree2 = tree1;
                        tree1 = tmp;
                }
 -              diff_tree_sha1(tree1->sha1,
 -                             tree2->sha1,
 +              diff_tree_sha1(tree1->oid.hash,
 +                             tree2->oid.hash,
                               "", &opt->diffopt);
                log_tree_diff_flush(opt);
                break;
diff --combined builtin/diff.c
@@@ -175,8 -175,8 +175,8 @@@ static int builtin_diff_tree(struct rev
         */
        if (ent1->item->flags & UNINTERESTING)
                swap = 1;
 -      sha1[swap] = ent0->item->sha1;
 -      sha1[1 - swap] = ent1->item->sha1;
 +      sha1[swap] = ent0->item->oid.hash;
 +      sha1[1 - swap] = ent1->item->oid.hash;
        diff_tree_sha1(sha1[0], sha1[1], "", &revs->diffopt);
        log_tree_diff_flush(revs);
        return 0;
@@@ -196,8 -196,8 +196,8 @@@ static int builtin_diff_combined(struc
        if (!revs->dense_combined_merges && !revs->combine_merges)
                revs->dense_combined_merges = revs->combine_merges = 1;
        for (i = 1; i < ents; i++)
 -              sha1_array_append(&parents, ent[i].item->sha1);
 -      diff_tree_combined(ent[0].item->sha1, &parents,
 +              sha1_array_append(&parents, ent[i].item->oid.hash);
 +      diff_tree_combined(ent[0].item->oid.hash, &parents,
                           revs->dense_combined_merges, revs);
        sha1_array_clear(&parents);
        return 0;
@@@ -318,8 -318,8 +318,9 @@@ int cmd_diff(int argc, const char **arg
  
        if (!no_index)
                gitmodules_config();
 +      init_diff_ui_defaults();
        git_config(git_diff_ui_config, NULL);
+       precompose_argv(argc, argv);
  
        init_revisions(&rev, prefix);
  
        }
        if (no_index)
                /* If this is a no-index diff, just run it and exit there. */
 -              diff_no_index(&rev, argc, argv, prefix);
 +              diff_no_index(&rev, argc, argv);
  
        /* Otherwise, we are doing the usual "git" diff */
        rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
                const char *name = entry->name;
                int flags = (obj->flags & UNINTERESTING);
                if (!obj->parsed)
 -                      obj = parse_object(obj->sha1);
 +                      obj = parse_object(obj->oid.hash);
                obj = deref_tag(obj, NULL, 0);
                if (!obj)
                        die(_("invalid object '%s' given."), name);
                } else if (obj->type == OBJ_BLOB) {
                        if (2 <= blobs)
                                die(_("more than two blobs given: '%s'"), name);
 -                      hashcpy(blob[blobs].sha1, obj->sha1);
 +                      hashcpy(blob[blobs].sha1, obj->oid.hash);
                        blob[blobs].name = name;
                        blob[blobs].mode = entry->mode;
                        blobs++;