Merge branch 'rs/simplify-by-deco-with-deco-refs-exclude'
authorJunio C Hamano <gitster@pobox.com>
Mon, 7 Oct 2019 02:32:54 +0000 (11:32 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Oct 2019 02:32:54 +0000 (11:32 +0900)
"git log --decorate-refs-exclude=<pattern>" was incorrectly
overruled when the "--simplify-by-decoration" option is used, which
has been corrected.

* rs/simplify-by-deco-with-deco-refs-exclude:
  log-tree: call load_ref_decorations() in get_name_decoration()
  log: test --decorate-refs-exclude with --simplify-by-decoration

1  2 
log-tree.c
revision.c
t/t4202-log.sh

diff --combined log-tree.c
@@@ -77,6 -77,7 +77,7 @@@ void add_name_decoration(enum decoratio
  
  const struct name_decoration *get_name_decoration(const struct object *obj)
  {
+       load_ref_decorations(NULL, DECORATE_SHORT_REFS);
        return lookup_decoration(&name_decoration, obj);
  }
  
@@@ -677,7 -678,9 +678,7 @@@ void show_log(struct rev_info *opt
                raw = (opt->commit_format == CMIT_FMT_USERFORMAT);
                format_display_notes(&commit->object.oid, &notebuf,
                                     get_log_output_encoding(), raw);
 -              ctx.notes_message = notebuf.len
 -                      ? strbuf_detach(&notebuf, NULL)
 -                      : xcalloc(1, 1);
 +              ctx.notes_message = strbuf_detach(&notebuf, NULL);
        }
  
        /*
diff --combined revision.c
@@@ -404,7 -404,9 +404,7 @@@ static struct commit *handle_commit(str
                struct tag *tag = (struct tag *) object;
                if (revs->tag_objects && !(flags & UNINTERESTING))
                        add_pending_object(revs, object, tag->tag);
 -              if (!tag->tagged)
 -                      die("bad tag");
 -              object = parse_object(revs->repo, &tag->tagged->oid);
 +              object = parse_object(revs->repo, get_tagged_oid(tag));
                if (!object) {
                        if (revs->ignore_missing_links || (flags & UNINTERESTING))
                                return NULL;
@@@ -2061,7 -2063,6 +2061,6 @@@ static int handle_revision_opt(struct r
                revs->simplify_by_decoration = 1;
                revs->limited = 1;
                revs->prune = 1;
-               load_ref_decorations(NULL, DECORATE_SHORT_REFS);
        } else if (!strcmp(arg, "--date-order")) {
                revs->sort_order = REV_SORT_BY_COMMIT_DATE;
                revs->topo_order = 1;
@@@ -2521,7 -2522,6 +2520,7 @@@ int setup_revisions(int argc, const cha
        int i, flags, left, seen_dashdash, got_rev_arg = 0, revarg_opt;
        struct argv_array prune_data = ARGV_ARRAY_INIT;
        const char *submodule = NULL;
 +      int seen_end_of_options = 0;
  
        if (opt)
                submodule = opt->submodule;
                revarg_opt |= REVARG_CANNOT_BE_FILENAME;
        for (left = i = 1; i < argc; i++) {
                const char *arg = argv[i];
 -              if (*arg == '-') {
 +              if (!seen_end_of_options && *arg == '-') {
                        int opts;
  
                        opts = handle_revision_pseudo_opt(submodule,
                                continue;
                        }
  
 +                      if (!strcmp(arg, "--end-of-options")) {
 +                              seen_end_of_options = 1;
 +                              continue;
 +                      }
 +
                        opts = handle_revision_opt(revs, argc - i, argv + i,
                                                   &left, argv, opt);
                        if (opts > 0) {
diff --combined t/t4202-log.sh
@@@ -837,6 -837,21 +837,21 @@@ test_expect_success 'decorate-refs and 
        test_cmp expect.decorate actual
  '
  
+ test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
+       cat >expect.decorate <<-\EOF &&
+       Merge-tag-reach (HEAD -> master)
+       reach (tag: reach, reach)
+       seventh (tag: seventh)
+       Merge-branch-tangle
+       Merge-branch-side-early-part-into-tangle (tangle)
+       tangle-a (tag: tangle-a)
+       EOF
+       git log -n6 --decorate=short --pretty="tformat:%f%d" \
+               --decorate-refs-exclude="*octopus*" \
+               --simplify-by-decoration >actual &&
+       test_cmp expect.decorate actual
+ '
  test_expect_success 'log.decorate config parsing' '
        git log --oneline --decorate=full >expect.full &&
        git log --oneline --decorate=short >expect.short &&
@@@ -1707,11 -1722,4 +1722,11 @@@ test_expect_success '--exclude-promisor
        test_must_fail git log --exclude-promisor-objects source-a
  '
  
 +test_expect_success 'log --end-of-options' '
 +       git update-ref refs/heads/--source HEAD &&
 +       git log --end-of-options --source >actual &&
 +       git log >expect &&
 +       test_cmp expect actual
 +'
 +
  test_done