pretty_print_commit: add different formats
[git.git] / diff.c
diff --git a/diff.c b/diff.c
index 5513632..315eb5c 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -589,6 +589,57 @@ void diff_setup(int flags)
        
 }
 
+static int parse_num(const char **cp_p)
+{
+       int num, scale, ch, cnt;
+       const char *cp = *cp_p;
+
+       cnt = num = 0;
+       scale = 1;
+       while ('0' <= (ch = *cp) && ch <= '9') {
+               if (cnt++ < 5) {
+                       /* We simply ignore more than 5 digits precision. */
+                       scale *= 10;
+                       num = num * 10 + ch - '0';
+               }
+               *cp++;
+       }
+       *cp_p = cp;
+
+       /* user says num divided by scale and we say internally that
+        * is MAX_SCORE * num / scale.
+        */
+       return (MAX_SCORE * num / scale);
+}
+
+int diff_scoreopt_parse(const char *opt)
+{
+       int opt1, opt2, cmd;
+
+       if (*opt++ != '-')
+               return -1;
+       cmd = *opt++;
+       if (cmd != 'M' && cmd != 'C' && cmd != 'B')
+               return -1; /* that is not a -M, -C nor -B option */
+
+       opt1 = parse_num(&opt);
+       if (cmd != 'B')
+               opt2 = 0;
+       else {
+               if (*opt == 0)
+                       opt2 = 0;
+               else if (*opt != '/')
+                       return -1; /* we expect -B80/99 or -B80 */
+               else {
+                       opt++;
+                       opt2 = parse_num(&opt);
+               }
+       }
+       if (*opt != 0)
+               return -1;
+       return opt1 | (opt2 << 16);
+}
+
 struct diff_queue_struct diff_queued_diff;
 
 void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)
@@ -916,6 +967,8 @@ void diffcore_std(const char **paths,
                diffcore_break(break_opt);
        if (detect_rename)
                diffcore_rename(detect_rename, rename_score);
+       if (0 <= break_opt)
+               diffcore_merge_broken();
        if (pickaxe)
                diffcore_pickaxe(pickaxe, pickaxe_opts);
        if (orderfile)