Skip to content

Commit

Permalink
Merge pull request #3817 from mathstuf/name-too-long-advice
Browse files Browse the repository at this point in the history
clean: suggest using `core.longPaths` if paths are too long to remove
  • Loading branch information
dscho committed Nov 22, 2024
2 parents 8ea9495 + 90cf5f6 commit b933268
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Documentation/config/advice.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ all advice messages.
set their identity configuration.
mergeConflict::
Shown when various commands stop because of conflicts.
nameTooLong::
Advice shown if a filepath operation is attempted where the
path was too long.
nestedTag::
Shown when a user attempts to recursively tag a tag object.
pushAlreadyExists::
Expand Down
1 change: 1 addition & 0 deletions advice.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ static struct {
[ADVICE_IGNORED_HOOK] = { "ignoredHook" },
[ADVICE_IMPLICIT_IDENTITY] = { "implicitIdentity" },
[ADVICE_MERGE_CONFLICT] = { "mergeConflict" },
[ADVICE_NAME_TOO_LONG] = { "nameTooLong" },
[ADVICE_NESTED_TAG] = { "nestedTag" },
[ADVICE_OBJECT_NAME_WARNING] = { "objectNameWarning" },
[ADVICE_PUSH_ALREADY_EXISTS] = { "pushAlreadyExists" },
Expand Down
1 change: 1 addition & 0 deletions advice.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum advice_type {
ADVICE_IGNORED_HOOK,
ADVICE_IMPLICIT_IDENTITY,
ADVICE_MERGE_CONFLICT,
ADVICE_NAME_TOO_LONG,
ADVICE_NESTED_TAG,
ADVICE_OBJECT_NAME_WARNING,
ADVICE_PUSH_ALREADY_EXISTS,
Expand Down
13 changes: 13 additions & 0 deletions builtin/clean.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "pathspec.h"
#include "help.h"
#include "prompt.h"
#include "advice.h"

static int require_force = -1; /* unset */
static int interactive;
Expand Down Expand Up @@ -217,6 +218,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
quote_path(path->buf, prefix, &quoted, 0);
errno = saved_errno;
warning_errno(_(msg_warn_remove_failed), quoted.buf);
if (saved_errno == ENAMETOOLONG) {
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
}
*dir_gone = 0;
}
ret = res;
Expand Down Expand Up @@ -252,6 +256,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
quote_path(path->buf, prefix, &quoted, 0);
errno = saved_errno;
warning_errno(_(msg_warn_remove_failed), quoted.buf);
if (saved_errno == ENAMETOOLONG) {
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
}
*dir_gone = 0;
ret = 1;
}
Expand Down Expand Up @@ -295,6 +302,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
quote_path(path->buf, prefix, &quoted, 0);
errno = saved_errno;
warning_errno(_(msg_warn_remove_failed), quoted.buf);
if (saved_errno == ENAMETOOLONG) {
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
}
*dir_gone = 0;
ret = 1;
}
Expand Down Expand Up @@ -1107,6 +1117,9 @@ int cmd_clean(int argc,
qname = quote_path(item->string, NULL, &buf, 0);
errno = saved_errno;
warning_errno(_(msg_warn_remove_failed), qname);
if (saved_errno == ENAMETOOLONG) {
advise_if_enabled(ADVICE_NAME_TOO_LONG, _("Setting `core.longPaths` may allow the deletion to succeed."));
}
errors++;
} else if (!quiet) {
qname = quote_path(item->string, NULL, &buf, 0);
Expand Down

0 comments on commit b933268

Please sign in to comment.