Skip to content

Commit 5370390

Browse files
committed
Merge pull request #3817 from mathstuf/name-too-long-advice
clean: suggest using `core.longPaths` if paths are too long to remove
2 parents 684549b + 6b41d7f commit 5370390

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

Documentation/config/advice.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ advice.*::
118118
waitingForEditor::
119119
Print a message to the terminal whenever Git is waiting for
120120
editor input from the user.
121+
nameTooLong::
122+
Advice shown if a filepath operation is attempted where the
123+
path was too long.
121124
nestedTag::
122125
Advice shown if a user attempts to recursively tag a tag object.
123126
submoduleAlternateErrorStrategyDie::

advice.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ static struct {
5151
[ADVICE_GRAFT_FILE_DEPRECATED] = { "graftFileDeprecated", 1 },
5252
[ADVICE_IGNORED_HOOK] = { "ignoredHook", 1 },
5353
[ADVICE_IMPLICIT_IDENTITY] = { "implicitIdentity", 1 },
54+
[ADVICE_NAME_TOO_LONG] = { "nameTooLong", 1 },
5455
[ADVICE_NESTED_TAG] = { "nestedTag", 1 },
5556
[ADVICE_OBJECT_NAME_WARNING] = { "objectNameWarning", 1 },
5657
[ADVICE_PUSH_ALREADY_EXISTS] = { "pushAlreadyExists", 1 },

advice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct string_list;
2525
ADVICE_GRAFT_FILE_DEPRECATED,
2626
ADVICE_IGNORED_HOOK,
2727
ADVICE_IMPLICIT_IDENTITY,
28+
ADVICE_NAME_TOO_LONG,
2829
ADVICE_NESTED_TAG,
2930
ADVICE_OBJECT_NAME_WARNING,
3031
ADVICE_PUSH_ALREADY_EXISTS,

builtin/clean.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "pathspec.h"
2525
#include "help.h"
2626
#include "prompt.h"
27+
#include "advice.h"
2728

2829
static int force = -1; /* unset */
2930
static int interactive;
@@ -219,6 +220,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
219220
quote_path(path->buf, prefix, &quoted, 0);
220221
errno = saved_errno;
221222
warning_errno(_(msg_warn_remove_failed), quoted.buf);
223+
if (saved_errno == ENAMETOOLONG) {
224+
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
225+
}
222226
*dir_gone = 0;
223227
}
224228
ret = res;
@@ -254,6 +258,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
254258
quote_path(path->buf, prefix, &quoted, 0);
255259
errno = saved_errno;
256260
warning_errno(_(msg_warn_remove_failed), quoted.buf);
261+
if (saved_errno == ENAMETOOLONG) {
262+
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
263+
}
257264
*dir_gone = 0;
258265
ret = 1;
259266
}
@@ -297,6 +304,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
297304
quote_path(path->buf, prefix, &quoted, 0);
298305
errno = saved_errno;
299306
warning_errno(_(msg_warn_remove_failed), quoted.buf);
307+
if (saved_errno == ENAMETOOLONG) {
308+
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
309+
}
300310
*dir_gone = 0;
301311
ret = 1;
302312
}
@@ -1116,6 +1126,9 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
11161126
qname = quote_path(item->string, NULL, &buf, 0);
11171127
errno = saved_errno;
11181128
warning_errno(_(msg_warn_remove_failed), qname);
1129+
if (saved_errno == ENAMETOOLONG) {
1130+
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
1131+
}
11191132
errors++;
11201133
} else if (!quiet) {
11211134
qname = quote_path(item->string, NULL, &buf, 0);

0 commit comments

Comments
 (0)