Code

Merge branch 'js/rerere'
[git.git] / revision.c
index 36cdfcd1ad80caf8545cc02da7881fa92414d665..4dae5342eb6e14758c93fa4b2942d7c053111d04 100644 (file)
@@ -6,7 +6,6 @@
 #include "diff.h"
 #include "refs.h"
 #include "revision.h"
-#include <regex.h>
 #include "grep.h"
 
 static char *path_name(struct name_path *path, const char *name)
@@ -344,6 +343,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
 static void add_parents_to_list(struct rev_info *revs, struct commit *commit, struct commit_list **list)
 {
        struct commit_list *parent = commit->parents;
+       unsigned left_flag;
 
        if (commit->object.flags & ADDED)
                return;
@@ -388,6 +388,7 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
        if (revs->no_walk)
                return;
 
+       left_flag = (commit->object.flags & SYMMETRIC_LEFT);
        parent = commit->parents;
        while (parent) {
                struct commit *p = parent->item;
@@ -395,6 +396,7 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
                parent = parent->next;
 
                parse_commit(p);
+               p->object.flags |= left_flag;
                if (p->object.flags & SEEN)
                        continue;
                p->object.flags |= SEEN;
@@ -465,7 +467,7 @@ static void limit_list(struct rev_info *revs)
 static int all_flags;
 static struct rev_info *all_revs;
 
-static int handle_one_ref(const char *path, const unsigned char *sha1)
+static int handle_one_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
 {
        struct object *object = get_reference(all_revs, path, sha1, all_flags);
        add_pending_object(all_revs, object, "");
@@ -476,7 +478,7 @@ static void handle_all(struct rev_info *revs, unsigned flags)
 {
        all_revs = revs;
        all_flags = flags;
-       for_each_ref(handle_one_ref);
+       for_each_ref(handle_one_ref, NULL);
 }
 
 static int add_parents_only(struct rev_info *revs, const char *arg, int flags)
@@ -640,7 +642,7 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
                                add_pending_commit_list(revs, exclude,
                                                        flags_exclude);
                                free_commit_list(exclude);
-                               a->object.flags |= flags;
+                               a->object.flags |= flags | SYMMETRIC_LEFT;
                        } else
                                a->object.flags |= flags_exclude;
                        b->object.flags |= flags;
@@ -657,6 +659,13 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
                        return 0;
                *dotdot = '^';
        }
+       dotdot = strstr(arg, "^!");
+       if (dotdot && !dotdot[2]) {
+               *dotdot = 0;
+               if (!add_parents_only(revs, arg, flags ^ UNINTERESTING))
+                       *dotdot = '^';
+       }
+
        local_flags = 0;
        if (*arg == '^') {
                local_flags = UNINTERESTING;
@@ -729,6 +738,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
        int i, flags, seen_dashdash, show_merge;
        const char **unrecognized = argv + 1;
        int left = 1;
+       int all_match = 0;
 
        /* First, search for "--" */
        seen_dashdash = 0;
@@ -842,6 +852,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                                revs->boundary = 1;
                                continue;
                        }
+                       if (!strcmp(arg, "--left-right")) {
+                               revs->left_right = 1;
+                               continue;
+                       }
                        if (!strcmp(arg, "--objects")) {
                                revs->tag_objects = 1;
                                revs->tree_objects = 1;
@@ -964,6 +978,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                                add_message_grep(revs, arg+7);
                                continue;
                        }
+                       if (!strcmp(arg, "--all-match")) {
+                               all_match = 1;
+                               continue;
+                       }
 
                        opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
                        if (opts > 0) {
@@ -1025,8 +1043,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
        if (diff_setup_done(&revs->diffopt) < 0)
                die("diff_setup_done failed");
 
-       if (revs->grep_filter)
+       if (revs->grep_filter) {
+               revs->grep_filter->all_match = all_match;
                compile_grep_patterns(revs->grep_filter);
+       }
 
        return left;
 }