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

[PATCH] git-diff-*: Allow "--name-only -z" as alias for "--name-only-z"

From
Matthias Urlichs <smurf@smurf.noris.de>
Date
Jul 14, 2005, 21:51 UTC
Message-ID
<20050714215126.GY9915@kiste.smurf.noris.de>
Junio C Hamano wrote:
> +		else if (!strcmp(arg, "--name-only-z"))
> +			diff_output_format = DIFF_FORMAT_NAME_Z;

Speaking as a user, I would get rather frustrated when I try to do that and it doesn't work... so the attached patch allows that usage. Please apply.

---
diff --git a/diff-cache.c b/diff-cache.c
--- a/diff-cache.c
+++ b/diff-cache.c
@@ -222,11 +222,17 @@ int main(int argc, const char **argv)
 			continue;
 		}
 		if (!strcmp(arg, "-z")) {
-			diff_output_format = DIFF_FORMAT_MACHINE;
+			if (diff_output_format == DIFF_FORMAT_NAME)
+				diff_output_format = DIFF_FORMAT_NAME_Z;
+			else
+				diff_output_format = DIFF_FORMAT_MACHINE;
 			continue;
 		}
 		if (!strcmp(arg, "--name-only")) {
-			diff_output_format = DIFF_FORMAT_NAME;
+			if (diff_output_format == DIFF_FORMAT_MACHINE)
+				diff_output_format = DIFF_FORMAT_NAME_Z;
+			else
+				diff_output_format = DIFF_FORMAT_NAME;
 			continue;
 		}
 		if (!strcmp(arg, "--name-only-z")) {
diff --git a/diff-files.c b/diff-files.c
--- a/diff-files.c
+++ b/diff-files.c
@@ -55,11 +55,17 @@ int main(int argc, const char **argv)
 			; /* no-op */
 		else if (!strcmp(argv[1], "-s"))
 			; /* no-op */
-		else if (!strcmp(argv[1], "-z"))
-			diff_output_format = DIFF_FORMAT_MACHINE;
-		else if (!strcmp(argv[1], "--name-only"))
-			diff_output_format = DIFF_FORMAT_NAME;
-		else if (!strcmp(argv[1], "--name-only-z"))
+		else if (!strcmp(argv[1], "-z")) {
+			if (diff_output_format == DIFF_FORMAT_NAME)
+				diff_output_format = DIFF_FORMAT_NAME_Z;
+			else
+				diff_output_format = DIFF_FORMAT_MACHINE;
+		} else if (!strcmp(argv[1], "--name-only")) {
+			if (diff_output_format == DIFF_FORMAT_MACHINE)
+				diff_output_format = DIFF_FORMAT_NAME_Z;
+			else
+				diff_output_format = DIFF_FORMAT_NAME;
+		} else if (!strcmp(argv[1], "--name-only-z"))
 			diff_output_format = DIFF_FORMAT_NAME_Z;
 		else if (!strcmp(argv[1], "-R"))
 			diff_setup_opt |= DIFF_SETUP_REVERSE;
diff --git a/diff-stages.c b/diff-stages.c
--- a/diff-stages.c
+++ b/diff-stages.c
@@ -86,11 +86,17 @@ int main(int ac, const char **av)
 		}
 		else if (!strcmp(arg, "--find-copies-harder"))
 			find_copies_harder = 1;
-		else if (!strcmp(arg, "-z"))
-			diff_output_format = DIFF_FORMAT_MACHINE;
-		else if (!strcmp(arg, "--name-only"))
-			diff_output_format = DIFF_FORMAT_NAME;
-		else if (!strcmp(arg, "--name-only-z"))
+		else if (!strcmp(arg, "-z")) {
+			if (diff_output_format == DIFF_FORMAT_NAME)
+				diff_output_format = DIFF_FORMAT_NAME_Z;
+			else
+				diff_output_format = DIFF_FORMAT_MACHINE;
+		} else if (!strcmp(arg, "--name-only")) {
+			if (diff_output_format == DIFF_FORMAT_MACHINE)
+				diff_output_format = DIFF_FORMAT_NAME_Z;
+			else
+				diff_output_format = DIFF_FORMAT_NAME;
+		} else if (!strcmp(arg, "--name-only-z"))
 			diff_output_format = DIFF_FORMAT_NAME_Z;
 		else if (!strcmp(arg, "-R"))
 			diff_setup_opt |= DIFF_SETUP_REVERSE;
diff --git a/diff-tree.c b/diff-tree.c
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -483,7 +483,10 @@ int main(int argc, const char **argv)
 			continue;
 		}
 		if (!strcmp(arg, "--name-only")) {
-			diff_output_format = DIFF_FORMAT_NAME;
+			if (diff_output_format == DIFF_FORMAT_MACHINE)
+				diff_output_format = DIFF_FORMAT_NAME_Z;
+			else
+				diff_output_format = DIFF_FORMAT_NAME;
 			continue;
 		}
 		if (!strcmp(arg, "--name-only-z")) {
@@ -491,7 +494,10 @@ int main(int argc, const char **argv)
 			continue;
 		}
 		if (!strcmp(arg, "-z")) {
-			diff_output_format = DIFF_FORMAT_MACHINE;
+			if (diff_output_format == DIFF_FORMAT_NAME)
+				diff_output_format = DIFF_FORMAT_NAME_Z;
+			else
+				diff_output_format = DIFF_FORMAT_MACHINE;
 			continue;
 		}
 		if (!strcmp(arg, "-m")) {
-- 
Matthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de
Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
 - -
When The Religious Right Takes Over, We'll All Live In Iran
Next: Junio C Hamano
Message 1 of 7 in “git-diff-*: Allow "--name-only -z" as alias for "--name-only-z"”
  1. git-diff-*: Allow "--name-only -z" as alias for "--name-only-z"Matthias Urlichs, Jul 14, 2005
  2. Junio C HamanoJul 14, 2005
  3. Matthias UrlichsJul 14, 2005
  4. Junio C HamanoJul 14, 2005
  5. Matthias UrlichsJul 14, 2005
  6. Linus TorvaldsJul 15, 2005
  7. Junio C HamanoJul 15, 2005

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.