submodule: print graph output next to submodule log

When running "git log -p --submodule=log", the submodule log is not indented by the graph output, although all other lines are. Fix this by prepending the current line prefix to each line of the submodule log. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

John Keeping committed Apr 5, 2013 at 17:12 UTC 0f33a0677d6d93b3f6d8fb7d1df62f30eb7b73a9
3 files changed +11 -4
diff.c
+1
@@ -2255,6 +2255,7 @@ static void builtin_diff(const char *name_a,
2255 const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
2256 const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
2257 show_submodule_summary(o->file, one ? one->path : two->path,
2258 + line_prefix,
2259 one->sha1, two->sha1, two->dirty_submodule,
2260 meta, del, add, reset);
2261 return;
submodule.c
+9 -4
@@ -216,6 +216,7 @@ static int prepare_submodule_summary(struct rev_info *rev, const char *path,
216 }
217
218 static void print_submodule_summary(struct rev_info *rev, FILE *f,
219 + const char *line_prefix,
220 const char *del, const char *add, const char *reset)
221 {
222 static const char format[] = " %m %s";
@@ -226,6 +227,7 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
227 struct pretty_print_context ctx = {0};
228 ctx.date_mode = rev->date_mode;
229 strbuf_setlen(&sb, 0);
230 + strbuf_addstr(&sb, line_prefix);
231 if (commit->object.flags & SYMMETRIC_LEFT) {
232 if (del)
233 strbuf_addstr(&sb, del);
@@ -256,6 +258,7 @@ int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
258 }
259
260 void show_submodule_summary(FILE *f, const char *path,
261 + const char *line_prefix,
262 unsigned char one[20], unsigned char two[20],
263 unsigned dirty_submodule, const char *meta,
264 const char *del, const char *add, const char *reset)
@@ -280,16 +283,18 @@ void show_submodule_summary(FILE *f, const char *path,
283 message = "(revision walker failed)";
284
285 if (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
283 - fprintf(f, "Submodule %s contains untracked content\n", path);
286 + fprintf(f, "%sSubmodule %s contains untracked content\n",
287 + line_prefix, path);
288 if (dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
285 - fprintf(f, "Submodule %s contains modified content\n", path);
289 + fprintf(f, "%sSubmodule %s contains modified content\n",
290 + line_prefix, path);
291
292 if (!hashcmp(one, two)) {
293 strbuf_release(&sb);
294 return;
295 }
296
292 - strbuf_addf(&sb, "%sSubmodule %s %s..", meta, path,
297 + strbuf_addf(&sb, "%s%sSubmodule %s %s..", line_prefix, meta, path,
298 find_unique_abbrev(one, DEFAULT_ABBREV));
299 if (!fast_backward && !fast_forward)
300 strbuf_addch(&sb, '.');
@@ -301,7 +306,7 @@ void show_submodule_summary(FILE *f, const char *path,
306 fwrite(sb.buf, sb.len, 1, f);
307
308 if (!message) /* only NULL if we succeeded in setting up the walk */
304 - print_submodule_summary(&rev, f, del, add, reset);
309 + print_submodule_summary(&rev, f, line_prefix, del, add, reset);
310 if (left)
311 clear_commit_marks(left, ~0);
312 if (right)
submodule.h
+1
@@ -19,6 +19,7 @@ int parse_submodule_config_option(const char *var, const char *value);
19 void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
20 int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
21 void show_submodule_summary(FILE *f, const char *path,
22 + const char *line_prefix,
23 unsigned char one[20], unsigned char two[20],
24 unsigned dirty_submodule, const char *meta,
25 const char *del, const char *add, const char *reset);