submodule: try harder to fetch needed sha1 by direct fetching sha1
[gitweb.git] / builtin / fast-export.c
index 30faf248f73618a0a5c5e09118a9f0cf9d6b7b2a..2471297f7101964c61c055b10e24a7aa4b65326a 100644 (file)
@@ -544,13 +544,13 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
        author = strstr(commit_buffer, "\nauthor ");
        if (!author)
                die ("Could not find author in commit %s",
-                    sha1_to_hex(commit->object.sha1));
+                    oid_to_hex(&commit->object.oid));
        author++;
        author_end = strchrnul(author, '\n');
        committer = strstr(author_end, "\ncommitter ");
        if (!committer)
                die ("Could not find committer in commit %s",
-                    sha1_to_hex(commit->object.sha1));
+                    oid_to_hex(&commit->object.oid));
        committer++;
        committer_end = strchrnul(committer, '\n');
        message = strstr(committer_end, "\n\n");
@@ -562,11 +562,11 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
            get_object_mark(&commit->parents->item->object) != 0 &&
            !full_tree) {
                parse_commit_or_die(commit->parents->item);
-               diff_tree_sha1(get_object_hash(commit->parents->item->tree->object),
-                              get_object_hash(commit->tree->object), "", &rev->diffopt);
+               diff_tree_sha1(commit->parents->item->tree->object.oid.hash,
+                              commit->tree->object.oid.hash, "", &rev->diffopt);
        }
        else
-               diff_root_tree_sha1(get_object_hash(commit->tree->object),
+               diff_root_tree_sha1(commit->tree->object.oid.hash,
                                    "", &rev->diffopt);
 
        /* Export the referenced blobs, and remember the marks. */
@@ -661,13 +661,13 @@ static void handle_tag(const char *name, struct tag *tag)
        }
        if (tagged->type == OBJ_TREE) {
                warning("Omitting tag %s,\nsince tags of trees (or tags of tags of trees, etc.) are not supported.",
-                       sha1_to_hex(tag->object.sha1));
+                       oid_to_hex(&tag->object.oid));
                return;
        }
 
-       buf = read_sha1_file(get_object_hash(tag->object), &type, &size);
+       buf = read_sha1_file(tag->object.oid.hash, &type, &size);
        if (!buf)
-               die ("Could not read tag %s", sha1_to_hex(tag->object.sha1));
+               die ("Could not read tag %s", oid_to_hex(&tag->object.oid));
        message = memmem(buf, size, "\n\n", 2);
        if (message) {
                message += 2;
@@ -706,16 +706,16 @@ static void handle_tag(const char *name, struct tag *tag)
                        case ABORT:
                                die ("Encountered signed tag %s; use "
                                     "--signed-tags=<mode> to handle it.",
-                                    sha1_to_hex(tag->object.sha1));
+                                    oid_to_hex(&tag->object.oid));
                        case WARN:
                                warning ("Exporting signed tag %s",
-                                        sha1_to_hex(tag->object.sha1));
+                                        oid_to_hex(&tag->object.oid));
                                /* fallthru */
                        case VERBATIM:
                                break;
                        case WARN_STRIP:
                                warning ("Stripping signature from tag %s",
-                                        sha1_to_hex(tag->object.sha1));
+                                        oid_to_hex(&tag->object.oid));
                                /* fallthru */
                        case STRIP:
                                message_size = signature + 1 - message;
@@ -731,14 +731,14 @@ static void handle_tag(const char *name, struct tag *tag)
                case ABORT:
                        die ("Tag %s tags unexported object; use "
                             "--tag-of-filtered-object=<mode> to handle it.",
-                            sha1_to_hex(tag->object.sha1));
+                            oid_to_hex(&tag->object.oid));
                case DROP:
                        /* Ignore this tag altogether */
                        return;
                case REWRITE:
                        if (tagged->type != OBJ_COMMIT) {
                                die ("Tag %s tags unexported %s!",
-                                    sha1_to_hex(tag->object.sha1),
+                                    oid_to_hex(&tag->object.oid),
                                     typename(tagged->type));
                        }
                        p = (struct commit *)tagged;
@@ -751,7 +751,7 @@ static void handle_tag(const char *name, struct tag *tag)
                                        break;
                                if (!p->parents)
                                        die ("Can't find replacement commit for tag %s\n",
-                                            sha1_to_hex(tag->object.sha1));
+                                            oid_to_hex(&tag->object.oid));
                                p = p->parents->item;
                        }
                        tagged_mark = get_object_mark(&p->object);
@@ -777,7 +777,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)
 
                /* handle nested tags */
                while (tag && tag->object.type == OBJ_TAG) {
-                       parse_object(get_object_hash(tag->object));
+                       parse_object(tag->object.oid.hash);
                        string_list_append(&extra_refs, full_name)->util = tag;
                        tag = (struct tag *)tag->tagged;
                }
@@ -828,7 +828,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
                case OBJ_COMMIT:
                        break;
                case OBJ_BLOB:
-                       export_blob(get_object_hash(commit->object));
+                       export_blob(commit->object.oid.hash);
                        continue;
                default: /* OBJ_TAG (nested tags) is already handled */
                        warning("Tag points to object of unexpected type %s, skipping.",
@@ -880,7 +880,7 @@ static void export_marks(char *file)
        FILE *f;
        int e = 0;
 
-       f = fopen(file, "w");
+       f = fopen_for_writing(file);
        if (!f)
                die_errno("Unable to open marks file %s for writing.", file);
 
@@ -888,7 +888,7 @@ static void export_marks(char *file)
                if (deco->base && deco->base->type == 1) {
                        mark = ptr_to_mark(deco->decoration);
                        if (fprintf(f, ":%"PRIu32" %s\n", mark,
-                               sha1_to_hex(deco->base->sha1)) < 0) {
+                               oid_to_hex(&deco->base->oid)) < 0) {
                            e = 1;
                            break;
                        }