[PATCH 0/6] show non-empty lines before functions with diff/grep -W

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The option -W/--function-context lets git diff and git grep show the
whole surrounding function as context.  For the sake of simplicity and
performance they don't fully parse the files, but as a heuristic show
all lines from the preceding function line to the next one.

This series refines that heuristic and extends the context to include
any non-empty lines before the preceding function line as well.  They
most likely contain comments related to that function and are thus
relevant for reviewing diffs and search results.

Idea and original implementation for git diff by Vegard Nossum:
https://public-inbox.org/git/1484324112-17773-2-git-send-email-vegard.nossum@xxxxxxxxxx/

  t4051: add test for comments preceeding function lines
  xdiff: factor out is_func_rec()
  xdiff: show non-empty lines before functions with -W
  t7810: improve check of -W with user-defined function lines
  grep: update boundary variable for pre-context
  grep: show non-empty lines before functions with -W

 grep.c                           | 35 +++++++++++++++++++++++++++-------
 t/t4051-diff-function-context.sh |  4 ++++
 t/t4051/hello.c                  |  3 +++
 t/t7810-grep.sh                  | 41 ++++++++++++++++++++++++++++++----------
 xdiff/xemit.c                    | 13 ++++++++++---
 5 files changed, 76 insertions(+), 20 deletions(-)

-- 
2.15.0



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux