Merge branch 'maint-1.7.0' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 4 May 2010 22:20:47 +0000 (15:20 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 4 May 2010 22:20:47 +0000 (15:20 -0700)
* maint-1.7.0:
remove ecb parameter from xdi_diff_outf()

1  2 
diff.c
xdiff-interface.c
xdiff-interface.h
diff --combined diff.c
index d0ecbc35406c88f89556a34f1514b77024944d09,a2d8c7f9a7a3bbfca889dedfbda8d6f351fbf016..e40c1271da3f2ea433b55f770408e8d3a0f8a521
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -551,10 -551,6 +551,10 @@@ static void emit_rewrite_diff(const cha
                emit_rewrite_lines(&ecbdata, '-', data_one, size_one);
        if (lc_b)
                emit_rewrite_lines(&ecbdata, '+', data_two, size_two);
 +      if (textconv_one)
 +              free((char *)data_one);
 +      if (textconv_two)
 +              free((char *)data_two);
  }
  
  struct diff_words_buffer {
@@@ -700,7 -696,6 +700,6 @@@ static void diff_words_show(struct diff
  {
        xpparam_t xpp;
        xdemitconf_t xecfg;
-       xdemitcb_t ecb;
        mmfile_t minus, plus;
  
        /* special case: only removal */
        /* as only the hunk header will be parsed, we need a 0-context */
        xecfg.ctxlen = 0;
        xdi_diff_outf(&minus, &plus, fn_out_diff_words_aux, diff_words,
-                     &xpp, &xecfg, &ecb);
+                     &xpp, &xecfg);
        free(minus.ptr);
        free(plus.ptr);
        if (diff_words->current_plus != diff_words->plus.text.ptr +
@@@ -1708,7 -1703,6 +1707,6 @@@ static void builtin_diff(const char *na
                const char *diffopts = getenv("GIT_DIFF_OPTS");
                xpparam_t xpp;
                xdemitconf_t xecfg;
-               xdemitcb_t ecb;
                struct emit_callback ecbdata;
                const struct userdiff_funcname *pe;
  
                        }
                }
                xdi_diff_outf(&mf1, &mf2, fn_out_consume, &ecbdata,
-                             &xpp, &xecfg, &ecb);
+                             &xpp, &xecfg);
                if (DIFF_OPT_TST(o, COLOR_DIFF_WORDS))
                        free_diff_words_data(&ecbdata);
                if (textconv_one)
@@@ -1833,13 -1827,12 +1831,12 @@@ static void builtin_diffstat(const cha
                /* Crazy xdl interfaces.. */
                xpparam_t xpp;
                xdemitconf_t xecfg;
-               xdemitcb_t ecb;
  
                memset(&xpp, 0, sizeof(xpp));
                memset(&xecfg, 0, sizeof(xecfg));
                xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
                xdi_diff_outf(&mf1, &mf2, diffstat_consume, diffstat,
-                             &xpp, &xecfg, &ecb);
+                             &xpp, &xecfg);
        }
  
   free_and_return:
@@@ -1881,14 -1874,13 +1878,13 @@@ static void builtin_checkdiff(const cha
                /* Crazy xdl interfaces.. */
                xpparam_t xpp;
                xdemitconf_t xecfg;
-               xdemitcb_t ecb;
  
                memset(&xpp, 0, sizeof(xpp));
                memset(&xecfg, 0, sizeof(xecfg));
                xecfg.ctxlen = 1; /* at least one context line */
                xpp.flags = XDF_NEED_MINIMAL;
                xdi_diff_outf(&mf1, &mf2, checkdiff_consume, &data,
-                             &xpp, &xecfg, &ecb);
+                             &xpp, &xecfg);
  
                if (data.ws_rule & WS_BLANK_AT_EOF) {
                        struct emit_callback ecbdata;
@@@ -2037,7 -2029,7 +2033,7 @@@ static int diff_populate_gitlink(struc
        char *data = xmalloc(100), *dirty = "";
  
        /* Are we looking at the work tree? */
 -      if (!s->sha1_valid && s->dirty_submodule)
 +      if (s->dirty_submodule)
                dirty = "-dirty";
  
        len = snprintf(data, 100,
@@@ -2633,12 -2625,6 +2629,12 @@@ int diff_setup_done(struct diff_option
         */
        if (options->pickaxe)
                DIFF_OPT_SET(options, RECURSIVE);
 +      /*
 +       * When patches are generated, submodules diffed against the work tree
 +       * must be checked for dirtiness too so it can be shown in the output
 +       */
 +      if (options->output_format & DIFF_FORMAT_PATCH)
 +              DIFF_OPT_SET(options, DIRTY_SUBMODULES);
  
        if (options->detect_rename && options->rename_limit < 0)
                options->rename_limit = diff_rename_limit_default;
@@@ -2837,15 -2823,6 +2833,15 @@@ int diff_opt_parse(struct diff_options 
                DIFF_OPT_SET(options, FOLLOW_RENAMES);
        else if (!strcmp(arg, "--color"))
                DIFF_OPT_SET(options, COLOR_DIFF);
 +      else if (!prefixcmp(arg, "--color=")) {
 +              int value = git_config_colorbool(NULL, arg+8, -1);
 +              if (value == 0)
 +                      DIFF_OPT_CLR(options, COLOR_DIFF);
 +              else if (value > 0)
 +                      DIFF_OPT_SET(options, COLOR_DIFF);
 +              else
 +                      return error("option `color' expects \"always\", \"auto\", or \"never\"");
 +      }
        else if (!strcmp(arg, "--no-color"))
                DIFF_OPT_CLR(options, COLOR_DIFF);
        else if (!strcmp(arg, "--color-words")) {
@@@ -3097,8 -3074,7 +3093,8 @@@ int diff_unmodified_pair(struct diff_fi
         * dealing with a change.
         */
        if (one->sha1_valid && two->sha1_valid &&
 -          !hashcmp(one->sha1, two->sha1))
 +          !hashcmp(one->sha1, two->sha1) &&
 +          !one->dirty_submodule && !two->dirty_submodule)
                return 1; /* no change */
        if (!one->sha1_valid && !two->sha1_valid)
                return 1; /* both look at the same file on the filesystem. */
@@@ -3233,8 -3209,6 +3229,8 @@@ static void diff_resolve_rename_copy(vo
                }
                else if (hashcmp(p->one->sha1, p->two->sha1) ||
                         p->one->mode != p->two->mode ||
 +                       p->one->dirty_submodule ||
 +                       p->two->dirty_submodule ||
                         is_null_sha1(p->one->sha1))
                        p->status = DIFF_STATUS_MODIFIED;
                else {
@@@ -3383,7 -3357,6 +3379,6 @@@ static int diff_get_patch_id(struct dif
        for (i = 0; i < q->nr; i++) {
                xpparam_t xpp;
                xdemitconf_t xecfg;
-               xdemitcb_t ecb;
                mmfile_t mf1, mf2;
                struct diff_filepair *p = q->queue[i];
                int len1, len2;
                xecfg.ctxlen = 3;
                xecfg.flags = XDL_EMIT_FUNCNAMES;
                xdi_diff_outf(&mf1, &mf2, patch_id_consume, &data,
-                             &xpp, &xecfg, &ecb);
+                             &xpp, &xecfg);
        }
  
        git_SHA1_Final(sha1, &ctx);
diff --combined xdiff-interface.c
index ca5e3fbae8184e7114413ec65fe815e01ad6b2a8,3cf39c39c47301fb39cbe859d5165179c13fe752..cd2285de1cb1faa9f7c6c97dd22210f20bb046a3
@@@ -138,19 -138,20 +138,20 @@@ int xdi_diff(mmfile_t *mf1, mmfile_t *m
  
  int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,
                  xdiff_emit_consume_fn fn, void *consume_callback_data,
-                 xpparam_t const *xpp,
-                 xdemitconf_t const *xecfg, xdemitcb_t *xecb)
+                 xpparam_t const *xpp, xdemitconf_t const *xecfg)
  {
        int ret;
        struct xdiff_emit_state state;
+       xdemitcb_t ecb;
  
        memset(&state, 0, sizeof(state));
        state.consume = fn;
        state.consume_callback_data = consume_callback_data;
-       xecb->outf = xdiff_outf;
-       xecb->priv = &state;
+       memset(&ecb, 0, sizeof(ecb));
+       ecb.outf = xdiff_outf;
+       ecb.priv = &state;
        strbuf_init(&state.remainder, 0);
-       ret = xdi_diff(mf1, mf2, xpp, xecfg, xecb);
+       ret = xdi_diff(mf1, mf2, xpp, xecfg, &ecb);
        strbuf_release(&state.remainder);
        return ret;
  }
@@@ -218,23 -219,6 +219,23 @@@ int read_mmfile(mmfile_t *ptr, const ch
        return 0;
  }
  
 +void read_mmblob(mmfile_t *ptr, const unsigned char *sha1)
 +{
 +      unsigned long size;
 +      enum object_type type;
 +
 +      if (!hashcmp(sha1, null_sha1)) {
 +              ptr->ptr = xstrdup("");
 +              ptr->size = 0;
 +              return;
 +      }
 +
 +      ptr->ptr = read_sha1_file(sha1, &type, &size);
 +      if (!ptr->ptr || type != OBJ_BLOB)
 +              die("unable to read blob object %s", sha1_to_hex(sha1));
 +      ptr->size = size;
 +}
 +
  #define FIRST_FEW_BYTES 8000
  int buffer_is_binary(const char *ptr, unsigned long size)
  {
diff --combined xdiff-interface.h
index abba70c16bb31fae0df999241830d0c8df8bfbb3,0cd4511bf797afb06d2d50024a8834766c12e9e1..49d1116fc34f536ab9358313522a25564dd1f6c3
@@@ -9,8 -9,7 +9,7 @@@ typedef void (*xdiff_emit_hunk_consume_
  int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *ecb);
  int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,
                  xdiff_emit_consume_fn fn, void *consume_callback_data,
-                 xpparam_t const *xpp,
-                 xdemitconf_t const *xecfg, xdemitcb_t *xecb);
+                 xpparam_t const *xpp, xdemitconf_t const *xecfg);
  int xdi_diff_hunks(mmfile_t *mf1, mmfile_t *mf2,
                   xdiff_emit_hunk_consume_fn fn, void *consume_callback_data,
                   xpparam_t const *xpp, xdemitconf_t *xecfg);
@@@ -18,7 -17,6 +17,7 @@@ int parse_hunk_header(char *line, int l
                      int *ob, int *on,
                      int *nb, int *nn);
  int read_mmfile(mmfile_t *ptr, const char *filename);
 +void read_mmblob(mmfile_t *ptr, const unsigned char *sha1);
  int buffer_is_binary(const char *ptr, unsigned long size);
  
  extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags);