path: root/builtin/grep.c
diff options
authorJunio C Hamano <>2017-06-02 06:06:05 (GMT)
committerJunio C Hamano <>2017-06-02 06:06:05 (GMT)
commit7ef0d047386a1932dc4a8b1008d851b0fe47f978 (patch)
tree164f1bd89b45be7337b44b0252a09bf7d4deffb5 /builtin/grep.c
parentf4fd99bf6e5c27265ee2a9ccb9c2495854f67acb (diff)
parent30d005c02014680403b5d35ef274047ab91fa5bd (diff)
Merge branch 'jk/diff-blob'
The result from "git diff" that compares two blobs, e.g. "git diff $commit1:$path $commit2:$path", used to be shown with the full object name as given on the command line, but it is more natural to use the $path in the output and use it to look up .gitattributes. * jk/diff-blob: diff: use blob path for blob/file diffs diff: use pending "path" if it is available diff: use the word "path" instead of "name" for blobs diff: pass whole pending entry in blobinfo handle_revision_arg: record paths for pending objects handle_revision_arg: record modes for "a..b" endpoints t4063: add tests of direct blob diffs get_sha1_with_context: dynamically allocate oc->path get_sha1_with_context: always initialize oc->symlink_path sha1_name: consistently refer to object_context as "oc" handle_revision_arg: add handle_dotdot() helper handle_revision_arg: hoist ".." check out of range parsing handle_revision_arg: stop using "dotdot" as a generic pointer handle_revision_arg: simplify commit reference lookups handle_revision_arg: reset "dotdot" consistently
Diffstat (limited to 'builtin/grep.c')
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index c6c26e9..72a1969 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -1190,7 +1190,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
- if (get_sha1_with_context(arg, 0, oid.hash, &oc)) {
+ if (get_sha1_with_context(arg, GET_SHA1_RECORD_PATH,
+ oid.hash, &oc)) {
if (seen_dashdash)
die(_("unable to resolve revision: %s"), arg);
@@ -1200,6 +1201,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
if (!seen_dashdash)
verify_non_filename(prefix, arg);
add_object_array_with_path(object, arg, &list, oc.mode, oc.path);
+ free(oc.path);