Skip to content
Snippets Groups Projects
Commit d34e70d6 authored by Karsten Blees's avatar Karsten Blees Committed by Junio C Hamano
Browse files

fix deletion of .git/objects sub-directories in git-prune/repack


Both git-prune and git-repack (and thus, git-gc) try to rmdir while
holding a DIR* handle on the directory.  This can leave dangling
empty directories in the .git/objects on platforms where directory
cannot be removed while they are open.

First call closedir() and then rmdir(); that is more logical ordering.

Reported-by: default avatarJohn Chen <john0312@gmail.com>
Reported-by: default avatarStefan Naewe <stefan.naewe@gmail.com>
Signed-off-by: default avatarKarsten Blees <blees@dcon.de>
Improved-and-Acked-by: default avatarJohannes Sixt <j6t@kdbg.org>
Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
parent 0dbe6592
No related branches found
No related tags found
No related merge requests found
......@@ -35,8 +35,6 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len, int opts)
unlink_or_warn(pathname);
display_progress(progress, i + 1);
}
pathname[len] = 0;
rmdir(pathname);
}
void prune_packed_objects(int opts)
......@@ -65,6 +63,8 @@ void prune_packed_objects(int opts)
continue;
prune_dir(i, d, pathname, len + 3, opts);
closedir(d);
pathname[len + 2] = '\0';
rmdir(pathname);
}
stop_progress(&progress);
}
......
......@@ -85,9 +85,9 @@ static int prune_dir(int i, char *path)
}
fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);
}
closedir(dir);
if (!show_only)
rmdir(path);
closedir(dir);
return 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment