Skip to content

Commit 0f33a06

Browse files
johnkeepinggitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bfd70c5 commit 0f33a06

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

diff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,6 +2255,7 @@ static void builtin_diff(const char *name_a,
22552255
const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
22562256
const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
22572257
show_submodule_summary(o->file, one ? one->path : two->path,
2258+
line_prefix,
22582259
one->sha1, two->sha1, two->dirty_submodule,
22592260
meta, del, add, reset);
22602261
return;

submodule.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ static int prepare_submodule_summary(struct rev_info *rev, const char *path,
216216
}
217217

218218
static void print_submodule_summary(struct rev_info *rev, FILE *f,
219+
const char *line_prefix,
219220
const char *del, const char *add, const char *reset)
220221
{
221222
static const char format[] = " %m %s";
@@ -226,6 +227,7 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
226227
struct pretty_print_context ctx = {0};
227228
ctx.date_mode = rev->date_mode;
228229
strbuf_setlen(&sb, 0);
230+
strbuf_addstr(&sb, line_prefix);
229231
if (commit->object.flags & SYMMETRIC_LEFT) {
230232
if (del)
231233
strbuf_addstr(&sb, del);
@@ -256,6 +258,7 @@ int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
256258
}
257259

258260
void show_submodule_summary(FILE *f, const char *path,
261+
const char *line_prefix,
259262
unsigned char one[20], unsigned char two[20],
260263
unsigned dirty_submodule, const char *meta,
261264
const char *del, const char *add, const char *reset)
@@ -280,16 +283,18 @@ void show_submodule_summary(FILE *f, const char *path,
280283
message = "(revision walker failed)";
281284

282285
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);
284288
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);
286291

287292
if (!hashcmp(one, two)) {
288293
strbuf_release(&sb);
289294
return;
290295
}
291296

292-
strbuf_addf(&sb, "%sSubmodule %s %s..", meta, path,
297+
strbuf_addf(&sb, "%s%sSubmodule %s %s..", line_prefix, meta, path,
293298
find_unique_abbrev(one, DEFAULT_ABBREV));
294299
if (!fast_backward && !fast_forward)
295300
strbuf_addch(&sb, '.');
@@ -301,7 +306,7 @@ void show_submodule_summary(FILE *f, const char *path,
301306
fwrite(sb.buf, sb.len, 1, f);
302307

303308
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);
305310
if (left)
306311
clear_commit_marks(left, ~0);
307312
if (right)

submodule.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ int parse_submodule_config_option(const char *var, const char *value);
1919
void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
2020
int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
2121
void show_submodule_summary(FILE *f, const char *path,
22+
const char *line_prefix,
2223
unsigned char one[20], unsigned char two[20],
2324
unsigned dirty_submodule, const char *meta,
2425
const char *del, const char *add, const char *reset);

0 commit comments

Comments
 (0)