diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-25T23·06+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-25T23·06+0100 |
commit | 93ba78d6f4632ef1c5228965e3edc8c0faf88c1e (patch) | |
tree | 85730c182a9f5f492ade8e8ccdb1c2356f9900bd /third_party/git/builtin/fast-export.c | |
parent | 6f8fbf4aa4b1654ab27d4829e114538761817de0 (diff) |
revert(3p/git): Revert merge of git upstream at v2.26.2 r/852
This causes cgit to serve error pages, which is undesirable. This reverts commit 5229c9b232de5bfa959ad6ebbb4c8192ac513352, reversing changes made to f2b211131f2347342dde63975b09cf603149f1a3.
Diffstat (limited to 'third_party/git/builtin/fast-export.c')
-rw-r--r-- | third_party/git/builtin/fast-export.c | 88 |
1 files changed, 25 insertions, 63 deletions
diff --git a/third_party/git/builtin/fast-export.c b/third_party/git/builtin/fast-export.c index 85868162eec9..f541f55d333b 100644 --- a/third_party/git/builtin/fast-export.c +++ b/third_party/git/builtin/fast-export.c @@ -40,7 +40,6 @@ static int no_data; static int full_tree; static int reference_excluded_commits; static int show_original_ids; -static int mark_tags; static struct string_list extra_refs = STRING_LIST_INIT_NODUP; static struct string_list tag_refs = STRING_LIST_INIT_NODUP; static struct refspec refspecs = REFSPEC_INIT_FETCH; @@ -127,15 +126,10 @@ struct anonymized_entry { }; static int anonymized_entry_cmp(const void *unused_cmp_data, - const struct hashmap_entry *eptr, - const struct hashmap_entry *entry_or_key, + const void *va, const void *vb, const void *unused_keydata) { - const struct anonymized_entry *a, *b; - - a = container_of(eptr, const struct anonymized_entry, hash); - b = container_of(entry_or_key, const struct anonymized_entry, hash); - + const struct anonymized_entry *a = va, *b = vb; return a->orig_len != b->orig_len || memcmp(a->orig, b->orig, a->orig_len); } @@ -154,10 +148,10 @@ static const void *anonymize_mem(struct hashmap *map, if (!map->cmpfn) hashmap_init(map, anonymized_entry_cmp, NULL, 0); - hashmap_entry_init(&key.hash, memhash(orig, *len)); + hashmap_entry_init(&key, memhash(orig, *len)); key.orig = orig; key.orig_len = *len; - ret = hashmap_get_entry(map, &key, hash, NULL); + ret = hashmap_get(map, &key, NULL); if (!ret) { ret = xmalloc(sizeof(*ret)); @@ -166,7 +160,7 @@ static const void *anonymize_mem(struct hashmap *map, ret->orig_len = *len; ret->anon = generate(orig, len); ret->anon_len = *len; - hashmap_put(map, &ret->hash); + hashmap_put(map, ret); } *len = ret->anon_len; @@ -293,8 +287,7 @@ static void export_blob(const struct object_id *oid) buf = read_object_file(oid, &type, &size); if (!buf) die("could not read blob %s", oid_to_hex(oid)); - if (check_object_signature(the_repository, oid, buf, size, - type_name(type)) < 0) + if (check_object_signature(oid, buf, size, type_name(type)) < 0) die("oid mismatch in blob %s", oid_to_hex(oid)); object = parse_object_buffer(the_repository, oid, type, size, buf, &eaten); @@ -849,39 +842,25 @@ static void handle_tag(const char *name, struct tag *tag) free(buf); return; case REWRITE: - if (tagged->type == OBJ_TAG && !mark_tags) { - die(_("Error: Cannot export nested tags unless --mark-tags is specified.")); - } else if (tagged->type == OBJ_COMMIT) { - p = rewrite_commit((struct commit *)tagged); - if (!p) { - printf("reset %s\nfrom %s\n\n", - name, oid_to_hex(&null_oid)); - free(buf); - return; - } - tagged_mark = get_object_mark(&p->object); - } else { - /* tagged->type is either OBJ_BLOB or OBJ_TAG */ - tagged_mark = get_object_mark(tagged); + if (tagged->type != OBJ_COMMIT) { + die("tag %s tags unexported %s!", + oid_to_hex(&tag->object.oid), + type_name(tagged->type)); + } + p = rewrite_commit((struct commit *)tagged); + if (!p) { + printf("reset %s\nfrom %s\n\n", + name, oid_to_hex(&null_oid)); + free(buf); + return; } + tagged_mark = get_object_mark(&p->object); } } - if (tagged->type == OBJ_TAG) { - printf("reset %s\nfrom %s\n\n", - name, oid_to_hex(&null_oid)); - } - skip_prefix(name, "refs/tags/", &name); - printf("tag %s\n", name); - if (mark_tags) { - mark_next_object(&tag->object); - printf("mark :%"PRIu32"\n", last_idnum); - } - if (tagged_mark) - printf("from :%d\n", tagged_mark); - else - printf("from %s\n", oid_to_hex(&tagged->oid)); - + if (starts_with(name, "refs/tags/")) + name += 10; + printf("tag %s\nfrom :%d\n", name, tagged_mark); if (show_original_ids) printf("original-oid %s\n", oid_to_hex(&tag->object.oid)); printf("%.*s%sdata %d\n%.*s\n", @@ -1068,16 +1047,11 @@ static void export_marks(char *file) error("Unable to write marks file %s.", file); } -static void import_marks(char *input_file, int check_exists) +static void import_marks(char *input_file) { char line[512]; - FILE *f; - struct stat sb; - - if (check_exists && stat(input_file, &sb)) - return; + FILE *f = xfopen(input_file, "r"); - f = xfopen(input_file, "r"); while (fgets(line, sizeof(line), f)) { uint32_t mark; char *line_end, *mark_end; @@ -1141,9 +1115,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix) struct rev_info revs; struct object_array commits = OBJECT_ARRAY_INIT; struct commit *commit; - char *export_filename = NULL, - *import_filename = NULL, - *import_filename_if_exists = NULL; + char *export_filename = NULL, *import_filename = NULL; uint32_t lastimportid; struct string_list refspecs_list = STRING_LIST_INIT_NODUP; struct string_list paths_of_changed_objects = STRING_LIST_INIT_DUP; @@ -1163,10 +1135,6 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix) N_("Dump marks to this file")), OPT_STRING(0, "import-marks", &import_filename, N_("file"), N_("Import marks from this file")), - OPT_STRING(0, "import-marks-if-exists", - &import_filename_if_exists, - N_("file"), - N_("Import marks from this file if it exists")), OPT_BOOL(0, "fake-missing-tagger", &fake_missing_tagger, N_("Fake a tagger when tags lack one")), OPT_BOOL(0, "full-tree", &full_tree, @@ -1181,8 +1149,6 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix) &reference_excluded_commits, N_("Reference parents which are not in fast-export stream by object id")), OPT_BOOL(0, "show-original-ids", &show_original_ids, N_("Show original object ids of blobs/commits")), - OPT_BOOL(0, "mark-tags", &mark_tags, - N_("Label tags with mark ids")), OPT_END() }; @@ -1216,12 +1182,8 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix) if (use_done_feature) printf("feature done\n"); - if (import_filename && import_filename_if_exists) - die(_("Cannot pass both --import-marks and --import-marks-if-exists")); if (import_filename) - import_marks(import_filename, 0); - else if (import_filename_if_exists) - import_marks(import_filename_if_exists, 1); + import_marks(import_filename); lastimportid = last_idnum; if (import_filename && revs.prune_data.nr) |