gnu-arch-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnu-arch-users] Passing arbitrary options to `diff'


From: Ludovic Courtès
Subject: [Gnu-arch-users] Passing arbitrary options to `diff'
Date: Wed, 21 Dec 2005 11:14:23 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

Hi,

Haakon Riiser <address@hidden> writes:

> Great, but could you also support the -B/--ignore-blank-lines
> option?  (I tend to use -Bb when reviewing diffs, since that
> combination excludes changes that normally are just cosmetics.)
> Here's an untested patch:

I slightly modified this patch in my branch[*] so that one can use both
options at the same time (you need `patch-2' and `patch-3' for this).

However, I thought that a generic option that would allow to pass
arbitrary options to `diff' would be more flexible (`patch-4' implements
this and removes `-b' and `-w').  Basically, this new option, namely
`--diff-options' or `-D', can be used as follows:

  $ tla diff -D -bw  # equivalent to `tla diff -bw' with Haakon's patch
  $ tla diff -D -b -D -w  # likewise
  $ tla diff -D -bw -D --show-c-function
  ...

IOW, all the `-D' parameters are added up.

For reviewing purposes, I attach the patch below.

Thanks,
Ludovic.

[*] Location: http://www.laas.fr/~lcourtes/software/arch-2005/
    Branch: tla--devo--1.3


--- orig/libarch/cmd-diff.c
+++ mod/libarch/cmd-diff.c
@@ -85,16 +85,9 @@ static t_uchar * version_string = (cfg__
       N_("show filenames in unescaped form"))\
   OP (opt_limit, 0, "limit LIMITS", 1, \
       N_("limit the diff to LIMITS")) \
-  OP (opt_ignore_space, "b", "ignore-space-change", 0, \
-      N_("ignore white space-only changes (display only)"))\
-  OP (opt_ignore_all_space, "w", "ignore-all-space", 0, \
-      N_("Ignore all white space (display only)"))
+  OP (opt_diff_opts, "D", "diff-options", 1, \
+      N_("specify options for `diff'"))
 
-/*
-  OP (opt_diffopt, 0, "diff-opts", 0, \
-      N_("specify specific diff options to use.")) \
-
-*/
 
 t_uchar arch_cmd_diff_help[] = N_("report about local changes in a project 
tree\n"
                                    "Generate a patch report describing the 
differences between the\n"
@@ -127,6 +120,7 @@ arch_cmd_diff (t_uchar * program_name, i
   t_uchar * output = 0;
   t_uchar * default_archive = 0;
   t_uchar ** diff_opts = 0;
+  unsigned diff_opt_count = 0;
   t_uchar *limit_string = 0;
   int diffs = 1;
   int keep = 0;
@@ -235,20 +229,12 @@ arch_cmd_diff (t_uchar * program_name, i
             latest = 1;
             break;
           }      
-        case opt_ignore_space:
-          {
-            lim_free(0, diff_opts);
-            diff_opts = lim_malloc(0, 3 * sizeof(diff_opts[0]));
-            diff_opts[0] = "--ignore-space-change";
-            diff_opts[1] = 0;
-            break;
-          }
-        case opt_ignore_all_space:
+       case opt_diff_opts:
           {
-            lim_free(0, diff_opts);
-            diff_opts = lim_malloc(0, 3 * sizeof(diff_opts[0]));
-            diff_opts[0] = "--ignore-all-space";
-            diff_opts[1] = 0;
+           diff_opt_count++;
+            diff_opts = lim_realloc (0, diff_opts, (diff_opt_count + 1) * 
sizeof (diff_opts[0]));
+            diff_opts[diff_opt_count - 1] = str_save (0, option->arg_string);
+            diff_opts[diff_opt_count] = 0;
             break;
           }
         }
@@ -480,12 +466,17 @@ arch_cmd_diff (t_uchar * program_name, i
       free_assoc_table (inode_shortcut);
     }
 
+    {
+      unsigned i;
+      for (i = 0; i < diff_opt_count; i++)
+       lim_free (0, diff_opts[i]);
+    }
+    lim_free (0, diff_opts);
     lim_free (0, rvsnspec);
     lim_free (0, tree_root);
     lim_free (0, archive);
     lim_free (0, revision);
     lim_free (0, log_file);
-    lim_free (0, diff_opts);
     lim_free (0, limit_string);
     lim_free (0, local_spec);
     rel_free_table (limits);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]