@@ -407,13 +407,12 @@ static int cmd_log_walk(struct rev_info *rev)
struct commit *commit;
int saved_nrl = 0;
int saved_dcctc = 0;
- struct tmp_objdir *remerge_objdir = NULL;
if (rev->remerge_diff) {
- remerge_objdir = tmp_objdir_create("remerge-diff");
- if (!remerge_objdir)
+ rev->remerge_objdir = tmp_objdir_create("remerge-diff");
+ if (!rev->remerge_objdir)
die_errno(_("unable to create temporary object directory"));
- tmp_objdir_replace_primary_odb(remerge_objdir, 1);
+ tmp_objdir_replace_primary_odb(rev->remerge_objdir, 1);
}
if (rev->early_output)
@@ -458,8 +457,10 @@ static int cmd_log_walk(struct rev_info *rev)
rev->diffopt.no_free = 0;
diff_free(&rev->diffopt);
- if (rev->remerge_diff)
- tmp_objdir_destroy(remerge_objdir);
+ if (rev->remerge_diff) {
+ tmp_objdir_destroy(rev->remerge_objdir);
+ rev->remerge_objdir = NULL;
+ }
if (rev->diffopt.output_format & DIFF_FORMAT_CHECKDIFF &&
rev->diffopt.flags.check_failed) {
@@ -4,6 +4,7 @@
#include "diff.h"
#include "object-store.h"
#include "repository.h"
+#include "tmp-objdir.h"
#include "commit.h"
#include "tag.h"
#include "graph.h"
@@ -944,7 +945,12 @@ static int do_remerge_diff(struct rev_info *opt,
strbuf_release(&parent1_desc);
strbuf_release(&parent2_desc);
merge_finalize(&o, &res);
- /* TODO: clean up the temporary object directory */
+
+ /* Clean up the contents of the temporary object directory */
+ if (opt->remerge_objdir)
+ tmp_objdir_discard_objects(opt->remerge_objdir);
+ else
+ BUG("unable to remove temporary object directory");
return !opt->loginfo;
}
@@ -318,6 +318,9 @@ struct rev_info {
/* misc. flags related to '--no-kept-objects' */
unsigned keep_pack_cache_flags;
+
+ /* Location where temporary objects for remerge-diff are written. */
+ struct tmp_objdir *remerge_objdir;
};
int ref_excluded(struct string_list *, const char *path);
@@ -79,6 +79,11 @@ static void remove_tmp_objdir_on_signal(int signo)
raise(signo);
}
+void tmp_objdir_discard_objects(struct tmp_objdir *t)
+{
+ remove_dir_recursively(&t->path, REMOVE_DIR_KEEP_TOPLEVEL);
+}
+
/*
* These env_* functions are for setting up the child environment; the
* "replace" variant overrides the value of any existing variable with that
@@ -46,6 +46,12 @@ int tmp_objdir_migrate(struct tmp_objdir *);
*/
int tmp_objdir_destroy(struct tmp_objdir *);
+/*
+ * Remove all objects from the temporary object directory, while leaving it
+ * around so more objects can be added.
+ */
+void tmp_objdir_discard_objects(struct tmp_objdir *);
+
/*
* Add the temporary object directory as an alternate object store in the
* current process.