Merge branch 'jk/combine-diff-binary-etc' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 16 Aug 2011 18:23:24 +0000 (11:23 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Aug 2011 18:23:24 +0000 (11:23 -0700)
* jk/combine-diff-binary-etc:
combine-diff: respect textconv attributes
refactor get_textconv to not require diff_filespec
combine-diff: handle binary files as binary
combine-diff: calculate mode_differs earlier
combine-diff: split header printing into its own function

1  2 
diff.c
userdiff.c
diff --combined diff.c
index 61bedaed57216cadaf2716ef7aa0d63889571f8a,3f538f5803e414fb313ab60598682b8b8491e204..5dd9049c7d354110534b2770fbf6cbc8e74e359e
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -1117,16 -1117,8 +1117,16 @@@ static void fn_out_consume(void *priv, 
                        emit_line(ecbdata->opt, plain, reset, line, len);
                        fputs("~\n", ecbdata->opt->file);
                } else {
 -                      /* don't print the prefix character */
 -                      emit_line(ecbdata->opt, plain, reset, line+1, len-1);
 +                      /*
 +                       * Skip the prefix character, if any.  With
 +                       * diff_suppress_blank_empty, there may be
 +                       * none.
 +                       */
 +                      if (line[0] != '\n') {
 +                            line++;
 +                            len--;
 +                      }
 +                      emit_line(ecbdata->opt, plain, reset, line, len);
                }
                return;
        }
@@@ -1984,19 -1976,7 +1984,7 @@@ struct userdiff_driver *get_textconv(st
                return NULL;
  
        diff_filespec_load_driver(one);
-       if (!one->driver->textconv)
-               return NULL;
-       if (one->driver->textconv_want_cache && !one->driver->textconv_cache) {
-               struct notes_cache *c = xmalloc(sizeof(*c));
-               struct strbuf name = STRBUF_INIT;
-               strbuf_addf(&name, "textconv/%s", one->driver->name);
-               notes_cache_init(c, name.buf, one->driver->textconv);
-               one->driver->textconv_cache = c;
-       }
-       return one->driver;
+       return userdiff_get_textconv(one->driver);
  }
  
  static void builtin_diff(const char *name_a,
@@@ -4456,13 -4436,6 +4444,13 @@@ int diff_result_code(struct diff_option
        return result;
  }
  
 +int diff_can_quit_early(struct diff_options *opt)
 +{
 +      return (DIFF_OPT_TST(opt, QUICK) &&
 +              !opt->filter &&
 +              DIFF_OPT_TST(opt, HAS_CHANGES));
 +}
 +
  /*
   * Shall changes to this submodule be ignored?
   *
diff --combined userdiff.c
index e55310cd02c8e7d1f0404b2fee9539e7340993d9,5d62e795a2e922ec9cf4d259c5315eeeec176c4c..01d3a8b81e628b0a088e3e9fc0ca59acf7d9c58d
@@@ -60,24 -60,10 +60,24 @@@ PATTERNS("pascal"
         "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"
         "|<>|<=|>=|:=|\\.\\."),
  PATTERNS("perl",
 -       "^[ \t]*package .*;\n"
 -       "^[ \t]*sub .* \\{\n"
 -       "^[A-Z]+ \\{\n"        /* BEGIN, END, ... */
 -       "^=head[0-9] ",        /* POD */
 +       "^package .*\n"
 +       "^sub [[:alnum:]_':]+[ \t]*"
 +              "(\\([^)]*\\)[ \t]*)?" /* prototype */
 +              /*
 +               * Attributes.  A regex can't count nested parentheses,
 +               * so just slurp up whatever we see, taking care not
 +               * to accept lines like "sub foo; # defined elsewhere".
 +               *
 +               * An attribute could contain a semicolon, but at that
 +               * point it seems reasonable enough to give up.
 +               */
 +              "(:[^;#]*)?"
 +              "(\\{[ \t]*)?" /* brace can come here or on the next line */
 +              "(#.*)?$\n" /* comment */
 +       "^(BEGIN|END|INIT|CHECK|UNITCHECK|AUTOLOAD|DESTROY)[ \t]*"
 +              "(\\{[ \t]*)?" /* brace can come here or on the next line */
 +              "(#.*)?$\n"
 +       "^=head[0-9] .*",      /* POD */
         /* -- */
         "[[:alpha:]_'][[:alnum:]_']*"
         "|0[xb]?[0-9a-fA-F_]*"
@@@ -281,3 -267,20 +281,20 @@@ struct userdiff_driver *userdiff_find_b
                return NULL;
        return userdiff_find_by_name(check.value);
  }
+ struct userdiff_driver *userdiff_get_textconv(struct userdiff_driver *driver)
+ {
+       if (!driver->textconv)
+               return NULL;
+       if (driver->textconv_want_cache && !driver->textconv_cache) {
+               struct notes_cache *c = xmalloc(sizeof(*c));
+               struct strbuf name = STRBUF_INIT;
+               strbuf_addf(&name, "textconv/%s", driver->name);
+               notes_cache_init(c, name.buf, driver->textconv);
+               driver->textconv_cache = c;
+       }
+       return driver;
+ }