From: Junio C Hamano Date: Wed, 11 Feb 2009 09:40:12 +0000 (-0800) Subject: Merge branch 'maint-1.5.4' into maint-1.5.5 X-Git-Tag: v1.7.7.1~4^2~6^2^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/92798702cf6d201f80e257a07d0a0c40565c79fe?ds=inline;hp=-c Merge branch 'maint-1.5.4' into maint-1.5.5 * maint-1.5.4: revision traversal and pack: notice and die on missing commit --- 92798702cf6d201f80e257a07d0a0c40565c79fe diff --combined revision.c index ffbed3fbf2,b8c015eedd..07e5fcd86c --- a/revision.c +++ b/revision.c @@@ -46,8 -46,6 +46,8 @@@ void add_object(struct object *obj static void mark_blob_uninteresting(struct blob *blob) { + if (!blob) + return; if (blob->object.flags & UNINTERESTING) return; blob->object.flags |= UNINTERESTING; @@@ -59,8 -57,6 +59,8 @@@ void mark_tree_uninteresting(struct tre struct name_entry entry; struct object *obj = &tree->object; + if (!tree) + return; if (obj->flags & UNINTERESTING) return; obj->flags |= UNINTERESTING; @@@ -177,8 -173,6 +177,8 @@@ static struct commit *handle_commit(str struct tag *tag = (struct tag *) object; if (revs->tag_objects && !(flags & UNINTERESTING)) add_pending_object(revs, object, tag->tag); + if (!tag->tagged) + die("bad tag"); object = parse_object(tag->tagged->sha1); if (!object) die("bad object %s", sha1_to_hex(tag->tagged->sha1)); @@@ -564,39 -558,8 +564,39 @@@ static void cherry_pick_list(struct com free_patch_ids(&ids); } +/* How many extra uninteresting commits we want to see.. */ +#define SLOP 5 + +static int still_interesting(struct commit_list *src, unsigned long date, int slop) +{ + /* + * No source list at all? We're definitely done.. + */ + if (!src) + return 0; + + /* + * Does the destination list contain entries with a date + * before the source list? Definitely _not_ done. + */ + if (date < src->item->date) + return SLOP; + + /* + * Does the source list still have interesting commits in + * it? Definitely not done.. + */ + if (!everybody_uninteresting(src)) + return SLOP; + + /* Ok, we're closing in.. */ + return slop-1; +} + static int limit_list(struct rev_info *revs) { + int slop = SLOP; + unsigned long date = ~0ul; struct commit_list *list = revs->commits; struct commit_list *newlist = NULL; struct commit_list **p = &newlist; @@@ -616,19 -579,12 +616,19 @@@ return -1; if (obj->flags & UNINTERESTING) { mark_parents_uninteresting(commit); - if (everybody_uninteresting(list)) - break; - continue; + if (revs->show_all) + p = &commit_list_insert(commit, p)->next; + slop = still_interesting(list, date, slop); + if (slop) + continue; + /* If showing all, add the whole pending list to the end */ + if (revs->show_all) + *p = list; + break; } if (revs->min_age != -1 && (commit->date > revs->min_age)) continue; + date = commit->date; p = &commit_list_insert(commit, p)->next; show = show_early_output; @@@ -661,13 -617,12 +661,13 @@@ static int handle_one_ref(const char *p return 0; } -static void handle_all(struct rev_info *revs, unsigned flags) +static void handle_refs(struct rev_info *revs, unsigned flags, + int (*for_each)(each_ref_fn, void *)) { struct all_refs_cb cb; cb.all_revs = revs; cb.all_flags = flags; - for_each_ref(handle_one_ref, &cb); + for_each(handle_one_ref, &cb); } static void handle_one_reflog_commit(unsigned char *sha1, void *cb_data) @@@ -730,8 -685,6 +730,8 @@@ static int add_parents_only(struct rev_ it = get_reference(revs, arg, sha1, 0); if (it->type != OBJ_TAG) break; + if (!((struct tag*)it)->tagged) + return 0; hashcpy(sha1, ((struct tag*)it)->tagged->sha1); } if (it->type != OBJ_COMMIT) @@@ -767,10 -720,6 +767,10 @@@ void init_revisions(struct rev_info *re revs->commit_format = CMIT_FMT_DEFAULT; diff_setup(&revs->diffopt); + if (prefix && !revs->diffopt.prefix) { + revs->diffopt.prefix = prefix; + revs->diffopt.prefix_length = strlen(prefix); + } } static void add_pending_commit_list(struct rev_info *revs, @@@ -971,7 -920,6 +971,7 @@@ int setup_revisions(int argc, const cha int left = 1; int all_match = 0; int regflags = 0; + int fixed = 0; /* First, search for "--" */ seen_dashdash = 0; @@@ -1040,19 -988,7 +1040,19 @@@ continue; } if (!strcmp(arg, "--all")) { - handle_all(revs, flags); + handle_refs(revs, flags, for_each_ref); + continue; + } + if (!strcmp(arg, "--branches")) { + handle_refs(revs, flags, for_each_branch_ref); + continue; + } + if (!strcmp(arg, "--tags")) { + handle_refs(revs, flags, for_each_tag_ref); + continue; + } + if (!strcmp(arg, "--remotes")) { + handle_refs(revs, flags, for_each_remote_ref); continue; } if (!strcmp(arg, "--first-parent")) { @@@ -1116,10 -1052,6 +1116,10 @@@ revs->dense = 0; continue; } + if (!strcmp(arg, "--show-all")) { + revs->show_all = 1; + continue; + } if (!strcmp(arg, "--remove-empty")) { revs->remove_empty_trees = 1; continue; @@@ -1281,11 -1213,6 +1281,11 @@@ regflags |= REG_ICASE; continue; } + if (!strcmp(arg, "--fixed-strings") || + !strcmp(arg, "-F")) { + fixed = 1; + continue; + } if (!strcmp(arg, "--all-match")) { all_match = 1; continue; @@@ -1341,10 -1268,8 +1341,10 @@@ } } - if (revs->grep_filter) + if (revs->grep_filter) { revs->grep_filter->regflags |= regflags; + revs->grep_filter->fixed = fixed; + } if (show_merge) prepare_show_merge(revs); @@@ -1510,8 -1435,6 +1510,8 @@@ enum commit_action simplify_commit(stru return commit_ignore; if (revs->unpacked && has_sha1_pack(commit->object.sha1, revs->ignore_packed)) return commit_ignore; + if (revs->show_all) + return commit_show; if (commit->object.flags & UNINTERESTING) return commit_ignore; if (revs->min_age != -1 && (commit->date > revs->min_age)) @@@ -1561,14 -1484,16 +1561,16 @@@ static struct commit *get_revision_1(st (commit->date < revs->max_age)) continue; if (add_parents_to_list(revs, commit, &revs->commits) < 0) - return NULL; + die("Failed to traverse parents of commit %s", + sha1_to_hex(commit->object.sha1)); } switch (simplify_commit(revs, commit)) { case commit_ignore: continue; case commit_error: - return NULL; + die("Failed to simplify parents of commit %s", + sha1_to_hex(commit->object.sha1)); default: return commit; }