git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Add format-patch option --no-name-prefix.

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 18, 2007, 17:06 UTC
Message-ID
<Pine.LNX.4.64.0712181703560.23902@racer.site>
In-Reply-To
<alpine.LFD.0.9999.0712180840060.21557@woody.linux-foundation.org>
Hi,
On Tue, 18 Dec 2007, Linus Torvalds wrote:
Show 14 quoted lines
> But I obviously think the version by Dscho is better (exactly because it's 
> *not* enough to just clear the name prefix entirely), although I think 
> that one is broken too - using ':' to separate the prefixes is *not* 
> acceptable, since ':' is very possibly part of the prefix.
> 
> So I think you'd need separate arguments for the from/to prefixes, and not 
> try to shoehorn it into one argument. With possibly some simple form to 
> say "no prefix". So maybe something like
> 
>   --src-prefix=<string>		// default "a/"
>   --dst-prefix=<string>		// default "b/"
>   --no-prefix			// shorthand for --src-prefix="" --dst-prefix=""
> 
> would work for everybody?
If this is preferred, please squash this:
-- snipsnap --
 Documentation/diff-options.txt |   11 ++++++++---
 diff.c                         |   24 ++++++++++++++----------
 2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 672a2d0..0d3dccc 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -211,9 +211,14 @@ endif::git-format-patch[]
 --no-ext-diff::
 	Disallow external diff drivers.
 
---prefix=<prefix1>[:<prefix2>]::
-	Show the given path prefixes instead of "a/" and "b/".  Leave
-	it empty to show no prefix at all.
+--src-prefix <prefix>::
+	Show the given source prefix instead of "a/".
+
+--dst-prefix <prefix>::
+	Show the given destination prefix instead of "b/".
+
+--no-prefix::
+	Do not show any source or destination prefix.
 
 For more detailed explanation on these common options, see also
 link:diffcore.html[diffcore documentation].
diff --git a/diff.c b/diff.c
index 095bbb5..9bc5fea 100644
--- a/diff.c
+++ b/diff.c
@@ -2317,16 +2317,20 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
 		else if (40 < options->abbrev)
 			options->abbrev = 40;
 	}
-	else if (!strcmp(arg, "--prefix=")) {
-		char *colon = strchr(arg + 9, ':');
-		options->a_prefix = arg + 9;
-		if (colon) {
-			*colon = '\0';
-			options->b_prefix = colon + 1;
-		}
-		else
-			options->b_prefix = options->a_prefix;
-	}
+	else if (!strcmp(arg, "--src-prefix")) {
+		if (ac < 2)
+			return error("--src-prefix needs a parameter");
+		options->a_prefix = arg + 1;
+		return 2;
+	}
+	else if (!strcmp(arg, "--dst-prefix")) {
+		if (ac < 2)
+			return error("--dst-prefix needs a parameter");
+		options->b_prefix = arg + 1;
+		return 2;
+	}
+	else if (!strcmp(arg, "--no-prefix"))
+		options->a_prefix = options->b_prefix = "";
 	else
 		return 0;
 	return 1;
Previous: Pascal ObryNext: Pascal Obry
Message 7 of 22 in “Add format-patch option --no-name-prefix.”
  1. Add format-patch option --no-name-prefix.Pascal Obry, Dec 18, 2007
  2. Pascal ObryDec 18, 2007
  3. Johannes SixtDec 18, 2007
  4. Pascal ObryDec 18, 2007
  5. Linus TorvaldsDec 18, 2007
  6. Pascal ObryDec 18, 2007
  7. Johannes SchindelinDec 18, 2007
  8. Pascal ObryDec 18, 2007
  9. Teach diff machinery to display other prefixes than "a/" and "b/"Johannes Schindelin, Dec 18, 2007
  10. Pascal ObryDec 18, 2007
  11. Linus TorvaldsDec 18, 2007
  12. Teach diff machinery to display other prefixes than "a/" and "b/"Johannes Schindelin, Dec 18, 2007
  13. Linus TorvaldsDec 18, 2007
  14. Junio C HamanoDec 18, 2007
  15. Andreas EricssonDec 18, 2007
  16. Pascal ObryDec 18, 2007
  17. Andreas EricssonDec 19, 2007
  18. Johannes SixtDec 19, 2007
  19. Teach diff machinery to display other prefixes than "a/" and "b/"Johannes Schindelin, Dec 18, 2007
  20. Pascal ObryDec 18, 2007
  21. Johannes SchindelinDec 18, 2007
  22. Matthieu MoyDec 18, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.