summaryrefslogtreecommitdiff
path: root/Documentation/diff-options.txt
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2011-10-09 13:36:57 +0200
committerJunio C Hamano <gitster@pobox.com>2011-10-10 12:05:07 -0700
commit14937c2c06e63f93f65e1bc6693b95d4e54053d7 (patch)
tree5258015610490cb82b160974a5d8e864416cbbd6 /Documentation/diff-options.txt
parentf99f4b3667a83f870565bb140711f0e585999108 (diff)
downloadgit-14937c2c06e63f93f65e1bc6693b95d4e54053d7.tar.gz
diff: add option to show whole functions as contextrs/diff-whole-function
Add the option -W/--function-context to git diff. It is similar to the same option of git grep and expands the context of change hunks so that the whole surrounding function is shown. This "natural" context can allow changes to be understood better. Note: GNU patch doesn't like diffs generated with the new option; it seems to expect context lines to be the same before and after changes. git apply doesn't complain. This implementation has the same shortcoming as the one in grep, namely that there is no way to explicitly find the end of a function. That means that a few lines of extra context are shown, right up to the next recognized function begins. It's already useful in its current form, though. The function get_func_line() in xdiff/xemit.c is extended to work forward as well as backward to find post-context as well as pre-context. It returns the position of the first found matching line. The func_line parameter is made optional, as we don't need it for -W. The enhanced function is then used in xdl_emit_diff() to extend the context as needed. If the added context overlaps with the next change, it is merged into the current hunk. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/diff-options.txt')
-rw-r--r--Documentation/diff-options.txt4
1 files changed, 4 insertions, 0 deletions
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index b620b3afec..1ce4ae3b17 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -404,6 +404,10 @@ endif::git-format-patch[]
Show the context between diff hunks, up to the specified number
of lines, thereby fusing hunks that are close to each other.
+-W::
+--function-context::
+ Show whole surrounding functions of changes.
+
ifndef::git-format-patch[]
--exit-code::
Make the program exit with codes similar to diff(1).