From: Junio C Hamano Date: Mon, 22 Jul 2013 18:23:27 +0000 (-0700) Subject: Merge branch 'mm/diff-no-patch-synonym-to-s' X-Git-Tag: v1.8.4-rc0~32 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/e2ecd252b5e3c90c211075ba9d1017379782708b?ds=inline;hp=-c Merge branch 'mm/diff-no-patch-synonym-to-s' "git show -s" was less discoverable than it should be. * mm/diff-no-patch-synonym-to-s: Documentation/git-log.txt: capitalize section names Documentation: move description of -s, --no-patch to diff-options.txt Documentation/git-show.txt: include common diff options, like git-log.txt diff: allow --patch & cie to override -s/--no-patch diff: allow --no-patch as synonym for -s t4000-diff-format.sh: modernize style --- e2ecd252b5e3c90c211075ba9d1017379782708b diff --combined Documentation/diff-options.txt index 87e92d6537,fe6a1cb4eb..bbed2cd79c --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@@ -26,6 -26,11 +26,11 @@@ ifndef::git-format-patch[ {git-diff? This is the default.} endif::git-format-patch[] + -s:: + --no-patch:: + Suppress diff output. Useful for commands like `git show` that + show the patch by default, or to cancel the effect of `--patch`. + -U:: --unified=:: Generate diffs with lines of context instead of @@@ -333,7 -338,7 +338,7 @@@ endif::git-log[ a fraction, with a decimal point before it. I.e., `-M5` becomes 0.5, and is thus the same as `-M50%`. Similarly, `-M05` is the same as `-M5%`. To limit detection to exact renames, use - `-M100%`. + `-M100%`. The default similarity index is 50%. -C[]:: --find-copies[=]:: @@@ -383,36 -388,14 +388,36 @@@ ifndef::git-format-patch[ that matches other criteria, nothing is selected. -S:: - Look for differences that introduce or remove an instance of - . Note that this is different than the string simply - appearing in diff output; see the 'pickaxe' entry in - linkgit:gitdiffcore[7] for more details. + Look for differences that change the number of occurrences of + the specified string (i.e. addition/deletion) in a file. + Intended for the scripter's use. ++ +It is useful when you're looking for an exact block of code (like a +struct), and want to know the history of that block since it first +came into being: use the feature iteratively to feed the interesting +block in the preimage back into `-S`, and keep going until you get the +very first version of the block. -G:: - Look for differences whose added or removed line matches - the given . + Look for differences whose patch text contains added/removed + lines that match . ++ +To illustrate the difference between `-S --pickaxe-regex` and +`-G`, consider a commit with the following diff in the same +file: ++ +---- ++ return !regexec(regexp, two->ptr, 1, ®match, 0); +... +- hit = !regexec(regexp, mf2.ptr, 1, ®match, 0); +---- ++ +While `git log -G"regexec\(regexp"` will show this commit, `git log +-S"regexec\(regexp" --pickaxe-regex` will not (because the number of +occurrences of that string did not change). ++ +See the 'pickaxe' entry in linkgit:gitdiffcore[7] for more +information. --pickaxe-all:: When `-S` or `-G` finds a change, show all the changes in that @@@ -420,8 -403,8 +425,8 @@@ in . --pickaxe-regex:: - Make the not a plain string but an extended POSIX - regex to match. + Treat the given to `-S` as an extended POSIX regular + expression to match. endif::git-format-patch[] -O:: @@@ -461,9 -444,6 +466,9 @@@ endif::git-format-patch[ differences even if one line has whitespace where the other line has none. +--ignore-blank-lines:: + Ignore changes whose lines are all blank. + --inter-hunk-context=:: Show the context between diff hunks, up to the specified number of lines, thereby fusing hunks that are close to each other. @@@ -505,7 -485,7 +510,7 @@@ endif::git-format-patch[ --ignore-submodules[=]:: Ignore changes to submodules in the diff generation. can be - either "none", "untracked", "dirty" or "all", which is the default + either "none", "untracked", "dirty" or "all", which is the default. Using "none" will consider the submodule modified when it either contains untracked or modified files or its HEAD differs from the commit recorded in the superproject and can be used to override any settings of the diff --combined Documentation/git-log.txt index 2ee6962a72,88f90ed78e..ac2694d04c --- a/Documentation/git-log.txt +++ b/Documentation/git-log.txt @@@ -62,19 -62,6 +62,19 @@@ produced by --stat etc Note that only message is considered, if also a diff is shown its size is not included. +-L ,:, -L :::: + + Trace the evolution of the line range given by "," + (or the funcname regex ) within the . You may + not give any pathspec limiters. This is currently limited to + a walk starting from a single revision, i.e., you may only + give zero or one positive revision arguments. + You can specify this option more than once. ++ + and can take one of these forms: + +include::line-range-format.txt[] + :: Show only commits in the specified revision range. When no is specified, it defaults to `HEAD` (i.e. the @@@ -97,7 -84,7 +97,7 @@@ include::rev-list-options.txt[ include::pretty-formats.txt[] - Common diff options + COMMON DIFF OPTIONS ------------------- :git-log: 1 @@@ -105,7 -92,7 +105,7 @@@ include::diff-options.txt[ include::diff-generate-patch.txt[] - Examples + EXAMPLES -------- `git log --no-merges`:: @@@ -128,9 -115,9 +128,9 @@@ in the "release" branch, along with the list of paths each commit modifies. -`git log --follow builtin-rev-list.c`:: +`git log --follow builtin/rev-list.c`:: - Shows the commits that changed builtin-rev-list.c, including + Shows the commits that changed builtin/rev-list.c, including those commits that occurred before the file was given its present name. @@@ -153,20 -140,15 +153,20 @@@ This makes sense only when following a strict policy of merging all topic branches when staying on a single integration branch. +`git log -L '/int main/',/^}/:main.c`:: + + Shows how the function `main()` in the file 'main.c' evolved + over time. + `git log -3`:: Limits the number of commits to show to 3. - Discussion + DISCUSSION ---------- include::i18n.txt[] - Configuration + CONFIGURATION ------------- See linkgit:git-config[1] for core variables and linkgit:git-diff[1] diff --combined Documentation/rev-list-options.txt index e157ec3fe7,c23688a4c0..e632e8576e --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@@ -271,8 -271,8 +271,8 @@@ See also linkgit:git-reflog[1] --boundary:: - Output uninteresting commits at the boundary, which are usually - not shown. + Output excluded boundary commits. Boundary commits are + prefixed with `-`. -- @@@ -342,13 -342,13 +342,13 @@@ In the following, we will always refer illustrate the differences between simplification settings. We assume that you are filtering for a file `foo` in this commit graph: ----------------------------------------------------------------------- - .-A---M---N---O---P - / / / / / - I B C D E - \ / / / / - `-------------' + .-A---M---N---O---P---Q + / / / / / / + I B C D E Y + \ / / / / / + `-------------' X ----------------------------------------------------------------------- -The horizontal line of history A---P is taken to be the first parent of +The horizontal line of history A---Q is taken to be the first parent of each merge. The commits are: * `I` is the initial commit, in which `foo` exists with contents @@@ -367,11 -367,8 +367,11 @@@ `N` and `D` to "foobarbaz"; i.e., it is not TREESAME to any parent. * `E` changes `quux` to "xyzzy", and its merge `P` combines the - strings to "quux xyzzy". Despite appearing interesting, `P` is - TREESAME to all parents. + strings to "quux xyzzy". `P` is TREESAME to `O`, but not to `E`. + +* `X` is an indpendent root commit that added a new file `side`, and `Y` + modified it. `Y` is TREESAME to `X`. Its merge `Q` added `side` to `P`, and + `Q` is TREESAME to `P`, but not to `Y`. 'rev-list' walks backwards through history, including or excluding commits based on whether '\--full-history' and/or parent rewriting @@@ -413,10 -410,10 +413,10 @@@ parent lines the example, we get + ----------------------------------------------------------------------- - I A B N D O + I A B N D O P Q ----------------------------------------------------------------------- + -`P` and `M` were excluded because they are TREESAME to a parent. `E`, +`M` was excluded because it is TREESAME to both parents. `E`, `C` and `B` were all walked, but only `B` was !TREESAME, so the others do not appear. + @@@ -434,7 -431,7 +434,7 @@@ Along each parent, prune away commits t themselves. This results in + ----------------------------------------------------------------------- - .-A---M---N---O---P + .-A---M---N---O---P---Q / / / / / I B / D / \ / / / / @@@ -444,7 -441,7 +444,7 @@@ Compare to '\--full-history' without rewriting above. Note that `E` was pruned away because it is TREESAME, but the parent list of P was rewritten to contain `E`'s parent `I`. The same happened for `C` and -`N`. Note also that `P` was included despite being TREESAME. +`N`, and `X`, `Y` and `Q`. In addition to the above settings, you can change whether TREESAME affects inclusion: @@@ -474,9 -471,8 +474,9 @@@ history according to the following rule * Set `C'` to `C`. + * Replace each parent `P` of `C'` with its simplification `P'`. In - the process, drop parents that are ancestors of other parents, and - remove duplicates. + the process, drop parents that are ancestors of other parents or that are + root commits TREESAME to an empty tree, and remove duplicates, but take care + to never drop all parents that we are TREESAME to. + * If after this parent rewriting, `C'` is a root or merge commit (has zero or >1 parents), a boundary commit, or !TREESAME, it remains. @@@ -494,7 -490,7 +494,7 @@@ The effect of this is best shown by wa `---------' ----------------------------------------------------------------------- + -Note the major differences in `N` and `P` over '--full-history': +Note the major differences in `N`, `P` and `Q` over '--full-history': + -- * `N`'s parent list had `I` removed, because it is an ancestor of the @@@ -502,10 -498,6 +502,10 @@@ + * `P`'s parent list similarly had `I` removed. `P` was then removed completely, because it had one parent and is TREESAME. ++ +* `Q`'s parent list had `Y` simplified to `X`. `X` was then removed, because it + was a TREESAME root. `Q` was then removed completely, because it had one + parent and is TREESAME. -- Finally, there is a fifth simplification mode available: @@@ -625,10 -617,6 +625,10 @@@ By default, the commits are shown in re Show no parents before all of its children are shown, but otherwise show commits in the commit timestamp order. +--author-date-order:: + Show no parents before all of its children are shown, but + otherwise show commits in the author timestamp order. + --topo-order:: Show no parents before all of its children are shown, and avoid showing commits on multiple lines of history @@@ -849,7 -837,4 +849,4 @@@ options may be given. See linkgit:git-d -t:: Show the tree objects in the diff output. This implies '-r'. - - -s:: - Suppress diff output. endif::git-rev-list[] diff --combined diff.c index e53ddad7d4,5290306caf..0b1b5e7af8 --- a/diff.c +++ b/diff.c @@@ -2677,14 -2677,6 +2677,14 @@@ static int diff_populate_gitlink(struc int diff_populate_filespec(struct diff_filespec *s, int size_only) { int err = 0; + /* + * demote FAIL to WARN to allow inspecting the situation + * instead of refusing. + */ + enum safe_crlf crlf_warn = (safe_crlf == SAFE_CRLF_FAIL + ? SAFE_CRLF_WARN + : safe_crlf); + if (!DIFF_FILE_VALID(s)) die("internal error: asking to populate invalid file."); if (S_ISDIR(s->mode)) @@@ -2740,7 -2732,7 +2740,7 @@@ /* * Convert from working tree format to canonical git format */ - if (convert_to_git(s->path, s->data, s->size, &buf, safe_crlf)) { + if (convert_to_git(s->path, s->data, s->size, &buf, crlf_warn)) { size_t size = 0; munmap(s->data, s->size); s->should_munmap = 0; @@@ -3505,6 -3497,11 +3505,11 @@@ static int parse_submodule_opt(struct d return 1; } + static void enable_patch_output(int *fmt) { + *fmt &= ~DIFF_FORMAT_NO_OUTPUT; + *fmt |= DIFF_FORMAT_PATCH; + } + int diff_opt_parse(struct diff_options *options, const char **av, int ac) { const char *arg = av[0]; @@@ -3512,15 -3509,15 +3517,15 @@@ int argcount; /* Output format options */ - if (!strcmp(arg, "-p") || !strcmp(arg, "-u") || !strcmp(arg, "--patch")) - options->output_format |= DIFF_FORMAT_PATCH; - else if (opt_arg(arg, 'U', "unified", &options->context)) - options->output_format |= DIFF_FORMAT_PATCH; + if (!strcmp(arg, "-p") || !strcmp(arg, "-u") || !strcmp(arg, "--patch") + || opt_arg(arg, 'U', "unified", &options->context)) + enable_patch_output(&options->output_format); else if (!strcmp(arg, "--raw")) options->output_format |= DIFF_FORMAT_RAW; - else if (!strcmp(arg, "--patch-with-raw")) - options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW; - else if (!strcmp(arg, "--numstat")) + else if (!strcmp(arg, "--patch-with-raw")) { + enable_patch_output(&options->output_format); + options->output_format |= DIFF_FORMAT_RAW; + } else if (!strcmp(arg, "--numstat")) options->output_format |= DIFF_FORMAT_NUMSTAT; else if (!strcmp(arg, "--shortstat")) options->output_format |= DIFF_FORMAT_SHORTSTAT; @@@ -3542,13 -3539,14 +3547,14 @@@ options->output_format |= DIFF_FORMAT_CHECKDIFF; else if (!strcmp(arg, "--summary")) options->output_format |= DIFF_FORMAT_SUMMARY; - else if (!strcmp(arg, "--patch-with-stat")) - options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT; - else if (!strcmp(arg, "--name-only")) + else if (!strcmp(arg, "--patch-with-stat")) { + enable_patch_output(&options->output_format); + options->output_format |= DIFF_FORMAT_DIFFSTAT; + } else if (!strcmp(arg, "--name-only")) options->output_format |= DIFF_FORMAT_NAME; else if (!strcmp(arg, "--name-status")) options->output_format |= DIFF_FORMAT_NAME_STATUS; - else if (!strcmp(arg, "-s")) + else if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch")) options->output_format |= DIFF_FORMAT_NO_OUTPUT; else if (!prefixcmp(arg, "--stat")) /* --stat, --stat-width, --stat-name-width, or --stat-count */ @@@ -3601,8 -3599,6 +3607,8 @@@ DIFF_XDL_SET(options, IGNORE_WHITESPACE_CHANGE); else if (!strcmp(arg, "--ignore-space-at-eol")) DIFF_XDL_SET(options, IGNORE_WHITESPACE_AT_EOL); + else if (!strcmp(arg, "--ignore-blank-lines")) + DIFF_XDL_SET(options, IGNORE_BLANK_LINES); else if (!strcmp(arg, "--patience")) options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF); else if (!strcmp(arg, "--histogram")) @@@ -3621,7 -3617,7 +3627,7 @@@ /* flags options */ else if (!strcmp(arg, "--binary")) { - options->output_format |= DIFF_FORMAT_PATCH; + enable_patch_output(&options->output_format); DIFF_OPT_SET(options, BINARY); } else if (!strcmp(arg, "--full-index"))