Re: [RFC PATCH v1 2/2] fixup! pathspec: warn: long and short forms are incompatible
On 26/03/21 09.40, Σταύρος Ντέντος wrote:
Show 6 quoted lines
> From: Stavros Ntentos <133706+stdedos@users.noreply.github.com>
>
> malloc and stuff
> ---
> pathspec.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
What does this fixup patch try to accomplish? Give more details.
Show 38 quoted lines
> diff --git a/pathspec.c b/pathspec.c
> index 374c529569..4ac8bfdc06 100644
> --- a/pathspec.c
> +++ b/pathspec.c
> @@ -7,6 +7,7 @@
> #include "attr.h"
> #include "strvec.h"
> #include "quote.h"
> +#include "git-compat-util.h"
>
> /*
> * Finds which of the given pathspecs match items in the index.
> @@ -745,16 +746,20 @@ int match_pathspec_attrs(const struct index_state *istate,
> }
>
> void check_mishandled_exclude(const char *entry) {
> + char *flags, *path;
> size_t entry_len = strlen(entry);
> - char flags[entry_len];
> - char path[entry_len];
>
> - if (sscanf(entry, ":!(%4096[^)])%4096s", &flags, &path) != 2) {
> - return;
> - }
> - if (count_slashes(flags) > 0) {
> - return;
> + flags = xstrdup(entry);
> + memset(flags, '\0', entry_len);
> + path = xstrdup(entry);
> + memset(path, '\0', entry_len);
> +
> + if (sscanf(entry, ":!(%4096[^)])%4096s", flags, path) == 2) {
> + if (count_slashes(flags) == 0) {
> + warning(_("Pathspec provided matches `:!(...)`\n\tDid you mean `:(exclude,...)`?"));
> + }
> }
>
> - warning(_("Pathspec provided matches `:!(...)`\n\tDid you mean `:(exclude,...)`?"));> + FREE_AND_NULL(flags);
> + FREE_AND_NULL(path);
> }
>
--
An old man doll... just what I always wanted! - Clara