From: Stefan Beller <sbeller@google.com>
To: sbeller@google.com
Cc: git@vger.kernel.org
Subject: [PATCH 1/2] WIP: range-diff: take extra arguments for different diffs.
Date: Thu, 9 Aug 2018 17:10:09 -0700 [thread overview]
Message-ID: <20180810001010.58870-2-sbeller@google.com> (raw)
In-Reply-To: <20180810001010.58870-1-sbeller@google.com>
We can use the range-diff on the same range to examine differences in the
diff algorithm.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
range-diff.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/range-diff.c b/range-diff.c
index 347b4a79f25..a977289b7dc 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -28,7 +28,8 @@ struct patch_util {
* Reads the patches into a string list, with the `util` field being populated
* as struct object_id (will need to be free()d).
*/
-static int read_patches(const char *range, struct string_list *list)
+static int read_patches(const char *range, struct string_list *list,
+ struct argv_array *extra_log_args)
{
struct child_process cp = CHILD_PROCESS_INIT;
FILE *in;
@@ -36,7 +37,12 @@ static int read_patches(const char *range, struct string_list *list)
struct patch_util *util = NULL;
int in_header = 1;
- argv_array_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
+ argv_array_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges", NULL);
+
+ if (extra_log_args)
+ argv_array_pushv(&cp.args, extra_log_args->argv);
+
+ argv_array_pushl(&cp.args,
"--reverse", "--date-order", "--decorate=no",
"--no-abbrev-commit", range,
NULL);
@@ -419,14 +425,20 @@ int show_range_diff(const char *range1, const char *range2,
{
int res = 0;
+ struct argv_array extra = ARGV_ARRAY_INIT;
+
struct string_list branch1 = STRING_LIST_INIT_DUP;
struct string_list branch2 = STRING_LIST_INIT_DUP;
- if (read_patches(range1, &branch1))
+ argv_array_push(&extra, "--diff-algorithm=patience");
+ argv_array_push(&extra, "--indent-heuristic");
+
+ if (read_patches(range1, &branch1, NULL))
res = error(_("could not parse log for '%s'"), range1);
- if (!res && read_patches(range2, &branch2))
+ if (!res && read_patches(range2, &branch2, &extra))
res = error(_("could not parse log for '%s'"), range2);
+ diffopt->color_moved = COLOR_MOVED_DEFAULT;
if (!res) {
find_exact_matches(&branch1, &branch2);
get_correspondences(&branch1, &branch2, creation_factor);
--
2.18.0.597.ga71716f1ad-goog
next prev parent reply other threads:[~2018-08-10 0:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-24 0:36 [PATCH] Documentation/diff-options: explain different diff algorithms Stefan Beller
2018-07-24 4:40 ` Jonathan Nieder
2018-07-24 17:38 ` Stefan Beller
2018-07-24 20:06 ` Junio C Hamano
2018-08-06 22:25 ` Stefan Beller
2018-08-06 23:18 ` Jonathan Nieder
2018-08-07 15:56 ` Junio C Hamano
2018-08-09 19:26 ` Stefan Beller
2018-08-10 22:18 ` Stefan Beller
2018-08-09 19:51 ` Stefan Beller
2018-08-10 0:10 ` [PATCH 0/2] Getting data on different diff algorithms WAS: " Stefan Beller
2018-08-10 0:10 ` Stefan Beller [this message]
2018-08-10 0:10 ` [PATCH 2/2] WIP range-diff: print some statistics about the range Stefan Beller
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=20180810001010.58870-2-sbeller@google.com \
--to=sbeller@google.com \
--cc=git@vger.kernel.org \
/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).