X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=revision.c;h=438cc87b17fa3a5a7b57c3fcdf4289cd869b79a7;hb=8acd141bb5cd4155d849fbfb3b74eb509608cd15;hp=4e1a299bfb822caa3eec94baca375de301a4cd73;hpb=4ca1b623865a9dc100f95a7867e35a9f73d7507a;p=git.git diff --git a/revision.c b/revision.c index 4e1a299bf..438cc87b1 100644 --- a/revision.c +++ b/revision.c @@ -134,10 +134,20 @@ static void add_pending_object_with_mode(struct rev_info *revs, struct object *o { if (revs->no_walk && (obj->flags & UNINTERESTING)) revs->no_walk = 0; - if (revs->reflog_info && obj->type == OBJ_COMMIT && - add_reflog_for_walk(revs->reflog_info, - (struct commit *)obj, name)) - return; + if (revs->reflog_info && obj->type == OBJ_COMMIT) { + struct strbuf buf = STRBUF_INIT; + int len = interpret_branch_name(name, &buf); + int st; + + if (0 < len && name[len] && buf.len) + strbuf_addstr(&buf, name + len); + st = add_reflog_for_walk(revs->reflog_info, + (struct commit *)obj, + buf.buf[0] ? buf.buf: name); + strbuf_release(&buf); + if (st) + return; + } add_object_array_with_mode(obj, name, &revs->pending, mode); } @@ -700,12 +710,18 @@ static int handle_one_ref(const char *path, const unsigned char *sha1, int flag, return 0; } +static void init_all_refs_cb(struct all_refs_cb *cb, struct rev_info *revs, + unsigned flags) +{ + cb->all_revs = revs; + cb->all_flags = 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; + init_all_refs_cb(&cb, revs, flags); for_each(handle_one_ref, &cb); } @@ -807,6 +823,7 @@ void init_revisions(struct rev_info *revs, const char *prefix) revs->grep_filter.status_only = 1; revs->grep_filter.pattern_tail = &(revs->grep_filter.pattern_list); + revs->grep_filter.header_tail = &(revs->grep_filter.header_list); revs->grep_filter.regflags = REG_NEWLINE; diff_setup(&revs->diffopt); @@ -1362,6 +1379,30 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch handle_refs(revs, flags, for_each_remote_ref); continue; } + if (!prefixcmp(arg, "--glob=")) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, flags); + for_each_glob_ref(handle_one_ref, arg + 7, &cb); + continue; + } + if (!prefixcmp(arg, "--branches=")) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, flags); + for_each_glob_ref_in(handle_one_ref, arg + 11, "refs/heads/", &cb); + continue; + } + if (!prefixcmp(arg, "--tags=")) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, flags); + for_each_glob_ref_in(handle_one_ref, arg + 7, "refs/tags/", &cb); + continue; + } + if (!prefixcmp(arg, "--remotes=")) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, flags); + for_each_glob_ref_in(handle_one_ref, arg + 10, "refs/remotes/", &cb); + continue; + } if (!strcmp(arg, "--reflog")) { handle_reflog(revs, flags); continue; @@ -1761,7 +1802,7 @@ static int rewrite_parents(struct rev_info *revs, struct commit *commit) static int commit_match(struct commit *commit, struct rev_info *opt) { - if (!opt->grep_filter.pattern_list) + if (!opt->grep_filter.pattern_list && !opt->grep_filter.header_list) return 1; return grep_buffer(&opt->grep_filter, NULL, /* we say nothing, not even filename */