Thread (27 messages) flat view 27 messages, 4 authors, 2021-04-11

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

From: Bagas Sanjaya <hidden>
Date: 2021-03-26 08:15:35

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

malloc and stuff
---
  pathspec.c | 21 +++++++++++++--------
  1 file changed, 13 insertions(+), 8 deletions(-)
What does this fixup patch try to accomplish? Give more details.
quoted hunk ↗ jump to hunk
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help