Skip to content

Commit 08d4169

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 516305d + ba0f161 commit 08d4169

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
@@ -64,6 +64,9 @@ all advice messages.
6464
set their identity configuration.
6565
mergeConflict::
6666
Shown when various commands stop because of conflicts.
67+
nameTooLong::
68+
Advice shown if a filepath operation is attempted where the
69+
path was too long.
6770
nestedTag::
6871
Shown when a user attempts to recursively tag a tag object.
6972
pushAlreadyExists::

advice.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ static struct {
6060
[ADVICE_IGNORED_HOOK] = { "ignoredHook" },
6161
[ADVICE_IMPLICIT_IDENTITY] = { "implicitIdentity" },
6262
[ADVICE_MERGE_CONFLICT] = { "mergeConflict" },
63+
[ADVICE_NAME_TOO_LONG] = { "nameTooLong" },
6364
[ADVICE_NESTED_TAG] = { "nestedTag" },
6465
[ADVICE_OBJECT_NAME_WARNING] = { "objectNameWarning" },
6566
[ADVICE_PUSH_ALREADY_EXISTS] = { "pushAlreadyExists" },

advice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ enum advice_type {
2727
ADVICE_IGNORED_HOOK,
2828
ADVICE_IMPLICIT_IDENTITY,
2929
ADVICE_MERGE_CONFLICT,
30+
ADVICE_NAME_TOO_LONG,
3031
ADVICE_NESTED_TAG,
3132
ADVICE_OBJECT_NAME_WARNING,
3233
ADVICE_PUSH_ALREADY_EXISTS,

builtin/clean.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "pathspec.h"
2626
#include "help.h"
2727
#include "prompt.h"
28+
#include "advice.h"
2829

2930
static int require_force = -1; /* unset */
3031
static int interactive;
@@ -220,6 +221,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
220221
quote_path(path->buf, prefix, &quoted, 0);
221222
errno = saved_errno;
222223
warning_errno(_(msg_warn_remove_failed), quoted.buf);
224+
if (saved_errno == ENAMETOOLONG) {
225+
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
226+
}
223227
*dir_gone = 0;
224228
}
225229
ret = res;
@@ -255,6 +259,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
255259
quote_path(path->buf, prefix, &quoted, 0);
256260
errno = saved_errno;
257261
warning_errno(_(msg_warn_remove_failed), quoted.buf);
262+
if (saved_errno == ENAMETOOLONG) {
263+
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
264+
}
258265
*dir_gone = 0;
259266
ret = 1;
260267
}
@@ -298,6 +305,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
298305
quote_path(path->buf, prefix, &quoted, 0);
299306
errno = saved_errno;
300307
warning_errno(_(msg_warn_remove_failed), quoted.buf);
308+
if (saved_errno == ENAMETOOLONG) {
309+
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
310+
}
301311
*dir_gone = 0;
302312
ret = 1;
303313
}
@@ -1110,6 +1120,9 @@ int cmd_clean(int argc,
11101120
qname = quote_path(item->string, NULL, &buf, 0);
11111121
errno = saved_errno;
11121122
warning_errno(_(msg_warn_remove_failed), qname);
1123+
if (saved_errno == ENAMETOOLONG) {
1124+
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
1125+
}
11131126
errors++;
11141127
} else if (!quiet) {
11151128
qname = quote_path(item->string, NULL, &buf, 0);

0 commit comments

Comments
 (0)