Re: [PATCH v4 09/21] range-diff: adjust the output of the commit pairs
- From
Thomas Gummerer <t.gummerer@gmail.com>
- Date
- Jul 29, 2018, 21:28 UTC
- Message-ID
- <20180729212809.GA13316@hank.intra.tgummerer.com>
- In-Reply-To
- <9641ab5c0df984f5e7ea9c49debffffe2a929095.1532210683.git.gitgitgadget@gmail.com>
On 07/21, Johannes Schindelin via GitGitGadget wrote:
Show 49 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> This change brings `git range-diff` yet another step closer to
> feature parity with tbdiff: it now shows the oneline, too, and indicates
> with `=` when the commits have identical diffs.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> range-diff.c | 64 ++++++++++++++++++++++++++++++++++++++++++++--------
> 1 file changed, 55 insertions(+), 9 deletions(-)
>
> diff --git a/range-diff.c b/range-diff.c
> index 1ecee2c09..8329f52e7 100644
> --- a/range-diff.c
> +++ b/range-diff.c
> @@ -7,6 +7,8 @@
> #include "xdiff-interface.h"
> #include "linear-assignment.h"
> #include "diffcore.h"
> +#include "commit.h"
> +#include "pretty.h"
>
> struct patch_util {
> /* For the search for an exact match */
> @@ -255,9 +257,54 @@ static void get_correspondences(struct string_list *a, struct string_list *b,
> free(b2a);
> }
>
> -static const char *short_oid(struct patch_util *util)
> +static void output_pair_header(struct strbuf *buf,
> + struct strbuf *dashes,
> + struct patch_util *a_util,
> + struct patch_util *b_util)
> {
> - return find_unique_abbrev(&util->oid, DEFAULT_ABBREV);
> + struct object_id *oid = a_util ? &a_util->oid : &b_util->oid;
> + struct commit *commit;
> +
> + if (!dashes->len)
> + strbuf_addchars(dashes, '-',
> + strlen(find_unique_abbrev(oid,
> + DEFAULT_ABBREV)));
> +
> + strbuf_reset(buf);
> + if (!a_util)
> + strbuf_addf(buf, "-: %s ", dashes->buf);
> + else
> + strbuf_addf(buf, "%d: %s ", a_util->i + 1,
> + find_unique_abbrev(&a_util->oid, DEFAULT_ABBREV));I failed to notice this earlier, but here we are starting to use util->i, which I was wondering about earlier. Good :)
Show 14 quoted lines
> + if (!a_util) > + strbuf_addch(buf, '>'); > + else if (!b_util) > + strbuf_addch(buf, '<'); > + else if (strcmp(a_util->patch, b_util->patch)) > + strbuf_addch(buf, '!'); > + else > + strbuf_addch(buf, '='); > + > + if (!b_util) > + strbuf_addf(buf, " -: %s", dashes->buf); > + else > + strbuf_addf(buf, " %d: %s", b_util->i + 1, > + find_unique_abbrev(&b_util->oid, DEFAULT_ABBREV));
And here for range b.
> + > [...]