diff options
author | Michael J Gruber <git@drmicha.warpmail.net> | 2013-05-10 17:10:16 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-05-10 10:27:34 -0700 |
commit | afa15f3cd8f4cbf9572138329be374ff8566b10a (patch) | |
tree | ba8751467e428e397ec3e24ee648c3e1a4a520b5 /builtin | |
parent | 335ec3bf411ae6606b58885deb281192c86651c6 (diff) | |
download | git-afa15f3cd8f4cbf9572138329be374ff8566b10a.tar.gz git-afa15f3cd8f4cbf9572138329be374ff8566b10a.tar.xz |
grep: honor --textconv for the case rev:path
Make "grep" honor the "--textconv" option also for the object case, i.e.
when used with an argument "rev:path".
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/grep.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index 00ee57d47..bb7f970ca 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -458,10 +458,10 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec, } static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec, - struct object *obj, const char *name) + struct object *obj, const char *name, struct object_context *oc) { if (obj->type == OBJ_BLOB) - return grep_sha1(opt, obj->sha1, name, 0, NULL); + return grep_sha1(opt, obj->sha1, name, 0, oc ? oc->path : NULL); if (obj->type == OBJ_COMMIT || obj->type == OBJ_TREE) { struct tree_desc tree; void *data; @@ -503,7 +503,7 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec, for (i = 0; i < nr; i++) { struct object *real_obj; real_obj = deref_tag(list->objects[i].item, NULL, 0); - if (grep_object(opt, pathspec, real_obj, list->objects[i].name)) { + if (grep_object(opt, pathspec, real_obj, list->objects[i].name, list->objects[i].context)) { hit = 1; if (opt->status_only) break; @@ -820,12 +820,13 @@ int cmd_grep(int argc, const char **argv, const char *prefix) for (i = 0; i < argc; i++) { const char *arg = argv[i]; unsigned char sha1[20]; + struct object_context oc; /* Is it a rev? */ - if (!get_sha1(arg, sha1)) { + if (!get_sha1_with_context(arg, 0, sha1, &oc)) { struct object *object = parse_object_or_die(sha1, arg); if (!seen_dashdash) verify_non_filename(prefix, arg); - add_object_array(object, arg, &list); + add_object_array_with_context(object, arg, &list, xmemdupz(&oc, sizeof(struct object_context))); continue; } if (!strcmp(arg, "--")) { |