/* automatically update cleanly resolved paths to the index */
static int rerere_autoupdate;
-static char *merge_rr_path;
-
+ static int rerere_dir_nr;
+ static int rerere_dir_alloc;
+
+ #define RR_HAS_POSTIMAGE 1
+ #define RR_HAS_PREIMAGE 2
+ static struct rerere_dir {
+ unsigned char sha1[20];
+ int status_alloc, status_nr;
+ unsigned char *status;
+ } **rerere_dir;
+
+ static void free_rerere_dirs(void)
+ {
+ int i;
+ for (i = 0; i < rerere_dir_nr; i++) {
+ free(rerere_dir[i]->status);
+ free(rerere_dir[i]);
+ }
+ free(rerere_dir);
+ rerere_dir_nr = rerere_dir_alloc = 0;
+ rerere_dir = NULL;
+ }
+
static void free_rerere_id(struct string_list_item *item)
{
free(item->util);
string_list_append(&to_remove, e->d_name);
}
closedir(dir);
- /* ... and then remove them one-by-one */
+
+ /* ... and then remove the empty directories */
for (i = 0; i < to_remove.nr; i++)
- unlink_rr_item(dirname_to_id(to_remove.items[i].string));
+ rmdir(git_path("rr-cache/%s", to_remove.items[i].string));
string_list_clear(&to_remove, 0);
+ rollback_lock_file(&write_lock);
}
/*
{
int i;
+ if (setup_rerere(merge_rr, 0) < 0)
+ return;
+
for (i = 0; i < merge_rr->nr; i++) {
struct rerere_id *id = merge_rr->items[i].util;
- if (!has_rerere_resolution(id))
+ if (!has_rerere_resolution(id)) {
unlink_rr_item(id);
+ rmdir(rerere_path(id, NULL));
+ }
}
- unlink_or_warn(git_path("MERGE_RR"));
+ unlink_or_warn(git_path_merge_rr());
+ rollback_lock_file(&write_lock);
}