From ddc66ddc990ee6f0fe22015b8141c1db142b806b Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 16 Feb 2016 16:31:12 +0100 Subject: [PATCH 1/2] remove_dirs: do not swallow error when stat() failed Without an error message when stat() failed, e.g. `git clean` would abort without an error message, leaving the user quite puzzled. This fixes https://github.com/git-for-windows/git/issues/521 Signed-off-by: Johannes Schindelin --- builtin/clean.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/clean.c b/builtin/clean.c index 919157bc2fa0d7..788c78264e0409 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -192,7 +192,8 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag, strbuf_setlen(path, len); strbuf_addstr(path, e->d_name); if (lstat(path->buf, &st)) - ; /* fall thru */ + warning("Could not stat path '%s': %s", + path->buf, strerror(errno)); else if (S_ISDIR(st.st_mode)) { if (remove_dirs(path, prefix, force_flag, dry_run, quiet, &gone)) ret = 1; From 496059603aba94aa2a32252273ecc7816a22d714 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 16 Feb 2016 16:36:10 +0100 Subject: [PATCH 2/2] t7300: `git clean -dfx` must show an error with long paths In particular on Windows, where the default maximum path length is quite small, but there are ways to circumvent that limit in many cases, it is very important that users be given an indication why their command failed because of too long paths when it did. This test case makes sure that a warning is issued that would have helped the user who reported Git for Windows' issue 521: https://github.com/git-for-windows/git/issues/521 Signed-off-by: Johannes Schindelin --- t/t7300-clean.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index 86ceb38b015807..a663dfa625a93f 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -653,4 +653,15 @@ test_expect_success 'git clean -d respects pathspecs (pathspec is prefix of dir) test_path_is_dir foobar ' +test_expect_success MINGW 'handle clean & core.longpaths = false nicely' ' + git config core.longpaths false && + test_when_finished git config --unset core.longpaths && + a50=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && + mkdir -p $a50$a50/$a50$a50/$a50$a50 && + touch $a50$a50/test.txt && + touch $a50$a50/$a50$a50/$a50$a50/test.txt && + test_must_fail git clean -xdf 2>.git/err && + grep "too long" .git/err +' + test_done