git-log(1): remove --full-line-diff description
[gitweb.git] / revision.c
index d7562ee5004379774c6fe1a74b0c503475a34ab5..3ad9d08c7fc02cd8d346715cb0a8b88fecfdbb36 100644 (file)
@@ -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;
@@ -1896,6 +1897,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,
@@ -2166,6 +2173,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)
@@ -2173,12 +2182,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;
@@ -2200,12 +2203,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:
@@ -2268,7 +2272,10 @@ static int commit_rewrite_person(struct strbuf *buf, const char *what, struct st
 static int commit_match(struct commit *commit, struct rev_info *opt)
 {
        int retval;
+       const char *encoding;
+       char *message;
        struct strbuf buf = STRBUF_INIT;
+
        if (!opt->grep_filter.pattern_list && !opt->grep_filter.header_list)
                return 1;
 
@@ -2279,13 +2286,23 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
                strbuf_addch(&buf, '\n');
        }
 
+       /*
+        * We grep in the user's output encoding, under the assumption that it
+        * is the encoding they are most likely to write their grep pattern
+        * for. In addition, it means we will match the "notes" encoding below,
+        * so we will not end up with a buffer that has two different encodings
+        * in it.
+        */
+       encoding = get_log_output_encoding();
+       message = logmsg_reencode(commit, encoding);
+
        /* Copy the commit to temporary if we are using "fake" headers */
        if (buf.len)
-               strbuf_addstr(&buf, commit->buffer);
+               strbuf_addstr(&buf, message);
 
        if (opt->grep_filter.header_list && opt->mailmap) {
                if (!buf.len)
-                       strbuf_addstr(&buf, commit->buffer);
+                       strbuf_addstr(&buf, message);
 
                commit_rewrite_person(&buf, "\nauthor ", opt->mailmap);
                commit_rewrite_person(&buf, "\ncommitter ", opt->mailmap);
@@ -2294,18 +2311,18 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
        /* Append "fake" message parts as needed */
        if (opt->show_notes) {
                if (!buf.len)
-                       strbuf_addstr(&buf, commit->buffer);
-               format_display_notes(commit->object.sha1, &buf,
-                                    get_log_output_encoding(), 1);
+                       strbuf_addstr(&buf, message);
+               format_display_notes(commit->object.sha1, &buf, encoding, 1);
        }
 
-       /* Find either in the commit object, or in the temporary */
+       /* Find either in the original commit message, or in the temporary */
        if (buf.len)
                retval = grep_buffer(&opt->grep_filter, buf.buf, buf.len);
        else
                retval = grep_buffer(&opt->grep_filter,
-                                    commit->buffer, strlen(commit->buffer));
+                                    message, strlen(message));
        strbuf_release(&buf);
+       logmsg_free(message, commit);
        return retval;
 }
 
@@ -2358,7 +2375,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;