diffcore-rename: use is_empty_blob_oid
[gitweb.git] / grep.c
diff --git a/grep.c b/grep.c
index 47cee4506703f5dd2b7db84e09dae93adf99fbaf..3e21c92b9d49a2b68062158c47204f6dfdaa1c64 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -1403,11 +1403,11 @@ static int fill_textconv_grep(struct userdiff_driver *driver,
         */
        df = alloc_filespec(gs->path);
        switch (gs->type) {
-       case GREP_SOURCE_SHA1:
+       case GREP_SOURCE_OID:
                fill_filespec(df, gs->identifier, 1, 0100644);
                break;
        case GREP_SOURCE_FILE:
-               fill_filespec(df, null_sha1, 0, 0100644);
+               fill_filespec(df, &null_oid, 0, 0100644);
                break;
        default:
                die("BUG: attempt to textconv something without a path?");
@@ -1747,9 +1747,8 @@ void grep_source_init(struct grep_source *gs, enum grep_source_type type,
                 * If the identifier is non-NULL (in the submodule case) it
                 * will be a SHA1 that needs to be copied.
                 */
-       case GREP_SOURCE_SHA1:
-               gs->identifier = xmalloc(20);
-               hashcpy(gs->identifier, identifier);
+       case GREP_SOURCE_OID:
+               gs->identifier = oiddup(identifier);
                break;
        case GREP_SOURCE_BUF:
                gs->identifier = NULL;
@@ -1772,7 +1771,7 @@ void grep_source_clear_data(struct grep_source *gs)
 {
        switch (gs->type) {
        case GREP_SOURCE_FILE:
-       case GREP_SOURCE_SHA1:
+       case GREP_SOURCE_OID:
        case GREP_SOURCE_SUBMODULE:
                free(gs->buf);
                gs->buf = NULL;
@@ -1784,7 +1783,7 @@ void grep_source_clear_data(struct grep_source *gs)
        }
 }
 
-static int grep_source_load_sha1(struct grep_source *gs)
+static int grep_source_load_oid(struct grep_source *gs)
 {
        enum object_type type;
 
@@ -1795,7 +1794,7 @@ static int grep_source_load_sha1(struct grep_source *gs)
        if (!gs->buf)
                return error(_("'%s': unable to read %s"),
                             gs->name,
-                            sha1_to_hex(gs->identifier));
+                            oid_to_hex(gs->identifier));
        return 0;
 }
 
@@ -1841,8 +1840,8 @@ static int grep_source_load(struct grep_source *gs)
        switch (gs->type) {
        case GREP_SOURCE_FILE:
                return grep_source_load_file(gs);
-       case GREP_SOURCE_SHA1:
-               return grep_source_load_sha1(gs);
+       case GREP_SOURCE_OID:
+               return grep_source_load_oid(gs);
        case GREP_SOURCE_BUF:
                return gs->buf ? 0 : -1;
        case GREP_SOURCE_SUBMODULE: