| 2352 | "----------------------------------------------------------------------"; |
| 2353 | |
| 2354 | static void show_stats(struct apply_state *state, struct patch *patch) |
| 2355 | { |
| 2356 | struct strbuf qname = STRBUF_INIT; |
| 2357 | char *cp = patch->new_name ? patch->new_name : patch->old_name; |
| 2358 | int max, add, del; |
| 2359 | |
| 2360 | quote_c_style(cp, &qname, NULL, 0); |
| 2361 | |
| 2362 | /* |
| 2363 | * "scale" the filename |
| 2364 | */ |
| 2365 | max = state->max_len; |
| 2366 | if (max > 50) |
| 2367 | max = 50; |
| 2368 | |
| 2369 | if (qname.len > max) { |
| 2370 | cp = strchr(qname.buf + qname.len + 3 - max, '/'); |
| 2371 | if (!cp) |
| 2372 | cp = qname.buf + qname.len + 3 - max; |
| 2373 | strbuf_splice(&qname, 0, cp - qname.buf, "...", 3); |
| 2374 | } |
| 2375 | |
| 2376 | if (patch->is_binary) { |
| 2377 | printf(" %-*s | Bin\n", max, qname.buf); |
| 2378 | strbuf_release(&qname); |
| 2379 | return; |
| 2380 | } |
| 2381 | |
| 2382 | printf(" %-*s |", max, qname.buf); |
| 2383 | strbuf_release(&qname); |
| 2384 | |
| 2385 | /* |
| 2386 | * scale the add/delete |
| 2387 | */ |
| 2388 | max = max + state->max_change > 70 ? 70 - max : state->max_change; |
| 2389 | add = patch->lines_added; |
| 2390 | del = patch->lines_deleted; |
| 2391 | |
| 2392 | if (state->max_change > 0) { |
| 2393 | int total = ((add + del) * max + state->max_change / 2) / state->max_change; |
| 2394 | add = (add * max + state->max_change / 2) / state->max_change; |
| 2395 | del = total - add; |
| 2396 | } |
| 2397 | printf("%5d %.*s%.*s\n", patch->lines_added + patch->lines_deleted, |
| 2398 | add, pluses, del, minuses); |
| 2399 | } |
| 2400 | |
| 2401 | static int read_old_data(struct stat *st, struct patch *patch, |
| 2402 | const char *path, struct strbuf *buf) |
no test coverage detected