mookid / diffr

Yet another diff highlighting tool
MIT License
539 stars 22 forks source link

Support for diff3 #39

Open ElieGouzien opened 4 years ago

ElieGouzien commented 4 years ago

It would be nice if diffr could support diff3 as generated by git during merges. Currently it simply ignores changes from on side.

mookid commented 4 years ago

Hi @ElieGouzien,

I see on the --help page of git that it produces something like

diff --combined describe.c
index fabadb8,cc95eb0..4866510
--- a/describe.c
+++ b/describe.c
@@@ -98,20 -98,12 +98,20 @@@
        return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
  }

- static void describe(char *arg)
 -static void describe(struct commit *cmit, int last_one)
++static void describe(char *arg, int last_one)
  {
 +      unsigned char sha1[20];
 +      struct commit *cmit;
        struct commit_list *list;
        static int initialized = 0;
        struct commit_name *n;

 +      if (get_sha1(arg, sha1) < 0)
 +              usage(describe_usage);
 +      cmit = lookup_commit_reference(sha1);
 +      if (!cmit)
 +              usage(describe_usage);
 +
        if (!initialized) {
                initialized = 1;
                for_each_ref(get_name);

which seems different from what is traditionally designated as diff3 format. Which one are you referring to?

ElieGouzien commented 4 years ago

You are right, I was thinking about the one from git. Lines like

 -static void describe(struct commit *cmit, int last_one)

are not considered by diffr as a diff due to the leading space.

Sorry for the confusion.