Re: [PATCH 2/3] xdiff: -W: include immediately preceding non-empty lines in context
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 15, 2017, 02:39 UTC
- Message-ID
- <xmqqy3ydcaia.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <48bdfd94-2fd4-bd55-d78b-2877e195fb82@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 15 quoted lines
>> I am also more focused on keeping the codebase maintainable in good >> health by making sure that we made an effort to find a solution that >> is general-enough before solving a single specific problem you have >> today. We may end up deciding that a blank-line heuristics gives us >> good enough tradeoff, but I do not want us to make a decision before >> thinking. > > How about extending the context upward only up to and excluding a line > that is either empty *or* a function line? That would limit the extra > context to a single function in the worst case. > > Reducing context at the bottom with the aim to remove comments for the > next section is more tricky as it could remove part of the function > that we'd like to show if we get the boundary wrong. How bad would it > be to keep the southern border unchanged?
I personally do not think there is any robust heuristic other than Vegard's "a blank line may be a signal enough that lines before that are not part of the beginning of the function", and I think your "hence we look for a blank line but if there is a line that matches the function header, stop there as we know we came too far back" will be a good-enough safety measure.
I also agree with you that we probably do not want to futz with the southern border.
Thanks.