remerge-diff: lazily prepare temporary objdir on demand
It is error prone for each caller that sets revs.remerge_diff bit to be responsible for preparing a temporary object directory and rotate it into the list of alternate object stores, making it the primary object store. Instead, remove the code to set up and arrange the temporary object directory from the current callers and implement it in the code that runs remerge-diff logic. The code to undo the futzing of the list of alternate object store is still spread across the callers, but we will deal with it in future steps. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
16
log-tree.c
16
log-tree.c
@ -1019,6 +1019,17 @@ static int do_remerge_diff(struct rev_info *opt,
|
||||
struct strbuf parent1_desc = STRBUF_INIT;
|
||||
struct strbuf parent2_desc = STRBUF_INIT;
|
||||
|
||||
/*
|
||||
* Lazily prepare a temporary object directory and rotate it
|
||||
* into the alternative object store list as the primary.
|
||||
*/
|
||||
if (opt->remerge_diff && !opt->remerge_objdir) {
|
||||
opt->remerge_objdir = tmp_objdir_create("remerge-diff");
|
||||
if (!opt->remerge_objdir)
|
||||
return error(_("unable to create temporary object directory"));
|
||||
tmp_objdir_replace_primary_odb(opt->remerge_objdir, 1);
|
||||
}
|
||||
|
||||
/* Setup merge options */
|
||||
init_merge_options(&o, the_repository);
|
||||
o.show_rename_progress = 0;
|
||||
@ -1053,10 +1064,7 @@ static int do_remerge_diff(struct rev_info *opt,
|
||||
merge_finalize(&o, &res);
|
||||
|
||||
/* Clean up the contents of the temporary object directory */
|
||||
if (opt->remerge_objdir)
|
||||
tmp_objdir_discard_objects(opt->remerge_objdir);
|
||||
else
|
||||
BUG("did a remerge diff without remerge_objdir?!?");
|
||||
tmp_objdir_discard_objects(opt->remerge_objdir);
|
||||
|
||||
return !opt->loginfo;
|
||||
}
|
||||
|
Reference in New Issue
Block a user