Skip to content

Commit 24f3237

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 fa75cb1 + caae38a commit 24f3237

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
@@ -59,6 +59,7 @@ static struct {
5959
[ADVICE_IGNORED_HOOK] = { "ignoredHook" },
6060
[ADVICE_IMPLICIT_IDENTITY] = { "implicitIdentity" },
6161
[ADVICE_MERGE_CONFLICT] = { "mergeConflict" },
62+
[ADVICE_NAME_TOO_LONG] = { "nameTooLong" },
6263
[ADVICE_NESTED_TAG] = { "nestedTag" },
6364
[ADVICE_OBJECT_NAME_WARNING] = { "objectNameWarning" },
6465
[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
@@ -23,6 +23,7 @@
2323
#include "pathspec.h"
2424
#include "help.h"
2525
#include "prompt.h"
26+
#include "advice.h"
2627

2728
static int require_force = -1; /* unset */
2829
static int interactive;
@@ -218,6 +219,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
218219
quote_path(path->buf, prefix, &quoted, 0);
219220
errno = saved_errno;
220221
warning_errno(_(msg_warn_remove_failed), quoted.buf);
222+
if (saved_errno == ENAMETOOLONG) {
223+
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
224+
}
221225
*dir_gone = 0;
222226
}
223227
ret = res;
@@ -253,6 +257,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
253257
quote_path(path->buf, prefix, &quoted, 0);
254258
errno = saved_errno;
255259
warning_errno(_(msg_warn_remove_failed), quoted.buf);
260+
if (saved_errno == ENAMETOOLONG) {
261+
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
262+
}
256263
*dir_gone = 0;
257264
ret = 1;
258265
}
@@ -296,6 +303,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
296303
quote_path(path->buf, prefix, &quoted, 0);
297304
errno = saved_errno;
298305
warning_errno(_(msg_warn_remove_failed), quoted.buf);
306+
if (saved_errno == ENAMETOOLONG) {
307+
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
308+
}
299309
*dir_gone = 0;
300310
ret = 1;
301311
}
@@ -1105,6 +1115,9 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
11051115
qname = quote_path(item->string, NULL, &buf, 0);
11061116
errno = saved_errno;
11071117
warning_errno(_(msg_warn_remove_failed), qname);
1118+
if (saved_errno == ENAMETOOLONG) {
1119+
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
1120+
}
11081121
errors++;
11091122
} else if (!quiet) {
11101123
qname = quote_path(item->string, NULL, &buf, 0);

0 commit comments

Comments
 (0)