Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 1 | #include "cache.h" |
| 2 | #include "range-diff.h" |
| 3 | #include "string-list.h" |
| 4 | #include "run-command.h" |
Jeff King | dbbcd44 | 2020-07-28 16:23:39 -0400 | [diff] [blame] | 5 | #include "strvec.h" |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 6 | #include "hashmap.h" |
| 7 | #include "xdiff-interface.h" |
| 8 | #include "linear-assignment.h" |
Johannes Schindelin | c8c5e43 | 2018-08-13 04:33:07 -0700 | [diff] [blame] | 9 | #include "diffcore.h" |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 10 | #include "commit.h" |
| 11 | #include "pretty.h" |
Johannes Schindelin | 4eba1fe | 2018-08-13 04:33:14 -0700 | [diff] [blame] | 12 | #include "userdiff.h" |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 13 | #include "apply.h" |
Johannes Schindelin | 359f0d7 | 2021-02-05 14:44:48 +0000 | [diff] [blame] | 14 | #include "revision.h" |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 15 | |
| 16 | struct patch_util { |
| 17 | /* For the search for an exact match */ |
| 18 | struct hashmap_entry e; |
| 19 | const char *diff, *patch; |
| 20 | |
Johannes Schindelin | 9dc46e0 | 2018-08-13 04:33:05 -0700 | [diff] [blame] | 21 | int i, shown; |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 22 | int diffsize; |
| 23 | size_t diff_offset; |
| 24 | /* the index of the matching item in the other branch, or -1 */ |
| 25 | int matching; |
| 26 | struct object_id oid; |
| 27 | }; |
| 28 | |
| 29 | /* |
| 30 | * Reads the patches into a string list, with the `util` field being populated |
| 31 | * as struct object_id (will need to be free()d). |
| 32 | */ |
Denton Liu | bd36191 | 2019-11-20 13:18:45 -0800 | [diff] [blame] | 33 | static int read_patches(const char *range, struct string_list *list, |
Jeff King | c972bf4 | 2020-07-28 16:25:12 -0400 | [diff] [blame] | 34 | const struct strvec *other_arg) |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 35 | { |
| 36 | struct child_process cp = CHILD_PROCESS_INIT; |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 37 | struct strbuf buf = STRBUF_INIT, contents = STRBUF_INIT; |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 38 | struct patch_util *util = NULL; |
| 39 | int in_header = 1; |
Thomas Gummerer | 444e096 | 2019-07-11 17:08:50 +0100 | [diff] [blame] | 40 | char *line, *current_filename = NULL; |
Jeff King | c4d5907 | 2021-08-09 18:48:48 -0400 | [diff] [blame] | 41 | ssize_t len; |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 42 | size_t size; |
Ævar Arnfjörð Bjarmason | 2d102c2 | 2022-03-04 19:32:16 +0100 | [diff] [blame] | 43 | int ret = -1; |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 44 | |
Jeff King | c972bf4 | 2020-07-28 16:25:12 -0400 | [diff] [blame] | 45 | strvec_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges", |
Jeff King | f6d8942 | 2020-07-28 16:26:31 -0400 | [diff] [blame] | 46 | "--reverse", "--date-order", "--decorate=no", |
Philippe Blain | 04b1f1f | 2022-06-06 20:59:13 +0000 | [diff] [blame] | 47 | "--no-prefix", "--submodule=short", |
Jeff King | f6d8942 | 2020-07-28 16:26:31 -0400 | [diff] [blame] | 48 | /* |
| 49 | * Choose indicators that are not used anywhere |
| 50 | * else in diffs, but still look reasonable |
| 51 | * (e.g. will not be confusing when debugging) |
| 52 | */ |
| 53 | "--output-indicator-new=>", |
| 54 | "--output-indicator-old=<", |
| 55 | "--output-indicator-context=#", |
| 56 | "--no-abbrev-commit", |
| 57 | "--pretty=medium", |
| 58 | "--notes", |
| 59 | NULL); |
Denton Liu | bd36191 | 2019-11-20 13:18:45 -0800 | [diff] [blame] | 60 | if (other_arg) |
Jeff King | d70a9eb | 2020-07-28 20:37:20 -0400 | [diff] [blame] | 61 | strvec_pushv(&cp.args, other_arg->v); |
Jeff King | c972bf4 | 2020-07-28 16:25:12 -0400 | [diff] [blame] | 62 | strvec_push(&cp.args, range); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 63 | cp.out = -1; |
| 64 | cp.no_stdin = 1; |
| 65 | cp.git_cmd = 1; |
| 66 | |
| 67 | if (start_command(&cp)) |
| 68 | return error_errno(_("could not start `log`")); |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 69 | if (strbuf_read(&contents, cp.out, 0) < 0) { |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 70 | error_errno(_("could not read `log` output")); |
| 71 | finish_command(&cp); |
Ævar Arnfjörð Bjarmason | 2d102c2 | 2022-03-04 19:32:16 +0100 | [diff] [blame] | 72 | goto cleanup; |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 73 | } |
Johannes Schindelin | 5189bb8 | 2021-02-04 20:07:51 +0000 | [diff] [blame] | 74 | if (finish_command(&cp)) |
Ævar Arnfjörð Bjarmason | 2d102c2 | 2022-03-04 19:32:16 +0100 | [diff] [blame] | 75 | goto cleanup; |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 76 | |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 77 | line = contents.buf; |
| 78 | size = contents.len; |
Jeff King | 47ac23d | 2021-08-09 18:47:42 -0400 | [diff] [blame] | 79 | for (; size > 0; size -= len, line += len) { |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 80 | const char *p; |
Jeff King | 7c86d36 | 2021-08-09 18:48:39 -0400 | [diff] [blame] | 81 | char *eol; |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 82 | |
Jeff King | 7c86d36 | 2021-08-09 18:48:39 -0400 | [diff] [blame] | 83 | eol = memchr(line, '\n', size); |
| 84 | if (eol) { |
| 85 | *eol = '\0'; |
| 86 | len = eol + 1 - line; |
| 87 | } else { |
| 88 | len = size; |
| 89 | } |
| 90 | |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 91 | if (skip_prefix(line, "commit ", &p)) { |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 92 | if (util) { |
| 93 | string_list_append(list, buf.buf)->util = util; |
| 94 | strbuf_reset(&buf); |
| 95 | } |
René Scharfe | ca56dad | 2021-03-13 17:17:22 +0100 | [diff] [blame] | 96 | CALLOC_ARRAY(util, 1); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 97 | if (get_oid(p, &util->oid)) { |
| 98 | error(_("could not parse commit '%s'"), p); |
Ævar Arnfjörð Bjarmason | 2d102c2 | 2022-03-04 19:32:16 +0100 | [diff] [blame] | 99 | FREE_AND_NULL(util); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 100 | string_list_clear(list, 1); |
Ævar Arnfjörð Bjarmason | 2d102c2 | 2022-03-04 19:32:16 +0100 | [diff] [blame] | 101 | goto cleanup; |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 102 | } |
| 103 | util->matching = -1; |
| 104 | in_header = 1; |
| 105 | continue; |
| 106 | } |
| 107 | |
Vasil Dimov | 8cf5156 | 2020-04-15 20:32:24 +0000 | [diff] [blame] | 108 | if (!util) { |
| 109 | error(_("could not parse first line of `log` output: " |
| 110 | "did not start with 'commit ': '%s'"), |
| 111 | line); |
| 112 | string_list_clear(list, 1); |
Ævar Arnfjörð Bjarmason | 2d102c2 | 2022-03-04 19:32:16 +0100 | [diff] [blame] | 113 | goto cleanup; |
Vasil Dimov | 8cf5156 | 2020-04-15 20:32:24 +0000 | [diff] [blame] | 114 | } |
| 115 | |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 116 | if (starts_with(line, "diff --git")) { |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 117 | struct patch patch = { 0 }; |
| 118 | struct strbuf root = STRBUF_INIT; |
| 119 | int linenr = 0; |
Vasil Dimov | 8d1675e | 2020-04-15 20:32:25 +0000 | [diff] [blame] | 120 | int orig_len; |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 121 | |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 122 | in_header = 0; |
| 123 | strbuf_addch(&buf, '\n'); |
| 124 | if (!util->diff_offset) |
| 125 | util->diff_offset = buf.len; |
Jeff King | 7c86d36 | 2021-08-09 18:48:39 -0400 | [diff] [blame] | 126 | if (eol) |
| 127 | *eol = '\n'; |
Vasil Dimov | 8d1675e | 2020-04-15 20:32:25 +0000 | [diff] [blame] | 128 | orig_len = len; |
Johannes Schindelin | 937b76e | 2019-10-02 14:10:47 -0700 | [diff] [blame] | 129 | len = parse_git_diff_header(&root, &linenr, 0, line, |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 130 | len, size, &patch); |
Johannes Schindelin | a2d474a | 2021-02-04 20:07:50 +0000 | [diff] [blame] | 131 | if (len < 0) { |
| 132 | error(_("could not parse git header '%.*s'"), |
| 133 | orig_len, line); |
Ævar Arnfjörð Bjarmason | 2d102c2 | 2022-03-04 19:32:16 +0100 | [diff] [blame] | 134 | FREE_AND_NULL(util); |
Johannes Schindelin | a2d474a | 2021-02-04 20:07:50 +0000 | [diff] [blame] | 135 | string_list_clear(list, 1); |
Ævar Arnfjörð Bjarmason | 2d102c2 | 2022-03-04 19:32:16 +0100 | [diff] [blame] | 136 | goto cleanup; |
Johannes Schindelin | a2d474a | 2021-02-04 20:07:50 +0000 | [diff] [blame] | 137 | } |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 138 | strbuf_addstr(&buf, " ## "); |
| 139 | if (patch.is_new > 0) |
| 140 | strbuf_addf(&buf, "%s (new)", patch.new_name); |
| 141 | else if (patch.is_delete > 0) |
| 142 | strbuf_addf(&buf, "%s (deleted)", patch.old_name); |
| 143 | else if (patch.is_rename) |
| 144 | strbuf_addf(&buf, "%s => %s", patch.old_name, patch.new_name); |
| 145 | else |
| 146 | strbuf_addstr(&buf, patch.new_name); |
| 147 | |
Thomas Gummerer | 444e096 | 2019-07-11 17:08:50 +0100 | [diff] [blame] | 148 | free(current_filename); |
| 149 | if (patch.is_delete > 0) |
| 150 | current_filename = xstrdup(patch.old_name); |
| 151 | else |
| 152 | current_filename = xstrdup(patch.new_name); |
| 153 | |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 154 | if (patch.new_mode && patch.old_mode && |
| 155 | patch.old_mode != patch.new_mode) |
| 156 | strbuf_addf(&buf, " (mode change %06o => %06o)", |
| 157 | patch.old_mode, patch.new_mode); |
| 158 | |
| 159 | strbuf_addstr(&buf, " ##"); |
Ævar Arnfjörð Bjarmason | 4998e93 | 2022-03-04 19:32:15 +0100 | [diff] [blame] | 160 | release_patch(&patch); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 161 | } else if (in_header) { |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 162 | if (starts_with(line, "Author: ")) { |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 163 | strbuf_addstr(&buf, " ## Metadata ##\n"); |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 164 | strbuf_addstr(&buf, line); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 165 | strbuf_addstr(&buf, "\n\n"); |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 166 | strbuf_addstr(&buf, " ## Commit message ##\n"); |
Denton Liu | 9f726e1 | 2019-11-20 13:18:43 -0800 | [diff] [blame] | 167 | } else if (starts_with(line, "Notes") && |
| 168 | line[strlen(line) - 1] == ':') { |
| 169 | strbuf_addstr(&buf, "\n\n"); |
| 170 | /* strip the trailing colon */ |
| 171 | strbuf_addf(&buf, " ## %.*s ##\n", |
| 172 | (int)(strlen(line) - 1), line); |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 173 | } else if (starts_with(line, " ")) { |
| 174 | p = line + len - 2; |
| 175 | while (isspace(*p) && p >= line) |
| 176 | p--; |
| 177 | strbuf_add(&buf, line, p - line + 1); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 178 | strbuf_addch(&buf, '\n'); |
| 179 | } |
| 180 | continue; |
Thomas Gummerer | e1db263 | 2019-07-11 17:08:47 +0100 | [diff] [blame] | 181 | } else if (skip_prefix(line, "@@ ", &p)) { |
| 182 | p = strstr(p, "@@"); |
Thomas Gummerer | 444e096 | 2019-07-11 17:08:50 +0100 | [diff] [blame] | 183 | strbuf_addstr(&buf, "@@"); |
| 184 | if (current_filename && p[2]) |
| 185 | strbuf_addf(&buf, " %s:", current_filename); |
| 186 | if (p) |
| 187 | strbuf_addstr(&buf, p + 2); |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 188 | } else if (!line[0]) |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 189 | /* |
| 190 | * A completely blank (not ' \n', which is context) |
| 191 | * line is not valid in a diff. We skip it |
| 192 | * silently, because this neatly handles the blank |
| 193 | * separator line between commits in git-log |
| 194 | * output. |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 195 | */ |
| 196 | continue; |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 197 | else if (line[0] == '>') { |
Stefan Beller | 8d5ccb5 | 2018-08-17 13:43:53 -0700 | [diff] [blame] | 198 | strbuf_addch(&buf, '+'); |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 199 | strbuf_addstr(&buf, line + 1); |
| 200 | } else if (line[0] == '<') { |
Stefan Beller | 8d5ccb5 | 2018-08-17 13:43:53 -0700 | [diff] [blame] | 201 | strbuf_addch(&buf, '-'); |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 202 | strbuf_addstr(&buf, line + 1); |
| 203 | } else if (line[0] == '#') { |
Stefan Beller | 8d5ccb5 | 2018-08-17 13:43:53 -0700 | [diff] [blame] | 204 | strbuf_addch(&buf, ' '); |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 205 | strbuf_addstr(&buf, line + 1); |
Stefan Beller | 8d5ccb5 | 2018-08-17 13:43:53 -0700 | [diff] [blame] | 206 | } else { |
Stefan Beller | 2543a64 | 2018-08-17 13:43:54 -0700 | [diff] [blame] | 207 | strbuf_addch(&buf, ' '); |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 208 | strbuf_addstr(&buf, line); |
Stefan Beller | 8d5ccb5 | 2018-08-17 13:43:53 -0700 | [diff] [blame] | 209 | } |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 210 | |
| 211 | strbuf_addch(&buf, '\n'); |
| 212 | util->diffsize++; |
| 213 | } |
Ævar Arnfjörð Bjarmason | 2d102c2 | 2022-03-04 19:32:16 +0100 | [diff] [blame] | 214 | |
| 215 | ret = 0; |
| 216 | cleanup: |
Thomas Gummerer | 44b67cb | 2019-07-11 17:08:46 +0100 | [diff] [blame] | 217 | strbuf_release(&contents); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 218 | |
| 219 | if (util) |
| 220 | string_list_append(list, buf.buf)->util = util; |
| 221 | strbuf_release(&buf); |
Thomas Gummerer | 444e096 | 2019-07-11 17:08:50 +0100 | [diff] [blame] | 222 | free(current_filename); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 223 | |
Ævar Arnfjörð Bjarmason | 2d102c2 | 2022-03-04 19:32:16 +0100 | [diff] [blame] | 224 | return ret; |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | static int patch_util_cmp(const void *dummy, const struct patch_util *a, |
Thomas Gummerer | 1ca6922 | 2019-07-11 17:08:45 +0100 | [diff] [blame] | 228 | const struct patch_util *b, const char *keydata) |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 229 | { |
| 230 | return strcmp(a->diff, keydata ? keydata : b->diff); |
| 231 | } |
| 232 | |
| 233 | static void find_exact_matches(struct string_list *a, struct string_list *b) |
| 234 | { |
Elijah Newren | b19315d | 2020-11-11 20:02:20 +0000 | [diff] [blame] | 235 | struct hashmap map = HASHMAP_INIT((hashmap_cmp_fn)patch_util_cmp, NULL); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 236 | int i; |
| 237 | |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 238 | /* First, add the patches of a to a hash map */ |
| 239 | for (i = 0; i < a->nr; i++) { |
| 240 | struct patch_util *util = a->items[i].util; |
| 241 | |
| 242 | util->i = i; |
| 243 | util->patch = a->items[i].string; |
| 244 | util->diff = util->patch + util->diff_offset; |
Eric Wong | d22245a | 2019-10-06 23:30:27 +0000 | [diff] [blame] | 245 | hashmap_entry_init(&util->e, strhash(util->diff)); |
Eric Wong | b94e5c1 | 2019-10-06 23:30:29 +0000 | [diff] [blame] | 246 | hashmap_add(&map, &util->e); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | /* Now try to find exact matches in b */ |
| 250 | for (i = 0; i < b->nr; i++) { |
| 251 | struct patch_util *util = b->items[i].util, *other; |
| 252 | |
| 253 | util->i = i; |
| 254 | util->patch = b->items[i].string; |
| 255 | util->diff = util->patch + util->diff_offset; |
Eric Wong | d22245a | 2019-10-06 23:30:27 +0000 | [diff] [blame] | 256 | hashmap_entry_init(&util->e, strhash(util->diff)); |
Eric Wong | 404ab78 | 2019-10-06 23:30:42 +0000 | [diff] [blame] | 257 | other = hashmap_remove_entry(&map, util, e, NULL); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 258 | if (other) { |
| 259 | if (other->matching >= 0) |
| 260 | BUG("already assigned!"); |
| 261 | |
| 262 | other->matching = i; |
| 263 | util->matching = other->i; |
| 264 | } |
| 265 | } |
| 266 | |
Elijah Newren | 6da1a25 | 2020-11-02 18:55:05 +0000 | [diff] [blame] | 267 | hashmap_clear(&map); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 268 | } |
| 269 | |
Ævar Arnfjörð Bjarmason | a8d5eb6 | 2021-04-12 19:15:24 +0200 | [diff] [blame] | 270 | static int diffsize_consume(void *data, char *line, unsigned long len) |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 271 | { |
| 272 | (*(int *)data)++; |
Ævar Arnfjörð Bjarmason | a8d5eb6 | 2021-04-12 19:15:24 +0200 | [diff] [blame] | 273 | return 0; |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 274 | } |
| 275 | |
Jeff King | d2eb809 | 2018-11-02 02:39:40 -0400 | [diff] [blame] | 276 | static void diffsize_hunk(void *data, long ob, long on, long nb, long nn, |
| 277 | const char *funcline, long funclen) |
| 278 | { |
| 279 | diffsize_consume(data, NULL, 0); |
| 280 | } |
| 281 | |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 282 | static int diffsize(const char *a, const char *b) |
| 283 | { |
| 284 | xpparam_t pp = { 0 }; |
| 285 | xdemitconf_t cfg = { 0 }; |
| 286 | mmfile_t mf1, mf2; |
| 287 | int count = 0; |
| 288 | |
| 289 | mf1.ptr = (char *)a; |
| 290 | mf1.size = strlen(a); |
| 291 | mf2.ptr = (char *)b; |
| 292 | mf2.size = strlen(b); |
| 293 | |
| 294 | cfg.ctxlen = 3; |
Jeff King | d2eb809 | 2018-11-02 02:39:40 -0400 | [diff] [blame] | 295 | if (!xdi_diff_outf(&mf1, &mf2, |
| 296 | diffsize_hunk, diffsize_consume, &count, |
| 297 | &pp, &cfg)) |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 298 | return count; |
| 299 | |
| 300 | error(_("failed to generate diff")); |
| 301 | return COST_MAX; |
| 302 | } |
| 303 | |
| 304 | static void get_correspondences(struct string_list *a, struct string_list *b, |
| 305 | int creation_factor) |
| 306 | { |
| 307 | int n = a->nr + b->nr; |
| 308 | int *cost, c, *a2b, *b2a; |
| 309 | int i, j; |
| 310 | |
| 311 | ALLOC_ARRAY(cost, st_mult(n, n)); |
| 312 | ALLOC_ARRAY(a2b, n); |
| 313 | ALLOC_ARRAY(b2a, n); |
| 314 | |
| 315 | for (i = 0; i < a->nr; i++) { |
| 316 | struct patch_util *a_util = a->items[i].util; |
| 317 | |
| 318 | for (j = 0; j < b->nr; j++) { |
| 319 | struct patch_util *b_util = b->items[j].util; |
| 320 | |
| 321 | if (a_util->matching == j) |
| 322 | c = 0; |
| 323 | else if (a_util->matching < 0 && b_util->matching < 0) |
| 324 | c = diffsize(a_util->diff, b_util->diff); |
| 325 | else |
| 326 | c = COST_MAX; |
| 327 | cost[i + n * j] = c; |
| 328 | } |
| 329 | |
| 330 | c = a_util->matching < 0 ? |
| 331 | a_util->diffsize * creation_factor / 100 : COST_MAX; |
| 332 | for (j = b->nr; j < n; j++) |
| 333 | cost[i + n * j] = c; |
| 334 | } |
| 335 | |
| 336 | for (j = 0; j < b->nr; j++) { |
| 337 | struct patch_util *util = b->items[j].util; |
| 338 | |
| 339 | c = util->matching < 0 ? |
| 340 | util->diffsize * creation_factor / 100 : COST_MAX; |
| 341 | for (i = a->nr; i < n; i++) |
| 342 | cost[i + n * j] = c; |
| 343 | } |
| 344 | |
| 345 | for (i = a->nr; i < n; i++) |
| 346 | for (j = b->nr; j < n; j++) |
| 347 | cost[i + n * j] = 0; |
| 348 | |
| 349 | compute_assignment(n, n, cost, a2b, b2a); |
| 350 | |
| 351 | for (i = 0; i < a->nr; i++) |
| 352 | if (a2b[i] >= 0 && a2b[i] < b->nr) { |
| 353 | struct patch_util *a_util = a->items[i].util; |
| 354 | struct patch_util *b_util = b->items[a2b[i]].util; |
| 355 | |
| 356 | a_util->matching = a2b[i]; |
| 357 | b_util->matching = i; |
| 358 | } |
| 359 | |
| 360 | free(cost); |
| 361 | free(a2b); |
| 362 | free(b2a); |
| 363 | } |
| 364 | |
Johannes Schindelin | faa1df8 | 2018-08-13 04:33:18 -0700 | [diff] [blame] | 365 | static void output_pair_header(struct diff_options *diffopt, |
Johannes Schindelin | d1f87a2 | 2018-08-13 04:33:28 -0700 | [diff] [blame] | 366 | int patch_no_width, |
Johannes Schindelin | faa1df8 | 2018-08-13 04:33:18 -0700 | [diff] [blame] | 367 | struct strbuf *buf, |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 368 | struct strbuf *dashes, |
| 369 | struct patch_util *a_util, |
| 370 | struct patch_util *b_util) |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 371 | { |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 372 | struct object_id *oid = a_util ? &a_util->oid : &b_util->oid; |
| 373 | struct commit *commit; |
Johannes Schindelin | faa1df8 | 2018-08-13 04:33:18 -0700 | [diff] [blame] | 374 | char status; |
| 375 | const char *color_reset = diff_get_color_opt(diffopt, DIFF_RESET); |
| 376 | const char *color_old = diff_get_color_opt(diffopt, DIFF_FILE_OLD); |
| 377 | const char *color_new = diff_get_color_opt(diffopt, DIFF_FILE_NEW); |
| 378 | const char *color_commit = diff_get_color_opt(diffopt, DIFF_COMMIT); |
| 379 | const char *color; |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 380 | |
| 381 | if (!dashes->len) |
| 382 | strbuf_addchars(dashes, '-', |
| 383 | strlen(find_unique_abbrev(oid, |
| 384 | DEFAULT_ABBREV))); |
| 385 | |
Johannes Schindelin | faa1df8 | 2018-08-13 04:33:18 -0700 | [diff] [blame] | 386 | if (!b_util) { |
| 387 | color = color_old; |
| 388 | status = '<'; |
| 389 | } else if (!a_util) { |
| 390 | color = color_new; |
| 391 | status = '>'; |
| 392 | } else if (strcmp(a_util->patch, b_util->patch)) { |
| 393 | color = color_commit; |
| 394 | status = '!'; |
| 395 | } else { |
| 396 | color = color_commit; |
| 397 | status = '='; |
| 398 | } |
| 399 | |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 400 | strbuf_reset(buf); |
Johannes Schindelin | faa1df8 | 2018-08-13 04:33:18 -0700 | [diff] [blame] | 401 | strbuf_addstr(buf, status == '!' ? color_old : color); |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 402 | if (!a_util) |
Johannes Schindelin | d1f87a2 | 2018-08-13 04:33:28 -0700 | [diff] [blame] | 403 | strbuf_addf(buf, "%*s: %s ", patch_no_width, "-", dashes->buf); |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 404 | else |
Johannes Schindelin | d1f87a2 | 2018-08-13 04:33:28 -0700 | [diff] [blame] | 405 | strbuf_addf(buf, "%*d: %s ", patch_no_width, a_util->i + 1, |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 406 | find_unique_abbrev(&a_util->oid, DEFAULT_ABBREV)); |
| 407 | |
Johannes Schindelin | faa1df8 | 2018-08-13 04:33:18 -0700 | [diff] [blame] | 408 | if (status == '!') |
| 409 | strbuf_addf(buf, "%s%s", color_reset, color); |
| 410 | strbuf_addch(buf, status); |
| 411 | if (status == '!') |
| 412 | strbuf_addf(buf, "%s%s", color_reset, color_new); |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 413 | |
| 414 | if (!b_util) |
Johannes Schindelin | d1f87a2 | 2018-08-13 04:33:28 -0700 | [diff] [blame] | 415 | strbuf_addf(buf, " %*s: %s", patch_no_width, "-", dashes->buf); |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 416 | else |
Johannes Schindelin | d1f87a2 | 2018-08-13 04:33:28 -0700 | [diff] [blame] | 417 | strbuf_addf(buf, " %*d: %s", patch_no_width, b_util->i + 1, |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 418 | find_unique_abbrev(&b_util->oid, DEFAULT_ABBREV)); |
| 419 | |
| 420 | commit = lookup_commit_reference(the_repository, oid); |
| 421 | if (commit) { |
Johannes Schindelin | faa1df8 | 2018-08-13 04:33:18 -0700 | [diff] [blame] | 422 | if (status == '!') |
| 423 | strbuf_addf(buf, "%s%s", color_reset, color); |
| 424 | |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 425 | strbuf_addch(buf, ' '); |
| 426 | pp_commit_easy(CMIT_FMT_ONELINE, commit, buf); |
| 427 | } |
Johannes Schindelin | faa1df8 | 2018-08-13 04:33:18 -0700 | [diff] [blame] | 428 | strbuf_addf(buf, "%s\n", color_reset); |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 429 | |
Eric Sunshine | 87f1b2d | 2018-07-22 05:57:10 -0400 | [diff] [blame] | 430 | fwrite(buf->buf, buf->len, 1, diffopt->file); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 431 | } |
| 432 | |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 433 | static struct userdiff_driver section_headers = { |
| 434 | .funcname = { "^ ## (.*) ##$\n" |
| 435 | "^.?@@ (.*)$", REG_EXTENDED } |
Johannes Schindelin | 4eba1fe | 2018-08-13 04:33:14 -0700 | [diff] [blame] | 436 | }; |
| 437 | |
Johannes Schindelin | c8c5e43 | 2018-08-13 04:33:07 -0700 | [diff] [blame] | 438 | static struct diff_filespec *get_filespec(const char *name, const char *p) |
| 439 | { |
| 440 | struct diff_filespec *spec = alloc_filespec(name); |
| 441 | |
brian m. carlson | 1422844 | 2021-04-26 01:02:56 +0000 | [diff] [blame] | 442 | fill_filespec(spec, null_oid(), 0, 0100644); |
Johannes Schindelin | c8c5e43 | 2018-08-13 04:33:07 -0700 | [diff] [blame] | 443 | spec->data = (char *)p; |
| 444 | spec->size = strlen(p); |
| 445 | spec->should_munmap = 0; |
| 446 | spec->is_stdin = 1; |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 447 | spec->driver = §ion_headers; |
Johannes Schindelin | c8c5e43 | 2018-08-13 04:33:07 -0700 | [diff] [blame] | 448 | |
| 449 | return spec; |
| 450 | } |
| 451 | |
| 452 | static void patch_diff(const char *a, const char *b, |
Thomas Gummerer | 1ca6922 | 2019-07-11 17:08:45 +0100 | [diff] [blame] | 453 | struct diff_options *diffopt) |
Johannes Schindelin | c8c5e43 | 2018-08-13 04:33:07 -0700 | [diff] [blame] | 454 | { |
| 455 | diff_queue(&diff_queued_diff, |
| 456 | get_filespec("a", a), get_filespec("b", b)); |
| 457 | |
| 458 | diffcore_std(diffopt); |
| 459 | diff_flush(diffopt); |
| 460 | } |
| 461 | |
Johannes Schindelin | 3e6046e | 2021-02-05 14:46:12 +0000 | [diff] [blame] | 462 | static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data) |
| 463 | { |
| 464 | return data; |
| 465 | } |
| 466 | |
Johannes Schindelin | c8c5e43 | 2018-08-13 04:33:07 -0700 | [diff] [blame] | 467 | static void output(struct string_list *a, struct string_list *b, |
Johannes Schindelin | 3e6046e | 2021-02-05 14:46:12 +0000 | [diff] [blame] | 468 | struct range_diff_options *range_diff_opts) |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 469 | { |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 470 | struct strbuf buf = STRBUF_INIT, dashes = STRBUF_INIT; |
Johannes Schindelin | d1f87a2 | 2018-08-13 04:33:28 -0700 | [diff] [blame] | 471 | int patch_no_width = decimal_width(1 + (a->nr > b->nr ? a->nr : b->nr)); |
Johannes Schindelin | 9dc46e0 | 2018-08-13 04:33:05 -0700 | [diff] [blame] | 472 | int i = 0, j = 0; |
Johannes Schindelin | 3e6046e | 2021-02-05 14:46:12 +0000 | [diff] [blame] | 473 | struct diff_options opts; |
| 474 | struct strbuf indent = STRBUF_INIT; |
| 475 | |
| 476 | if (range_diff_opts->diffopt) |
| 477 | memcpy(&opts, range_diff_opts->diffopt, sizeof(opts)); |
| 478 | else |
| 479 | diff_setup(&opts); |
| 480 | |
René Scharfe | 709b3f3 | 2021-09-04 09:50:58 +0200 | [diff] [blame] | 481 | opts.no_free = 1; |
Johannes Schindelin | 3e6046e | 2021-02-05 14:46:12 +0000 | [diff] [blame] | 482 | if (!opts.output_format) |
| 483 | opts.output_format = DIFF_FORMAT_PATCH; |
| 484 | opts.flags.suppress_diff_headers = 1; |
| 485 | opts.flags.dual_color_diffed_diffs = |
| 486 | range_diff_opts->dual_color; |
| 487 | opts.flags.suppress_hunk_header_line_count = 1; |
| 488 | opts.output_prefix = output_prefix_cb; |
| 489 | strbuf_addstr(&indent, " "); |
| 490 | opts.output_prefix_data = &indent; |
| 491 | diff_setup_done(&opts); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 492 | |
Johannes Schindelin | 9dc46e0 | 2018-08-13 04:33:05 -0700 | [diff] [blame] | 493 | /* |
| 494 | * We assume the user is really more interested in the second argument |
| 495 | * ("newer" version). To that end, we print the output in the order of |
| 496 | * the RHS (the `b` parameter). To put the LHS (the `a` parameter) |
| 497 | * commits that are no longer in the RHS into a good place, we place |
| 498 | * them once we have shown all of their predecessors in the LHS. |
| 499 | */ |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 500 | |
Johannes Schindelin | 9dc46e0 | 2018-08-13 04:33:05 -0700 | [diff] [blame] | 501 | while (i < a->nr || j < b->nr) { |
| 502 | struct patch_util *a_util, *b_util; |
| 503 | a_util = i < a->nr ? a->items[i].util : NULL; |
| 504 | b_util = j < b->nr ? b->items[j].util : NULL; |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 505 | |
Johannes Schindelin | 9dc46e0 | 2018-08-13 04:33:05 -0700 | [diff] [blame] | 506 | /* Skip all the already-shown commits from the LHS. */ |
| 507 | while (i < a->nr && a_util->shown) |
| 508 | a_util = ++i < a->nr ? a->items[i].util : NULL; |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 509 | |
Johannes Schindelin | 9dc46e0 | 2018-08-13 04:33:05 -0700 | [diff] [blame] | 510 | /* Show unmatched LHS commit whose predecessors were shown. */ |
| 511 | if (i < a->nr && a_util->matching < 0) { |
Johannes Schindelin | 1e79f97 | 2021-02-05 14:46:13 +0000 | [diff] [blame] | 512 | if (!range_diff_opts->right_only) |
| 513 | output_pair_header(&opts, patch_no_width, |
Johannes Schindelin | faa1df8 | 2018-08-13 04:33:18 -0700 | [diff] [blame] | 514 | &buf, &dashes, a_util, NULL); |
Johannes Schindelin | 9dc46e0 | 2018-08-13 04:33:05 -0700 | [diff] [blame] | 515 | i++; |
| 516 | continue; |
| 517 | } |
| 518 | |
| 519 | /* Show unmatched RHS commits. */ |
| 520 | while (j < b->nr && b_util->matching < 0) { |
Johannes Schindelin | 1e79f97 | 2021-02-05 14:46:13 +0000 | [diff] [blame] | 521 | if (!range_diff_opts->left_only) |
| 522 | output_pair_header(&opts, patch_no_width, |
Johannes Schindelin | faa1df8 | 2018-08-13 04:33:18 -0700 | [diff] [blame] | 523 | &buf, &dashes, NULL, b_util); |
Johannes Schindelin | 9dc46e0 | 2018-08-13 04:33:05 -0700 | [diff] [blame] | 524 | b_util = ++j < b->nr ? b->items[j].util : NULL; |
| 525 | } |
| 526 | |
| 527 | /* Show matching LHS/RHS pair. */ |
| 528 | if (j < b->nr) { |
| 529 | a_util = a->items[b_util->matching].util; |
Johannes Schindelin | 3e6046e | 2021-02-05 14:46:12 +0000 | [diff] [blame] | 530 | output_pair_header(&opts, patch_no_width, |
Johannes Schindelin | faa1df8 | 2018-08-13 04:33:18 -0700 | [diff] [blame] | 531 | &buf, &dashes, a_util, b_util); |
Johannes Schindelin | 3e6046e | 2021-02-05 14:46:12 +0000 | [diff] [blame] | 532 | if (!(opts.output_format & DIFF_FORMAT_NO_OUTPUT)) |
Johannes Schindelin | c8c5e43 | 2018-08-13 04:33:07 -0700 | [diff] [blame] | 533 | patch_diff(a->items[b_util->matching].string, |
Johannes Schindelin | 3e6046e | 2021-02-05 14:46:12 +0000 | [diff] [blame] | 534 | b->items[j].string, &opts); |
Johannes Schindelin | 9dc46e0 | 2018-08-13 04:33:05 -0700 | [diff] [blame] | 535 | a_util->shown = 1; |
| 536 | j++; |
| 537 | } |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 538 | } |
Johannes Schindelin | eb0be38 | 2018-08-13 04:33:13 -0700 | [diff] [blame] | 539 | strbuf_release(&buf); |
| 540 | strbuf_release(&dashes); |
Johannes Schindelin | 3e6046e | 2021-02-05 14:46:12 +0000 | [diff] [blame] | 541 | strbuf_release(&indent); |
René Scharfe | 709b3f3 | 2021-09-04 09:50:58 +0200 | [diff] [blame] | 542 | opts.no_free = 0; |
| 543 | diff_free(&opts); |
Eric Sunshine | 73a834e | 2018-07-22 05:57:12 -0400 | [diff] [blame] | 544 | } |
| 545 | |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 546 | int show_range_diff(const char *range1, const char *range2, |
Johannes Schindelin | f1ce6c1 | 2021-02-05 14:46:11 +0000 | [diff] [blame] | 547 | struct range_diff_options *range_diff_opts) |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 548 | { |
| 549 | int res = 0; |
| 550 | |
| 551 | struct string_list branch1 = STRING_LIST_INIT_DUP; |
| 552 | struct string_list branch2 = STRING_LIST_INIT_DUP; |
| 553 | |
Johannes Schindelin | 1e79f97 | 2021-02-05 14:46:13 +0000 | [diff] [blame] | 554 | if (range_diff_opts->left_only && range_diff_opts->right_only) |
Jean-Noël Avila | 43ea635 | 2022-01-05 20:02:14 +0000 | [diff] [blame] | 555 | res = error(_("options '%s' and '%s' cannot be used together"), "--left-only", "--right-only"); |
Johannes Schindelin | 1e79f97 | 2021-02-05 14:46:13 +0000 | [diff] [blame] | 556 | |
| 557 | if (!res && read_patches(range1, &branch1, range_diff_opts->other_arg)) |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 558 | res = error(_("could not parse log for '%s'"), range1); |
Johannes Schindelin | f1ce6c1 | 2021-02-05 14:46:11 +0000 | [diff] [blame] | 559 | if (!res && read_patches(range2, &branch2, range_diff_opts->other_arg)) |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 560 | res = error(_("could not parse log for '%s'"), range2); |
| 561 | |
| 562 | if (!res) { |
| 563 | find_exact_matches(&branch1, &branch2); |
Johannes Schindelin | f1ce6c1 | 2021-02-05 14:46:11 +0000 | [diff] [blame] | 564 | get_correspondences(&branch1, &branch2, |
| 565 | range_diff_opts->creation_factor); |
Johannes Schindelin | 3e6046e | 2021-02-05 14:46:12 +0000 | [diff] [blame] | 566 | output(&branch1, &branch2, range_diff_opts); |
Johannes Schindelin | d9c66f0 | 2018-08-13 04:33:04 -0700 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | string_list_clear(&branch1, 1); |
| 570 | string_list_clear(&branch2, 1); |
| 571 | |
| 572 | return res; |
| 573 | } |
Johannes Schindelin | 679b591 | 2021-01-27 16:37:22 +0000 | [diff] [blame] | 574 | |
| 575 | int is_range_diff_range(const char *arg) |
| 576 | { |
Johannes Schindelin | 359f0d7 | 2021-02-05 14:44:48 +0000 | [diff] [blame] | 577 | char *copy = xstrdup(arg); /* setup_revisions() modifies it */ |
| 578 | const char *argv[] = { "", copy, "--", NULL }; |
| 579 | int i, positive = 0, negative = 0; |
| 580 | struct rev_info revs; |
| 581 | |
| 582 | init_revisions(&revs, NULL); |
| 583 | if (setup_revisions(3, argv, &revs, NULL) == 1) { |
| 584 | for (i = 0; i < revs.pending.nr; i++) |
| 585 | if (revs.pending.objects[i].item->flags & UNINTERESTING) |
| 586 | negative++; |
| 587 | else |
| 588 | positive++; |
| 589 | for (i = 0; i < revs.pending.nr; i++) { |
| 590 | struct object *obj = revs.pending.objects[i].item; |
| 591 | |
| 592 | if (obj->type == OBJ_COMMIT) |
| 593 | clear_commit_marks((struct commit *)obj, |
| 594 | ALL_REV_FLAGS); |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | free(copy); |
Ævar Arnfjörð Bjarmason | 1878b5e | 2022-04-13 22:01:35 +0200 | [diff] [blame] | 599 | release_revisions(&revs); |
Johannes Schindelin | 359f0d7 | 2021-02-05 14:44:48 +0000 | [diff] [blame] | 600 | return negative > 0 && positive > 0; |
Johannes Schindelin | 679b591 | 2021-01-27 16:37:22 +0000 | [diff] [blame] | 601 | } |