Skip to content

Commit 5810981

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 94beeb5 + 2bc30ac commit 5810981

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
@@ -58,6 +58,9 @@ advice.*::
5858
set their identity configuration.
5959
mergeConflict::
6060
Shown when various commands stop because of conflicts.
61+
nameTooLong::
62+
Advice shown if a filepath operation is attempted where the
63+
path was too long.
6164
nestedTag::
6265
Shown when a user attempts to recursively tag a tag object.
6366
pushAlreadyExists::

advice.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ static struct {
5858
[ADVICE_IGNORED_HOOK] = { "ignoredHook" },
5959
[ADVICE_IMPLICIT_IDENTITY] = { "implicitIdentity" },
6060
[ADVICE_MERGE_CONFLICT] = { "mergeConflict" },
61+
[ADVICE_NAME_TOO_LONG] = { "nameTooLong" },
6162
[ADVICE_NESTED_TAG] = { "nestedTag" },
6263
[ADVICE_OBJECT_NAME_WARNING] = { "objectNameWarning" },
6364
[ADVICE_PUSH_ALREADY_EXISTS] = { "pushAlreadyExists" },

advice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ enum advice_type {
2626
ADVICE_IGNORED_HOOK,
2727
ADVICE_IMPLICIT_IDENTITY,
2828
ADVICE_MERGE_CONFLICT,
29+
ADVICE_NAME_TOO_LONG,
2930
ADVICE_NESTED_TAG,
3031
ADVICE_OBJECT_NAME_WARNING,
3132
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 require_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
}
@@ -1106,6 +1116,9 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
11061116
qname = quote_path(item->string, NULL, &buf, 0);
11071117
errno = saved_errno;
11081118
warning_errno(_(msg_warn_remove_failed), qname);
1119+
if (saved_errno == ENAMETOOLONG) {
1120+
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
1121+
}
11091122
errors++;
11101123
} else if (!quiet) {
11111124
qname = quote_path(item->string, NULL, &buf, 0);

0 commit comments

Comments
 (0)