X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=revision.c;h=518cd086939f306f8fc6d1228bd6e61ea6d0bc22;hb=ed73fe56428eecd2b635473f6a517a183c4713a3;hp=eb981288686a2c7cd8c854e3f414b606ed4f8c69;hpb=574d51b575d9025d57c610c3b571ca58d347d0da;p=~andy%2Fgit diff --git a/revision.c b/revision.c index eb9812886..518cd0869 100644 --- a/revision.c +++ b/revision.c @@ -13,6 +13,7 @@ #include "decorate.h" #include "log-tree.h" #include "string-list.h" +#include "line-log.h" #include "mailmap.h" volatile show_early_output_fn_t show_early_output; @@ -915,6 +916,19 @@ static void add_rev_cmdline(struct rev_info *revs, info->nr++; } +static void add_rev_cmdline_list(struct rev_info *revs, + struct commit_list *commit_list, + int whence, + unsigned flags) +{ + while (commit_list) { + struct object *object = &commit_list->item->object; + add_rev_cmdline(revs, object, sha1_to_hex(object->sha1), + whence, flags); + commit_list = commit_list->next; + } +} + struct all_refs_cb { int all_flags; int warned_bad_reflog; @@ -1092,6 +1106,7 @@ static void prepare_show_merge(struct rev_info *revs) add_pending_object(revs, &head->object, "HEAD"); add_pending_object(revs, &other->object, "MERGE_HEAD"); bases = get_merge_bases(head, other, 1); + add_rev_cmdline_list(revs, bases, REV_CMD_MERGE_BASE, UNINTERESTING); add_pending_commit_list(revs, bases, UNINTERESTING); free_commit_list(bases); head->object.flags |= SYMMETRIC_LEFT; @@ -1179,6 +1194,9 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi if (symmetric) { exclude = get_merge_bases(a, b, 1); + add_rev_cmdline_list(revs, exclude, + REV_CMD_MERGE_BASE, + flags_exclude); add_pending_commit_list(revs, exclude, flags_exclude); free_commit_list(exclude); @@ -1276,7 +1294,8 @@ static void read_revisions_from_stdin(struct rev_info *revs, } die("options not supported in --stdin mode"); } - if (handle_revision_arg(sb.buf, revs, 0, REVARG_CANNOT_BE_FILENAME)) + if (handle_revision_arg(xstrdup(sb.buf), revs, 0, + REVARG_CANNOT_BE_FILENAME)) die("bad revision '%s'", sb.buf); } if (seen_dashdash) @@ -1896,6 +1915,12 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s if (revs->combine_merges) revs->ignore_merges = 0; revs->diffopt.abbrev = revs->abbrev; + + if (revs->line_level_traverse) { + revs->limited = 1; + revs->topo_order = 1; + } + diff_setup_done(&revs->diffopt); grep_commit_pattern_type(GREP_PATTERN_TYPE_UNSPECIFIED, @@ -2167,6 +2192,8 @@ int prepare_revision_walk(struct rev_info *revs) return -1; if (revs->topo_order) sort_in_topological_order(&revs->commits, revs->lifo); + if (revs->line_level_traverse) + line_log_filter(revs); if (revs->simplify_merges) simplify_merges(revs); if (revs->children.name) @@ -2174,12 +2201,6 @@ int prepare_revision_walk(struct rev_info *revs) return 0; } -enum rewrite_result { - rewrite_one_ok, - rewrite_one_noparents, - rewrite_one_error -}; - static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp) { struct commit_list *cache = NULL; @@ -2201,12 +2222,13 @@ static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp } } -static int rewrite_parents(struct rev_info *revs, struct commit *commit) +int rewrite_parents(struct rev_info *revs, struct commit *commit, + rewrite_parent_fn_t rewrite_parent) { struct commit_list **pp = &commit->parents; while (*pp) { struct commit_list *parent = *pp; - switch (rewrite_one(revs, &parent->item)) { + switch (rewrite_parent(revs, &parent->item)) { case rewrite_one_ok: break; case rewrite_one_noparents: @@ -2291,7 +2313,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt) * in it. */ encoding = get_log_output_encoding(); - message = logmsg_reencode(commit, encoding); + message = logmsg_reencode(commit, NULL, encoding); /* Copy the commit to temporary if we are using "fake" headers */ if (buf.len) @@ -2372,7 +2394,7 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit) if (action == commit_show && !revs->show_all && revs->prune && revs->dense && want_ancestry(revs)) { - if (rewrite_parents(revs, commit) < 0) + if (rewrite_parents(revs, commit, rewrite_one) < 0) return commit_error; } return action;