git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Thomas Gummerer <t.gummerer@gmail.com>
Cc: Git List <git@vger.kernel.org>, Duy Nguyen <pclouds@gmail.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [RFC PATCH 3/4] range-diff: add section header instead of diff header
Date: Sun, 14 Apr 2019 19:29:54 -0400	[thread overview]
Message-ID: <CAPig+cTJyYLGAfHM_PrZd9DDaZBcVUetcWFcANGCYPvaMh2qxA@mail.gmail.com> (raw)
In-Reply-To: <20190414210933.20875-4-t.gummerer@gmail.com>

On Sun, Apr 14, 2019 at 5:10 PM Thomas Gummerer <t.gummerer@gmail.com> wrote:
> [...]
> Introduce a new range diff hunk header, that's enclosed by "##",
> similar to how line numbers in diff hunks are enclosed by "@@", and
> give human readable information of what exactly happened to the file,
> including the file name.
> [...]
> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
> ---
> diff --git a/range-diff.c b/range-diff.c
> @@ -90,8 +91,37 @@ static int read_patches(const char *range, struct string_list *list)
> +               } else if (starts_with(line.buf, "--- ")) {
> +                       if (!strcmp(line.buf, "--- /dev/null"))
> +                               strbuf_remove(&line, 0, 4);
> +                       else
> +                               strbuf_remove(&line, 0, 6);
> +                       strbuf_rtrim(&line);
> +                       strbuf_reset(&filename_a);
> +                       strbuf_addbuf(&filename_a, &line);
> +               } else if (starts_with(line.buf, "+++ ")) {

At this point, we know that line.buf starts with "+++"...

> +                       strbuf_addstr(&buf, " ## ");
> +                       if (!strcmp(line.buf, "--- /dev/null"))

so, it seems unlikely that it's ever going to match "--- /dev/null".

> +                               strbuf_remove(&line, 0, 4);
> +                       if (!strcmp(filename_a.buf, "/dev/null")) {
> +                               strbuf_addstr(&buf, "new file ");
> +                               strbuf_addbuf(&buf, &line);
> +                       } else if (!strcmp(line.buf, "/dev/null")) {
> +                               strbuf_addstr(&buf, "removed file ");
> +                               strbuf_addbuf(&buf, &line);
> +                       } else if (strbuf_cmp(&filename_a, &line)) {
> +                               strbuf_addstr(&buf, "renamed file ");
> +                               strbuf_addbuf(&buf, &filename_a);
> +                               strbuf_addstr(&buf, " -> ");
> +                               strbuf_addbuf(&buf, &line);
> +                       } else {
> +                               strbuf_addstr(&buf, "modified file ");
> +                               strbuf_addbuf(&buf, &line);
> +                       }

All of these disposition strings end with "file", which seems
redundant. Short and sweet "new", "removed", "renamed", "modified"
provide just as much useful information.

Also, should these strings be localizable? Alternately, rather than
using prose to describe the disposition, perhaps do so symbolically
(thus universally), say with "+", "-", "->", "*" (or ""),
respectively?

  reply	other threads:[~2019-04-14 23:30 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11 11:17 incorrect range-diff output? Duy Nguyen
2019-04-11 22:05 ` Thomas Gummerer
2019-04-12  8:41   ` Johannes Schindelin
2019-04-14 21:12     ` Thomas Gummerer
2019-04-12  9:21   ` Duy Nguyen
2019-04-12 15:02   ` Junio C Hamano
2019-04-14 21:20     ` Thomas Gummerer
2019-04-15  2:01       ` Junio C Hamano
2019-04-15 12:40     ` Johannes Schindelin
2019-04-14 21:09   ` [RFC PATCH 0/4] output improvements for git range-diff Thomas Gummerer
2019-04-14 21:09     ` [RFC PATCH 1/4] range-diff: fix function parameter indentation Thomas Gummerer
2019-04-14 21:09     ` [RFC PATCH 2/4] range-diff: don't remove funcname from inner diff Thomas Gummerer
2019-04-14 23:21       ` Eric Sunshine
2019-04-15 12:54         ` Johannes Schindelin
2019-04-15 18:56           ` Thomas Gummerer
2019-04-17 11:52             ` Johannes Schindelin
2019-04-24 18:15               ` Thomas Gummerer
2019-04-15 12:53       ` Johannes Schindelin
2019-04-15 18:57         ` Thomas Gummerer
2019-04-14 21:09     ` [RFC PATCH 3/4] range-diff: add section header instead of diff header Thomas Gummerer
2019-04-14 23:29       ` Eric Sunshine [this message]
2019-04-15  6:28         ` Johannes Sixt
2019-04-15 13:01         ` Johannes Schindelin
2019-04-15 19:09           ` Thomas Gummerer
2019-04-14 21:09     ` [RFC PATCH 4/4] range-diff: add section headers to the outer hunk header Thomas Gummerer
2019-04-15 12:44       ` Johannes Schindelin
2019-04-15 18:48         ` Thomas Gummerer
2019-04-15 12:47     ` [RFC PATCH 0/4] output improvements for git range-diff Johannes Schindelin
2019-04-15 19:25       ` Thomas Gummerer

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CAPig+cTJyYLGAfHM_PrZd9DDaZBcVUetcWFcANGCYPvaMh2qxA@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    --cc=t.gummerer@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.
Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).