Skip to content

pathspec cleanup

Brandon Williams git 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest16 patches 3 repliesIn review
  2. v416 patches 3 repliesSuperseded
  3. v316 patches 5 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v216 patches12 repliesSuperseded
v117 patches32 repliesSuperseded

Changes in v5 from the cover letter

* Move GUARD_PATHSPEC to prevent checking if pathspec is null twice.
* Mark a string containing 'mnemonic' for translation.

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16mv: remove use of deprecated 'get_pathspec()'builtin/mv.c+31 -190 replies
2/16dir: remove struct path_simplifydir.c+76 -1030 replies
3/16dir: convert fill_directory to use the pathspec struct interfacedir.c+8 -40 replies
4/16ls-tree: convert show_recursive to use the pathspec struct interfacebuiltin/ls-tree.c+7 -90 replies
5/16pathspec: remove the deprecated get_pathspec functionDocumentation/technical/api-setup.txt cache.h pathspec.c +1 more+3 -430 replies
6/16pathspec: copy and free owned memorypathspec.c pathspec.h+21 -60 replies
7/16pathspec: remove unused variable from unsupported_magicpathspec.c+2 -30 replies
8/16pathspec: always show mnemonic and name in unsupported_magicpathspec.c+9 -150 replies
9/16pathspec: simpler logic to prefix original pathspec elementspathspec.c+13 -200 replies
10/16pathspec: factor global magic into its own functionpathspec.c+78 -490 replies
11/16pathspec: create parse_short_magic functionpathspec.c+36 -180 replies
12/16pathspec: create parse_long_magic functionpathspec.c+57 -350 replies
13/16pathspec: create parse_element_magic helperpathspec.c+20 -170 replies
14/16pathspec: create strip submodule slash helperspathspec.c+42 -260 replies
15/16pathspec: small readability changespathspec.c+15 -100 replies
16/16pathspec: rename prefix_pathspec to init_pathspec_itempathspec.c+7 -170 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH v5 00/16] pathspec cleanup

Changes in v5:
* Move GUARD_PATHSPEC to prevent checking if pathspec is null twice.
* Mark a string containing 'mnemonic' for translation.

Brandon Williams (16):
mv: remove use of deprecated 'get_pathspec()'
dir: remove struct path_simplify
dir: convert fill_directory to use the pathspec struct interface
ls-tree: convert show_recursive to use the pathspec struct interface
pathspec: remove the deprecated get_pathspec function
pathspec: copy and free owned memory
pathspec: remove unused variable from unsupported_magic
pathspec: always show mnemonic and name in unsupported_magic
pathspec: simpler logic to prefix original pathspec elements
pathspec: factor global magic into its own function
pathspec: create parse_short_magic function
pathspec: create parse_long_magic function
pathspec: create parse_element_magic helper
pathspec: create strip submodule slash helpers
pathspec: small readability changes
pathspec: rename prefix_pathspec to init_pathspec_item

 Documentation/technical/api-setup.txt |   2 -
 builtin/ls-tree.c                     |  16 +-
 builtin/mv.c                          |  50 ++--
 cache.h                               |   1 -
 dir.c                                 | 191 ++++++--------
 pathspec.c                            | 480 +++++++++++++++++++---------------
 pathspec.h                            |   5 +-
 7 files changed, 388 insertions(+), 357 deletions(-)

--- interdiff between v4 and v5

dir.c +16 -18
index e8ddd7f8a..bc5ff7216 100644
@@ -1353,18 +1353,17 @@ static int simplify_away(const char *path, int pathlen,
 {
 	int i;
 
-	if (pathspec)
-		GUARD_PATHSPEC(pathspec,
-			       PATHSPEC_FROMTOP |
-			       PATHSPEC_MAXDEPTH |
-			       PATHSPEC_LITERAL |
-			       PATHSPEC_GLOB |
-			       PATHSPEC_ICASE |
-			       PATHSPEC_EXCLUDE);
-
 	if (!pathspec || !pathspec->nr)
 		return 0;
 
+	GUARD_PATHSPEC(pathspec,
+		       PATHSPEC_FROMTOP |
+		       PATHSPEC_MAXDEPTH |
+		       PATHSPEC_LITERAL |
+		       PATHSPEC_GLOB |
+		       PATHSPEC_ICASE |
+		       PATHSPEC_EXCLUDE);
+
 	for (i = 0; i < pathspec->nr; i++) {
 		const struct pathspec_item *item = &pathspec->items[i];
 		int len = item->nowildcard_len;
@@ -1394,18 +1393,17 @@ static int exclude_matches_pathspec(const char *path, int pathlen,
 {
 	int i;
 
-	if (pathspec)
-		GUARD_PATHSPEC(pathspec,
-			       PATHSPEC_FROMTOP |
-			       PATHSPEC_MAXDEPTH |
-			       PATHSPEC_LITERAL |
-			       PATHSPEC_GLOB |
-			       PATHSPEC_ICASE |
-			       PATHSPEC_EXCLUDE);
-
 	if (!pathspec || !pathspec->nr)
 		return 0;
 
+	GUARD_PATHSPEC(pathspec,
+		       PATHSPEC_FROMTOP |
+		       PATHSPEC_MAXDEPTH |
+		       PATHSPEC_LITERAL |
+		       PATHSPEC_GLOB |
+		       PATHSPEC_ICASE |
+		       PATHSPEC_EXCLUDE);
+
 	for (i = 0; i < pathspec->nr; i++) {
 		const struct pathspec_item *item = &pathspec->items[i];
 		int len = item->nowildcard_len;
pathspec.c +1 -1
index bcf3ba039..ff2509ddd 100644
@@ -417,7 +417,7 @@ static void NORETURN unsupported_magic(const char *pattern,
 			strbuf_addstr(&sb, ", ");
 
 		if (m->mnemonic)
-			strbuf_addf(&sb, "'%s' (mnemonic: '%c')",
+			strbuf_addf(&sb, _("'%s' (mnemonic: '%c')"),
 				    m->name, m->mnemonic);
 		else
 			strbuf_addf(&sb, "'%s'", m->name);
Signature · 1 line
2.11.0.390.gc69c2f50cf-goog