summaryrefslogtreecommitdiff
path: root/rerere.c
diff options
context:
space:
mode:
authorLibravatar Elijah Newren <newren@gmail.com>2021-05-27 04:53:56 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-05-27 14:02:37 +0900
commit906fc557b70b2b2995785c9b37e212d2f86b469e (patch)
treeaae98ad6bb236082101b55fa3617b94da11204a1 /rerere.c
parentdir: update stale description of treat_directory() (diff)
downloadtgif-906fc557b70b2b2995785c9b37e212d2f86b469e.tar.xz
dir: introduce readdir_skip_dot_and_dotdot() helper
Many places in the code were doing while ((d = readdir(dir)) != NULL) { if (is_dot_or_dotdot(d->d_name)) continue; ...process d... } Introduce a readdir_skip_dot_and_dotdot() helper to make that a one-liner: while ((d = readdir_skip_dot_and_dotdot(dir)) != NULL) { ...process d... } This helper particularly simplifies checks for empty directories. Also use this helper in read_cached_dir() so that our statistics are consistent across platforms. (In other words, read_cached_dir() should have been using is_dot_or_dotdot() and skipping such entries, but did not and left it to treat_path() to detect and mark such entries as path_none.) Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'rerere.c')
-rw-r--r--rerere.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/rerere.c b/rerere.c
index dee60dc6df..d83d58df4f 100644
--- a/rerere.c
+++ b/rerere.c
@@ -1190,13 +1190,11 @@ void rerere_gc(struct repository *r, struct string_list *rr)
if (!dir)
die_errno(_("unable to open rr-cache directory"));
/* Collect stale conflict IDs ... */
- while ((e = readdir(dir))) {
+ while ((e = readdir_skip_dot_and_dotdot(dir))) {
struct rerere_dir *rr_dir;
struct rerere_id id;
int now_empty;
- if (is_dot_or_dotdot(e->d_name))
- continue;
if (!is_rr_cache_dirname(e->d_name))
continue; /* or should we remove e->d_name? */