summaryrefslogtreecommitdiff
path: root/xdiff/xdiff.h
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 /xdiff/xdiff.h
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 'xdiff/xdiff.h')
-rw-r--r--xdiff/xdiff.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h
index 4beb10c678..00d36c3ac7 100644
--- a/xdiff/xdiff.h
+++ b/xdiff/xdiff.h
@@ -43,6 +43,7 @@ extern "C" {
#define XDL_EMIT_FUNCNAMES (1 << 0)
#define XDL_EMIT_COMMON (1 << 1)
+#define XDL_EMIT_FUNCCONTEXT (1 << 2)
#define XDL_MMB_READONLY (1 << 0)