git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] WIP: range-diff: take extra arguments for different diffs.

From
Stefan Beller <sbeller@google.com>
Date
Aug 10, 2018, 00:10 UTC
Message-ID
<20180810001010.58870-2-sbeller@google.com>
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
Previous: Stefan BellerNext: Stefan Beller
Message 12 of 13 in “Documentation/diff-options: explain different diff algorithms”
  1. Documentation/diff-options: explain different diff algorithmsStefan Beller, Jul 24, 2018
  2. Jonathan NiederJul 24, 2018
  3. Stefan BellerJul 24, 2018
  4. Junio C HamanoJul 24, 2018
  5. Documentation/diff-options: explain different diff algorithmsStefan Beller, Aug 6, 2018
  6. Jonathan NiederAug 6, 2018
  7. Junio C HamanoAug 7, 2018
  8. Stefan BellerAug 9, 2018
  9. Documentation/diff-options: explain different diff algorithmsStefan Beller, Aug 10, 2018
  10. Stefan BellerAug 9, 2018
  11. 0/2 Getting data on different diff algorithms WAS: Documentation/diff-options: explain different diff algorithmsStefan Beller, Aug 10, 2018
  12. 1/2 WIP: range-diff: take extra arguments for different diffs.Stefan Beller, Aug 10, 2018
  13. 2/2 WIP range-diff: print some statistics about the rangeStefan Beller, Aug 10, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.