78
}
79
80
static void wt_status_print_dirty_header(struct wt_status *s,
81
- int has_deleted)
81
+ int has_deleted,
82
+ int has_dirty_submodules)
83
{
84
const char *c = color(WT_STATUS_HEADER, s);
85
91
else
92
color_fprintf_ln(s->fp, c, "# (use \"git add/rm <file>...\" to update what will be committed)");
93
color_fprintf_ln(s->fp, c, "# (use \"git checkout -- <file>...\" to discard changes in working directory)");
94
+ if (has_dirty_submodules)
95
+ color_fprintf_ln(s->fp, c, "# (commit or discard the untracked or modified content in submodules)");
96
color_fprintf_ln(s->fp, c, "#");
97
}
98
147
char *two_name;
148
const char *one, *two;
149
struct strbuf onebuf = STRBUF_INIT, twobuf = STRBUF_INIT;
150
+ struct strbuf extra = STRBUF_INIT;
151
152
one_name = two_name = it->string;
153
switch (change_type) {
157
one_name = d->head_path;
158
break;
159
case WT_STATUS_CHANGED:
160
+ if (d->new_submodule_commits || d->dirty_submodule) {
161
+ strbuf_addstr(&extra, " (");
162
+ if (d->new_submodule_commits)
163
+ strbuf_addf(&extra, "new commits, ");
164
+ if (d->dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
165
+ strbuf_addf(&extra, "modified content, ");
166
+ if (d->dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
167
+ strbuf_addf(&extra, "untracked content, ");
168
+ strbuf_setlen(&extra, extra.len - 2);
169
+ strbuf_addch(&extra, ')');
170
+ }
171
status = d->worktree_status;
172
break;
173
}
204
default:
205
die("bug: unhandled diff status %c", status);
206
}
207
+ if (extra.len) {
208
+ color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "%s", extra.buf);
209
+ strbuf_release(&extra);
210
+ }
211
fprintf(s->fp, "\n");
212
strbuf_release(&onebuf);
213
strbuf_release(&twobuf);
237
}
238
if (!d->worktree_status)
239
d->worktree_status = p->status;
240
+ d->dirty_submodule = p->two->dirty_submodule;
241
+ if (S_ISGITLINK(p->two->mode))
242
+ d->new_submodule_commits = !!hashcmp(p->one->sha1, p->two->sha1);
243
}
244
}
245
303
init_revisions(&rev, NULL);
304
setup_revisions(0, NULL, &rev, NULL);
305
rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
306
+ DIFF_OPT_SET(&rev.diffopt, DIRTY_SUBMODULES);
307
rev.diffopt.format_callback = wt_status_collect_changed_cb;
308
rev.diffopt.format_callback_data = s;
309
rev.prune_data = s->pathspec;
441
* 0 : no change
442
* 1 : some change but no delete
443
*/
421
-static int wt_status_check_worktree_changes(struct wt_status *s)
444
+static int wt_status_check_worktree_changes(struct wt_status *s,
445
+ int *dirty_submodules)
446
{
447
int i;
448
int changes = 0;
449
450
+ *dirty_submodules = 0;
451
+
452
for (i = 0; i < s->change.nr; i++) {
453
struct wt_status_change_data *d;
454
d = s->change.items[i].util;
455
if (!d->worktree_status ||
456
d->worktree_status == DIFF_STATUS_UNMERGED)
457
continue;
432
- changes = 1;
458
+ if (!changes)
459
+ changes = 1;
460
+ if (d->dirty_submodule)
461
+ *dirty_submodules = 1;
462
if (d->worktree_status == DIFF_STATUS_DELETED)
434
- return -1;
463
+ changes = -1;
464
}
465
return changes;
466
}
467
468
static void wt_status_print_changed(struct wt_status *s)
469
{
441
- int i;
442
- int worktree_changes = wt_status_check_worktree_changes(s);
470
+ int i, dirty_submodules;
471
+ int worktree_changes = wt_status_check_worktree_changes(s, &dirty_submodules);
472
473
if (!worktree_changes)
474
return;
475
447
- wt_status_print_dirty_header(s, worktree_changes < 0);
476
+ wt_status_print_dirty_header(s, worktree_changes < 0, dirty_submodules);
477
478
for (i = 0; i < s->change.nr; i++) {
479
struct wt_status_change_data *d;