static bool stage_diff_single_write(struct io *io, bool staged, struct line *line, struct line *single, struct line *end) { enum line_type write_as_normal = staged ? LINE_DIFF_ADD : LINE_DIFF_DEL; enum line_type ignore = staged ? LINE_DIFF_DEL : LINE_DIFF_ADD; while (line < end) { const char *prefix = ""; const char *data = box_text(line); if (line == single) { /* Write the complete line. */ } else if (line->type == write_as_normal) { prefix = " "; data = data + 1; } else if (line->type == ignore) { data = NULL; } if (data && !io_printf(io, "%s%s\n", prefix, data)) return false; line++; if (stage_diff_done(line, end)) break; } return true; }
static bool stage_diff_write(struct io *io, struct line *line, struct line *end) { while (line < end) { if (!io_write(io, line->data, strlen(line->data)) || !io_write(io, "\n", 1)) return FALSE; line++; if (stage_diff_done(line, end)) break; } return TRUE; }
static bool stage_diff_write(struct io *io, struct line *line, struct line *end) { while (line < end) { const char *text = box_text(line); if (!io_write(io, text, strlen(text)) || !io_write(io, "\n", 1)) return false; line++; if (stage_diff_done(line, end)) break; } return true; }