Skip to content

Commit e5f5917

Browse files
peffgitster
authored andcommitted
rerere: don't segfault on failure to open rr-cache
The rr-cache directory should always exist if we are doing garbage collection (earlier code paths check this explicitly), but we may not necessarily succeed in opening it (for example, due to permissions problems). In that case, we should print an error message rather than simply segfaulting. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent adf9628 commit e5f5917

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

builtin-rerere.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ static void garbage_collect(struct string_list *rr)
4848

4949
git_config(git_rerere_gc_config, NULL);
5050
dir = opendir(git_path("rr-cache"));
51+
if (!dir)
52+
die_errno("unable to open rr-cache directory");
5153
while ((e = readdir(dir))) {
5254
if (is_dot_or_dotdot(e->d_name))
5355
continue;

0 commit comments

Comments
 (0)