Re: [RFC PATCH v1 2/2] fixup! pathspec: warn: long and short forms are incompatible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 26/03/21 09.40, Σταύρος Ντέντος wrote:
From: Stavros Ntentos <133706+stdedos@xxxxxxxxxxxxxxxxxxxxxxxx>

malloc and stuff
---
  pathspec.c | 21 +++++++++++++--------
  1 file changed, 13 insertions(+), 8 deletions(-)
What does this fixup patch try to accomplish? Give more details.
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,...)`?"));
Message looks ok.
+	FREE_AND_NULL(flags);
+	FREE_AND_NULL(path);
  }


--
An old man doll... just what I always wanted! - Clara



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux