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   |  [EMAIL PROTECTED]
Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
 - -
When The Religious Right Takes Over, We'll All Live In Iran

Attachment: signature.asc
Description: Digital signature

Reply via email to