From: Junio C Hamano Date: Thu, 13 Nov 2008 05:50:41 +0000 (-0800) Subject: Merge branch 'jk/diff-convfilter-test-fix' X-Git-Tag: v1.6.1-rc1~63 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/459d60084fa463203d0adfc99cbf5d6fcd7edd43?ds=inline;hp=-c Merge branch 'jk/diff-convfilter-test-fix' * jk/diff-convfilter-test-fix: Avoid using non-portable `echo -n` in tests. add userdiff textconv tests document the diff driver textconv feature diff: add missing static declaration Conflicts: Documentation/gitattributes.txt --- 459d60084fa463203d0adfc99cbf5d6fcd7edd43 diff --combined Documentation/gitattributes.txt index eb648418ee,314e2d32e5..a172baf993 --- a/Documentation/gitattributes.txt +++ b/Documentation/gitattributes.txt @@@ -163,8 -163,8 +163,8 @@@ few exceptions. Even though.. `ident` ^^^^^^^ -When the attribute `ident` is set to a path, git replaces -`$Id$` in the blob object with `$Id:`, followed by +When the attribute `ident` is set for a path, git replaces +`$Id$` in the blob object with `$Id:`, followed by the 40-character hexadecimal blob object name, followed by a dollar sign `$` upon checkout. Any byte sequence that begins with `$Id:` and ends with `$` in the worktree file is replaced @@@ -213,13 -213,12 +213,15 @@@ with `crlf`, and then `ident` and fed t Generating diff text ~~~~~~~~~~~~~~~~~~~~ +`diff` +^^^^^^ + - The attribute `diff` affects if 'git-diff' generates textual - patch for the path or just says `Binary files differ`. It also - can affect what line is shown on the hunk header `@@ -k,l +n,m @@` - line. + The attribute `diff` affects how 'git' generates diffs for particular + files. It can tell git whether to generate a textual patch for the path + or to treat the path as a binary file. It can also affect what line is + shown on the hunk header `@@ -k,l +n,m @@` line, tell git to use an + external command to generate the diff, or ask git to convert binary + files to a text format before generating the diff. Set:: @@@ -230,7 -229,8 +232,8 @@@ Unset:: A path to which the `diff` attribute is unset will - generate `Binary files differ`. + generate `Binary files differ` (or a binary patch, if + binary patches are enabled). Unspecified:: @@@ -241,21 -241,21 +244,21 @@@ String:: - Diff is shown using the specified custom diff driver. - The driver program is given its input using the same - calling convention as used for GIT_EXTERNAL_DIFF - program. This name is also used for custom hunk header - selection. + Diff is shown using the specified diff driver. Each driver may + specify one or more options, as described in the following + section. The options for the diff driver "foo" are defined + by the configuration variables in the "diff.foo" section of the + git config file. - Defining a custom diff driver - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Defining an external diff driver + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The definition of a diff driver is done in `gitconfig`, not `gitattributes` file, so strictly speaking this manual page is a wrong place to talk about it. However... - To define a custom diff driver `jcdiff`, add a section to your + To define an external diff driver `jcdiff`, add a section to your `$GIT_DIR/config` file (or `$HOME/.gitconfig` file) like this: ---------------------------------------------------------------- @@@ -331,12 -331,46 +334,49 @@@ patterns are available - `tex` suitable for source code for LaTeX documents. + Performing text diffs of binary files + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + Sometimes it is desirable to see the diff of a text-converted + version of some binary files. For example, a word processor + document can be converted to an ASCII text representation, and + the diff of the text shown. Even though this conversion loses + some information, the resulting diff is useful for human + viewing (but cannot be applied directly). + + The `textconv` config option is used to define a program for + performing such a conversion. The program should take a single + argument, the name of a file to convert, and produce the + resulting text on stdout. + + For example, to show the diff of the exif information of a + file instead of the binary information (assuming you have the + exif tool installed): + + ------------------------ + [diff "jpg"] + textconv = exif + ------------------------ + + NOTE: The text conversion is generally a one-way conversion; + in this example, we lose the actual image contents and focus + just on the text data. This means that diffs generated by + textconv are _not_ suitable for applying. For this reason, + only `git diff` and the `git log` family of commands (i.e., + log, whatchanged, show) will perform text conversion. `git + format-patch` will never generate this output. If you want to + send somebody a text-converted diff of a binary file (e.g., + because it quickly conveys the changes you have made), you + should generate it separately and send it as a comment _in + addition to_ the usual binary diff that you might send. + + Performing a three-way merge ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`merge` +^^^^^^^ + The attribute `merge` affects how three versions of a file is merged when a file-level merge is necessary during `git merge`, and other programs such as `git revert` and `git cherry-pick`. diff --combined diff.c index 1918b73d53,d1fd594ba3..3e6c752bb7 --- a/diff.c +++ b/diff.c @@@ -400,7 -400,6 +400,7 @@@ static void diff_words_show(struct diff mmfile_t minus, plus; int i; + memset(&xpp, 0, sizeof(xpp)); memset(&xecfg, 0, sizeof(xecfg)); minus.size = diff_words->minus.text.size; minus.ptr = xmalloc(minus.size); @@@ -1283,7 -1282,7 +1283,7 @@@ static void emit_binary_diff(FILE *file emit_binary_diff_body(file, two, one); } - void diff_filespec_load_driver(struct diff_filespec *one) + static void diff_filespec_load_driver(struct diff_filespec *one) { if (!one->driver) one->driver = userdiff_find_by_path(one->path); @@@ -1417,7 -1416,6 +1417,7 @@@ static void builtin_diff(const char *na if (!pe) pe = diff_funcname_pattern(two); + memset(&xpp, 0, sizeof(xpp)); memset(&xecfg, 0, sizeof(xecfg)); memset(&ecbdata, 0, sizeof(ecbdata)); ecbdata.label_path = lbl; @@@ -1491,7 -1489,6 +1491,7 @@@ static void builtin_diffstat(const cha 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, @@@ -1538,7 -1535,6 +1538,7 @@@ static void builtin_checkdiff(const cha 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; @@@ -2962,7 -2958,6 +2962,7 @@@ static int diff_get_patch_id(struct dif struct diff_filepair *p = q->queue[i]; int len1, len2; + memset(&xpp, 0, sizeof(xpp)); memset(&xecfg, 0, sizeof(xecfg)); if (p->status == 0) return error("internal diff status error");