git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Junio C Hamano <gitster@pobox.com>
Cc: Mark Lodato <lodatom@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH 0/4] grep: add more information to hunk separators
Date: Mon, 26 Mar 2012 23:12:12 +0200	[thread overview]
Message-ID: <4F70DBAC.4010609@lsrfire.ath.cx> (raw)
In-Reply-To: <7vobrjp7gu.fsf@alter.siamese.dyndns.org>

Am 26.03.2012 20:01, schrieb Junio C Hamano:
> René Scharfe<rene.scharfe@lsrfire.ath.cx>  writes:
>
>> Looking at the above, I thought: We have unified diffs between two
>> files, we have combined diffs between more than two, what about
>> showing grep results as one-sided unified diffs?  ("What's the sound
>> of one hand clapping?" :-)
>>
>> 	--- a/git.c
>> 	@ -570,3 @ int main(int argc, const char **argv)
>> 	-		printf("usage: %s\n\n", git_usage_string);
>> 	:		list_common_cmds_help();
>> 	-		printf("\n%s\n", git_more_info_string);
>>
>> Pro: Generalization of an established format for showing interesting
>> parts of a file.  Less duplication of meta-information.  Markers that
>> tell us the kind of the shown lines are kept ("-" for context, ":" for
>> matches).  Machine parsable.
>>
>> Con: Why the "a/" prefix?  One-sided diffs, srsly?
>
> Cute, and I tend to agree that this is probably easier to read if you are
> used to reading unified diffs.
>
> Wouldn't it make more sense to replace your '-/:' with ' /=', so that at
> least ' ' SP retains the meaning of "this is shown merely to give you
> context, it is not a proper part of what you are looking for"?

Ah, good idea, the space makes for a less cluttered output.  For 
completeness sake, I have to mention that the current grep output uses 
'-/:/=', however, for context/match/function line ("especially 
interesting context").  Even function lines that happen to fall within 
the --context are marked with an equal sign.  That's not the case for 
unified diffs; they simply get shown as normal context.

> The reasoning behind '=' is that it is not either -/+ as we are not really
> comparing anything with anything.

Mapping the '-/:/=' of grep to ' /:/=' or ' /:/ ' might be easier to 
understand.  However, seeing a line starting with a colon or an equal 
sign feels both strange, because they are normally used as binary 
operators.  Normal grep output shows a filename or a line number before 
the separator, so it doesn't invoke that strange feeling.

Perhaps mapping to ' /!/ ' is better instead, similar to context diffs?

> It may also make sense to replace the
> per-file header line with "=== git.c" to be consistent.

A context diffs would have '*** git.c', but they are ugly IMHO, overall.

What we also could do: Produce a valid unified diff that would remove 
the matching lines if we were to apply it (or the --reverse, i.e. + 
instead of -).  Then we wouldn't need to invent a special format, but 
the output would be a bit more verbose due to the added +++ lines.

I guess it's time to implement these options in order to try them out 
against real code.  Won't have time to do so before the second half of 
the week, however.

René

  reply	other threads:[~2012-03-26 21:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26  2:41 [PATCH 0/4] grep: add more information to hunk separators Mark Lodato
2012-03-26  2:41 ` [PATCH 1/4] grep doc: add --break / --heading / -W to synopsis Mark Lodato
2012-03-26  2:41 ` [PATCH 2/4] add tests for grep --heading with context Mark Lodato
2012-03-26  2:41 ` [PATCH 3/4] grep: move code to print hunk markers after heading Mark Lodato
2012-03-26  2:41 ` [PATCH 4/4] grep: add --hunk-heading option Mark Lodato
2012-03-26  5:14 ` [PATCH 0/4] grep: add more information to hunk separators Junio C Hamano
2012-03-26 16:16   ` René Scharfe
2012-03-26 18:05     ` Junio C Hamano
2012-03-26 18:48   ` Bert Wesarg
2012-03-26 16:16 ` René Scharfe
2012-03-26 18:01   ` Junio C Hamano
2012-03-26 21:12     ` René Scharfe [this message]
2012-03-26 21:19       ` Junio C Hamano
2012-03-27  5:31 ` [PATCH 5/4] move sane_truncate_line to utf8_truncate_line Mark Lodato
2012-03-27  5:31 ` [PATCH 6/4] add grep.hunkHeadingFunction option Mark Lodato

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F70DBAC.4010609@lsrfire.ath.cx \
    --to=rene.scharfe@lsrfire.ath.cx \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=lodatom@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).