diff --git a/builtin/refs.c b/builtin/refs.c index 46dcd150d4e279..33f74375e82ee9 100644 --- a/builtin/refs.c +++ b/builtin/refs.c @@ -28,29 +28,44 @@ static int cmd_refs_migrate(int argc, const char **argv, const char *prefix) struct strbuf errbuf = STRBUF_INIT; int err; + fputs("parse options\n", stderr); + fflush(stderr); + argc = parse_options(argc, argv, prefix, options, migrate_usage, 0); if (argc) usage(_("too many arguments")); if (!format_str) usage(_("missing --ref-format=")); + fputs("ref storage format\n", stderr); + fflush(stderr); + format = ref_storage_format_by_name(format_str); if (format == REF_STORAGE_FORMAT_UNKNOWN) { err = error(_("unknown ref storage format '%s'"), format_str); goto out; } + fputs("double check\n", stderr); + fflush(stderr); + if (the_repository->ref_storage_format == format) { err = error(_("repository already uses '%s' format"), ref_storage_format_to_name(format)); goto out; } + fputs("repo migrate\n", stderr); + fflush(stderr); + if (repo_migrate_ref_storage_format(the_repository, format, flags, &errbuf) < 0) { err = error("%s", errbuf.buf); goto out; } + fputs("repo migrate done\n", stderr); + fflush(stderr); + err = 0; out: diff --git a/refs.c b/refs.c index abe38602c53f65..802ce4a09435c8 100644 --- a/refs.c +++ b/refs.c @@ -2712,6 +2712,9 @@ int repo_migrate_ref_storage_format(struct repository *repo, old_refs = get_main_ref_store(repo); + fputs("reflog checks\n", stderr); + fflush(stderr); + /* * We do not have any interfaces that would allow us to write many * reflog entries. Once we have them we can remove this restriction. @@ -2727,6 +2730,9 @@ int repo_migrate_ref_storage_format(struct repository *repo, goto done; } + fputs("worktree checks\n", stderr); + fflush(stderr); + /* * Worktrees complicate the migration because every worktree has a * separate ref storage. While it should be feasible to implement, this @@ -2742,6 +2748,9 @@ int repo_migrate_ref_storage_format(struct repository *repo, goto done; } + fputs("mkdtemp\n", stderr); + fflush(stderr); + /* * The overall logic looks like this: * @@ -2773,12 +2782,18 @@ int repo_migrate_ref_storage_format(struct repository *repo, goto done; } + fputs("ref store init\n", stderr); + fflush(stderr); + new_refs = ref_store_init(repo, format, new_gitdir, REF_STORE_ALL_CAPS); ret = ref_store_create_on_disk(new_refs, 0, errbuf); if (ret < 0) goto done; + fputs("ref store transaction\n", stderr); + fflush(stderr); + transaction = ref_store_transaction_begin(new_refs, errbuf); if (!transaction) goto done; @@ -2787,6 +2802,9 @@ int repo_migrate_ref_storage_format(struct repository *repo, data.transaction = transaction; data.errbuf = errbuf; + fputs("ref enumeration\n", stderr); + fflush(stderr); + /* * We need to use the internal `do_for_each_ref()` here so that we can * also include broken refs and symrefs. These would otherwise be @@ -2804,6 +2822,9 @@ int repo_migrate_ref_storage_format(struct repository *repo, if (ret < 0) goto done; + fputs("ref transaction commit\n", stderr); + fflush(stderr); + /* * TODO: we might want to migrate to `initial_ref_transaction_commit()` * here, which is more efficient for the files backend because it would @@ -2823,6 +2844,9 @@ int repo_migrate_ref_storage_format(struct repository *repo, goto done; } + fputs("ref db removal\n", stderr); + fflush(stderr); + /* * Until now we were in the non-destructive phase, where we only * populated the new ref store. From hereon though we are about @@ -2839,6 +2863,9 @@ int repo_migrate_ref_storage_format(struct repository *repo, if (ret < 0) goto done; + fputs("move files\n", stderr); + fflush(stderr); + ret = move_files(new_gitdir, old_refs->gitdir, errbuf); if (ret < 0) goto done; @@ -2847,6 +2874,9 @@ int repo_migrate_ref_storage_format(struct repository *repo, warning_errno(_("could not remove temporary migration directory '%s'"), new_gitdir); + fputs("move over\n", stderr); + fflush(stderr); + /* * We have migrated the repository, so we now need to adjust the * repository format so that clients will use the new ref store. diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c index 62992a67ee6cf7..a9c619f52fdccc 100644 --- a/refs/reftable-backend.c +++ b/refs/reftable-backend.c @@ -352,26 +352,53 @@ static int reftable_be_remove_on_disk(struct ref_store *ref_store, struct strbuf sb = STRBUF_INIT; int ret = 0; + fputs("removal: remove old store\n", stderr); + fflush(stderr); + + reftable_be_release(ref_store); + + fputs("removal: remove reftable directory\n", stderr); + fflush(stderr); + strbuf_addf(&sb, "%s/reftable", refs->base.gitdir); if (remove_dir_recursively(&sb, 0) < 0) { - strbuf_addstr(err, "could not delete reftables"); + strbuf_addf(err, "could not delete reftables: %s", + strerror(errno)); ret = -1; + + fputs(sb.buf, stderr); + fflush(stderr); } strbuf_reset(&sb); + fputs("removal: remove HEAD\n", stderr); + fflush(stderr); + strbuf_addf(&sb, "%s/HEAD", refs->base.gitdir); if (remove_path(sb.buf) < 0) { strbuf_addstr(err, "could not delete stub HEAD"); ret = -1; + + fputs(sb.buf, stderr); + fflush(stderr); } strbuf_reset(&sb); + fputs("removal: remove refs/heads\n", stderr); + fflush(stderr); + strbuf_addf(&sb, "%s/refs/heads", refs->base.gitdir); if (remove_path(sb.buf) < 0) { strbuf_addstr(err, "could not delete stub heads"); ret = -1; + + fputs(sb.buf, stderr); + fflush(stderr); } + fputs("removal: done\n", stderr); + fflush(stderr); + strbuf_release(&sb); return ret; }