Code

Fix per-directory exclude handing for "git add"
[git.git] / revision.c
index 28b5f2eacebf637323fa0af112ea568beb95c7f3..48756b5d4466d06123922573e4330fc4344c1dcb 100644 (file)
@@ -118,10 +118,11 @@ static void add_pending_object_with_mode(struct rev_info *revs, struct object *o
 {
        if (revs->no_walk && (obj->flags & UNINTERESTING))
                die("object ranges do not make sense when not walking revisions");
+       if (revs->reflog_info && obj->type == OBJ_COMMIT &&
+                       add_reflog_for_walk(revs->reflog_info,
+                               (struct commit *)obj, name))
+               return;
        add_object_array_with_mode(obj, name, &revs->pending, mode);
-       if (revs->reflog_info && obj->type == OBJ_COMMIT)
-               add_reflog_for_walk(revs->reflog_info,
-                               (struct commit *)obj, name);
 }
 
 void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
@@ -895,7 +896,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                        continue;
                argv[i] = NULL;
                argc = i;
-               revs->prune_data = get_pathspec(revs->prefix, argv + i + 1);
+               if (argv[i + 1])
+                       revs->prune_data = get_pathspec(revs->prefix, argv + i + 1);
                seen_dashdash = 1;
                break;
        }
@@ -1022,6 +1024,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                        }
                        if (!strcmp(arg, "--cherry-pick")) {
                                revs->cherry_pick = 1;
+                               revs->limited = 1;
                                continue;
                        }
                        if (!strcmp(arg, "--objects")) {
@@ -1149,6 +1152,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                                        die("unknown date format %s", arg);
                                continue;
                        }
+                       if (!strcmp(arg, "--log-size")) {
+                               revs->show_log_size = 1;
+                               continue;
+                       }
 
                        /*
                         * Grepping the commit log
@@ -1165,11 +1172,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                                add_message_grep(revs, arg+7);
                                continue;
                        }
-                       if (!prefixcmp(arg, "--extended-regexp")) {
+                       if (!strcmp(arg, "--extended-regexp") ||
+                           !strcmp(arg, "-E")) {
                                regflags |= REG_EXTENDED;
                                continue;
                        }
-                       if (!prefixcmp(arg, "--regexp-ignore-case")) {
+                       if (!strcmp(arg, "--regexp-ignore-case") ||
+                           !strcmp(arg, "-i")) {
                                regflags |= REG_ICASE;
                                continue;
                        }
@@ -1189,11 +1198,17 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                                revs->reverse ^= 1;
                                continue;
                        }
+                       if (!strcmp(arg, "--no-walk")) {
+                               revs->no_walk = 1;
+                               continue;
+                       }
+                       if (!strcmp(arg, "--do-walk")) {
+                               revs->no_walk = 0;
+                               continue;
+                       }
 
                        opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
                        if (opts > 0) {
-                               if (strcmp(argv[i], "-z"))
-                                       revs->diff = 1;
                                i += opts - 1;
                                continue;
                        }
@@ -1237,6 +1252,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                add_pending_object_with_mode(revs, object, def, mode);
        }
 
+       /* Did the user ask for any diff output? Run the diff! */
+       if (revs->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT)
+               revs->diff = 1;
+
+       /* Pickaxe and rename following needs diffs */
+       if (revs->diffopt.pickaxe || revs->diffopt.follow_renames)
+               revs->diff = 1;
+
        if (revs->topo_order)
                revs->limited = 1;
 
@@ -1262,6 +1285,9 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                compile_grep_patterns(revs->grep_filter);
        }
 
+       if (revs->reverse && revs->reflog_info)
+               die("cannot combine --reverse with --walk-reflogs");
+
        return left;
 }
 
@@ -1323,16 +1349,17 @@ static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp
 
 static void remove_duplicate_parents(struct commit *commit)
 {
-       struct commit_list *p;
-       struct commit_list **pp = &commit->parents;
+       struct commit_list **pp, *p;
 
        /* Examine existing parents while marking ones we have seen... */
-       for (p = commit->parents; p; p = p->next) {
+       pp = &commit->parents;
+       while ((p = *pp) != NULL) {
                struct commit *parent = p->item;
-               if (parent->object.flags & TMP_MARK)
+               if (parent->object.flags & TMP_MARK) {
+                       *pp = p->next;
                        continue;
+               }
                parent->object.flags |= TMP_MARK;
-               *pp = p;
                pp = &p->next;
        }
        /* ... and clear the temporary mark */