Skip to content

Commit f3d508f

Browse files
committed
Merge branch 'js/clean-report-too-long-a-path'
"git clean" silently skipped a path when it cannot lstat() it; now it gives a warning. * js/clean-report-too-long-a-path: clean: show an error message when the path is too long
2 parents f8aee85 + b09364c commit f3d508f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

builtin/clean.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ static const char *msg_would_remove = N_("Would remove %s\n");
3434
static const char *msg_skip_git_dir = N_("Skipping repository %s\n");
3535
static const char *msg_would_skip_git_dir = N_("Would skip repository %s\n");
3636
static const char *msg_warn_remove_failed = N_("failed to remove %s");
37+
static const char *msg_warn_lstat_failed = N_("could not lstat %s\n");
3738

3839
enum color_clean {
3940
CLEAN_COLOR_RESET = 0,
@@ -194,7 +195,7 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
194195
strbuf_setlen(path, len);
195196
strbuf_addstr(path, e->d_name);
196197
if (lstat(path->buf, &st))
197-
; /* fall thru */
198+
warning_errno(_(msg_warn_lstat_failed), path->buf);
198199
else if (S_ISDIR(st.st_mode)) {
199200
if (remove_dirs(path, prefix, force_flag, dry_run, quiet, &gone))
200201
ret = 1;

t/t7300-clean.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,4 +669,16 @@ test_expect_success 'git clean -d skips untracked dirs containing ignored files'
669669
test_path_is_missing foo/b/bb
670670
'
671671

672+
test_expect_success MINGW 'handle clean & core.longpaths = false nicely' '
673+
test_config core.longpaths false &&
674+
a50=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
675+
mkdir -p $a50$a50/$a50$a50/$a50$a50 &&
676+
: >"$a50$a50/test.txt" 2>"$a50$a50/$a50$a50/$a50$a50/test.txt" &&
677+
# create a temporary outside the working tree to hide from "git clean"
678+
test_must_fail git clean -xdf 2>.git/err &&
679+
# grepping for a strerror string is unportable but it is OK here with
680+
# MINGW prereq
681+
test_i18ngrep "too long" .git/err
682+
'
683+
672684
test_done

0 commit comments

Comments
 (0)