X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=revision.c;h=75c648c13c6c50335ffc3e79f5d6303bea20104e;hb=ae448e3854d8b6e7e37aa88fa3917f5dd97f3210;hp=b6ed0149a5c3f34b4747bfcdedf4b2251b0a69ce;hpb=95a31cc5b32c5ab787e419124826ac202a00b7f5;p=git.git diff --git a/revision.c b/revision.c index b6ed0149..75c648c1 100644 --- a/revision.c +++ b/revision.c @@ -53,8 +53,9 @@ static void mark_blob_uninteresting(struct blob *blob) void mark_tree_uninteresting(struct tree *tree) { + struct tree_desc desc; + struct name_entry entry; struct object *obj = &tree->object; - struct tree_entry_list *entry; if (obj->flags & UNINTERESTING) return; @@ -63,17 +64,22 @@ void mark_tree_uninteresting(struct tree *tree) return; if (parse_tree(tree) < 0) die("bad tree %s", sha1_to_hex(obj->sha1)); - entry = tree->entries; - tree->entries = NULL; - while (entry) { - struct tree_entry_list *next = entry->next; - if (entry->directory) - mark_tree_uninteresting(entry->item.tree); + + desc.buf = tree->buffer; + desc.size = tree->size; + while (tree_entry(&desc, &entry)) { + if (S_ISDIR(entry.mode)) + mark_tree_uninteresting(lookup_tree(entry.sha1)); else - mark_blob_uninteresting(entry->item.blob); - free(entry); - entry = next; + mark_blob_uninteresting(lookup_blob(entry.sha1)); } + + /* + * We don't care about the tree any more + * after it has been marked uninteresting. + */ + free(tree->buffer); + tree->buffer = NULL; } void mark_parents_uninteresting(struct commit *commit) @@ -297,7 +303,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit) parse_commit(p); switch (rev_compare_tree(revs, p->tree, commit->tree)) { case REV_TREE_SAME: - if (p->object.flags & UNINTERESTING) { + if (!revs->simplify_history || (p->object.flags & UNINTERESTING)) { /* Even if a merge with an uninteresting * side branch brought the entire change * we are interested in, we do not want @@ -477,12 +483,43 @@ static void handle_all(struct rev_info *revs, unsigned flags) for_each_ref(handle_one_ref); } +static int add_parents_only(struct rev_info *revs, const char *arg, int flags) +{ + unsigned char sha1[20]; + struct object *it; + struct commit *commit; + struct commit_list *parents; + + if (*arg == '^') { + flags ^= UNINTERESTING; + arg++; + } + if (get_sha1(arg, sha1)) + return 0; + while (1) { + it = get_reference(revs, arg, sha1, 0); + if (strcmp(it->type, tag_type)) + break; + memcpy(sha1, ((struct tag*)it)->tagged->sha1, 20); + } + if (strcmp(it->type, commit_type)) + return 0; + commit = (struct commit *)it; + for (parents = commit->parents; parents; parents = parents->next) { + it = &parents->item->object; + it->flags |= flags; + add_pending_object(revs, it, arg); + } + return 1; +} + void init_revisions(struct rev_info *revs) { memset(revs, 0, sizeof(*revs)); revs->abbrev = DEFAULT_ABBREV; revs->ignore_merges = 1; + revs->simplify_history = 1; revs->pruning.recursive = 1; revs->pruning.add_remove = file_add_remove; revs->pruning.change = file_change; @@ -544,7 +581,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch revs->max_count = atoi(arg + 12); continue; } - /* accept -, like traditilnal "head" */ + /* accept -, like traditional "head" */ if ((*arg == '-') && isdigit(arg[1])) { revs->max_count = atoi(arg + 1); continue; @@ -664,6 +701,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch } if (!strcmp(arg, "-c")) { revs->diff = 1; + revs->dense_combined_merges = 0; revs->combine_merges = 1; continue; } @@ -702,6 +740,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch revs->abbrev = DEFAULT_ABBREV; continue; } + if (!strncmp(arg, "--abbrev=", 9)) { + revs->abbrev = strtoul(arg + 9, NULL, 10); + if (revs->abbrev < MINIMUM_ABBREV) + revs->abbrev = MINIMUM_ABBREV; + else if (revs->abbrev > 40) + revs->abbrev = 40; + continue; + } if (!strcmp(arg, "--abbrev-commit")) { revs->abbrev_commit = 1; continue; @@ -711,6 +757,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch revs->full_diff = 1; continue; } + if (!strcmp(arg, "--full-history")) { + revs->simplify_history = 0; + continue; + } opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i); if (opts > 0) { revs->diff = 1; @@ -751,12 +801,19 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch } *dotdot = '.'; } + dotdot = strstr(arg, "^@"); + if (dotdot && !dotdot[2]) { + *dotdot = 0; + if (add_parents_only(revs, arg, flags)) + continue; + *dotdot = '^'; + } local_flags = 0; if (*arg == '^') { local_flags = UNINTERESTING; arg++; } - if (get_sha1(arg, sha1) < 0) { + if (get_sha1(arg, sha1)) { int j; if (seen_dashdash || local_flags) @@ -782,7 +839,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch if (def && !revs->pending_objects) { unsigned char sha1[20]; struct object *object; - if (get_sha1(def, sha1) < 0) + if (get_sha1(def, sha1)) die("bad default revision '%s'", def); object = get_reference(revs, def, sha1, 0); add_pending_object(revs, object, def);