git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 0/1] Show an error if too-long paths are seen by git clean -dfx

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Jul 18, 2019, 09:30 UTC
Message-ID
<pull.219.v2.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.219.git.gitgitgadget@gmail.com>

This is particularly important on Windows, where PATH_MAX is very small compared to Unix/Linux.

Changes since v1:
 * Matched the warning message style to existing ones,
 * Fixed test in multiple ways: * Avoiding touch in favor of : >.
    * Using test_config.
    * Using test_i18ngrep instead of grep to avoid localization problems.
    * Add helpful comments.
   
   
 * The commit message now talks about lstat() instead of stat().
 * The commit message also explains where that core.longpaths comes from.
Johannes Schindelin (1):
  clean: show an error message when the path is too long
 builtin/clean.c  |  3 ++-
 t/t7300-clean.sh | 12 ++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
base-commit: aa25c82427ae70aebf3b8f970f2afd54e9a2a8c6
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-219%2Fdscho%2Fclean-long-paths-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-219/dscho/clean-long-paths-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/219
Range-diff vs v1:
 1:  36677556a2 ! 1:  c7b11fe410 clean: show an error message when the path is too long
     @@ -2,7 +2,7 @@
      
          clean: show an error message when the path is too long
      
     -    Without an error message when stat() failed, e.g. `git clean` would
     +    Without an error message when `lstat()` failed, `git clean` would
          abort without an error message, leaving the user quite puzzled.
      
          In particular on Windows, where the default maximum path length is quite
     @@ -15,18 +15,32 @@
      
                  https://github.com/git-for-windows/git/issues/521
      
     +    Note that we temporarily set `core.longpaths = false` in the regression
     +    test; This ensures forward-compatibility with the `core.longpaths`
     +    feature that has not yet been upstreamed from Git for Windows.
     +
     +    Helped-by: René Scharfe <l.s.r@web.de>
     +    Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
     +    Helped-by: Junio C Hamano <gitster@pobox.com>
          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
      
       diff --git a/builtin/clean.c b/builtin/clean.c
       --- a/builtin/clean.c
       +++ b/builtin/clean.c
     +@@
     + static const char *msg_skip_git_dir = N_("Skipping repository %s\n");
     + static const char *msg_would_skip_git_dir = N_("Would skip repository %s\n");
     + static const char *msg_warn_remove_failed = N_("failed to remove %s");
     ++static const char *msg_warn_lstat_failed = N_("could not lstat %s\n");
     + 
     + enum color_clean {
     + 	CLEAN_COLOR_RESET = 0,
      @@
       		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));
     ++			warning_errno(_(msg_warn_lstat_failed), path->buf);
       		else if (S_ISDIR(st.st_mode)) {
       			if (remove_dirs(path, prefix, force_flag, dry_run, quiet, &gone))
       				ret = 1;
     @@ -39,14 +53,15 @@
       '
       
      +test_expect_success MINGW 'handle clean & core.longpaths = false nicely' '
     -+	git config core.longpaths false &&
     -+	test_when_finished git config --unset core.longpaths &&
     ++	test_config core.longpaths false &&
      +	a50=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
      +	mkdir -p $a50$a50/$a50$a50/$a50$a50 &&
     -+	touch $a50$a50/test.txt &&
     -+	touch $a50$a50/$a50$a50/$a50$a50/test.txt &&
     ++	: >"$a50$a50/test.txt" 2>"$a50$a50/$a50$a50/$a50$a50/test.txt" &&
     ++	# create a temporary outside the working tree to hide from "git clean"
      +	test_must_fail git clean -xdf 2>.git/err &&
     -+	grep "too long" .git/err
     ++	# grepping for a strerror string is unportable but it is OK here with
     ++	# MINGW prereq
     ++	test_i18ngrep "too long" .git/err
      +'
      +
       test_done
-- 
gitgitgadget
Previous: SZEDER GáborNext: Johannes Schindelin via GitGitGadget
Message 8 of 12 in “Show an error if too-long paths are seen by git clean -dfx”
  1. 0/1 Show an error if too-long paths are seen by git clean -dfxJohannes Schindelin via GitGitGadget, Jul 16, 2019
  2. 1/1 clean: show an error message when the path is too longJohannes Schindelin via GitGitGadget, Jul 16, 2019
  3. René ScharfeJul 16, 2019
  4. Junio C HamanoJul 16, 2019
  5. Junio C HamanoJul 17, 2019
  6. Johannes SchindelinJul 18, 2019
  7. SZEDER GáborJul 16, 2019
  8. 0/1 Show an error if too-long paths are seen by git clean -dfxJohannes Schindelin via GitGitGadget, Jul 18, 2019
  9. 1/1 clean: show an error message when the path is too longJohannes Schindelin via GitGitGadget, Jul 18, 2019
  10. Junio C HamanoJul 18, 2019
  11. Johannes SchindelinJul 19, 2019
  12. Junio C HamanoJul 19, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.