From 76e2f7ce323c7ddb3a7c29e56407da6a69a4fa53 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 7 Aug 2009 23:31:57 -0700 Subject: git stat: the beginning of "status that is not a dry-run of commit" Tentatively add "git stat" as a new command. This is not "preview of commit with the same arguments"; the path parameters are not paths to be added to the pristine index (aka "--only" option), but are taken as pathspecs to limit the output. Later in 1.7.0 release, it will take over "git status". Signed-off-by: Junio C Hamano --- wt-status.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'wt-status.c') diff --git a/wt-status.c b/wt-status.c index 63598ce40c..249227c382 100644 --- a/wt-status.c +++ b/wt-status.c @@ -269,6 +269,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s) rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = wt_status_collect_changed_cb; rev.diffopt.format_callback_data = s; + rev.prune_data = s->pathspec; run_diff_files(&rev, 0); } @@ -285,6 +286,7 @@ static void wt_status_collect_changes_index(struct wt_status *s) rev.diffopt.detect_rename = 1; rev.diffopt.rename_limit = 200; rev.diffopt.break_opt = 0; + rev.prune_data = s->pathspec; run_diff_index(&rev, 1); } @@ -297,6 +299,8 @@ static void wt_status_collect_changes_initial(struct wt_status *s) struct wt_status_change_data *d; struct cache_entry *ce = active_cache[i]; + if (!ce_path_match(ce, s->pathspec)) + continue; it = string_list_insert(ce->name, &s->change); d = it->util; if (!d) { @@ -330,6 +334,8 @@ static void wt_status_collect_untracked(struct wt_status *s) struct dir_entry *ent = dir.entries[i]; if (!cache_name_is_other(ent->name, ent->len)) continue; + if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL)) + continue; s->workdir_untracked = 1; string_list_insert(ent->name, &s->untracked); } @@ -533,10 +539,8 @@ static void wt_status_print_tracking(struct wt_status *s) void wt_status_print(struct wt_status *s) { - unsigned char sha1[20]; const char *branch_color = color(WT_STATUS_HEADER, s); - s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0; if (s->branch) { const char *on_what = "On branch "; const char *branch_name = s->branch; @@ -553,8 +557,6 @@ void wt_status_print(struct wt_status *s) wt_status_print_tracking(s); } - wt_status_collect(s); - if (s->is_initial) { color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#"); color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "# Initial commit"); -- cgit 1.2.3-korg From 84dbe7b867cfaaa929ed1941f930d564514ae714 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Sat, 5 Dec 2009 16:04:37 +0100 Subject: builtin-commit: refactor short-status code into wt-status.c Currently, builtin-commit.c contains most code producing the short-status output, whereas wt-status.c contains most of the code for the long format. Refactor so that most of the long and short format producing code resides in wt-status.c and is named analogously. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- builtin-commit.c | 101 +++---------------------------------------------------- wt-status.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ wt-status.h | 2 ++ 3 files changed, 95 insertions(+), 97 deletions(-) (limited to 'wt-status.c') diff --git a/builtin-commit.c b/builtin-commit.c index f49b598cbd..8411236fda 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -79,8 +79,6 @@ static enum { STATUS_FORMAT_PORCELAIN, } status_format = STATUS_FORMAT_LONG; -static void short_print(struct wt_status *s, int null_termination); - static int opt_parse_m(const struct option *opt, const char *arg, int unset) { struct strbuf *buf = opt->value; @@ -381,10 +379,10 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int switch (status_format) { case STATUS_FORMAT_SHORT: - short_print(s, null_termination); + wt_shortstatus_print(s, null_termination); break; case STATUS_FORMAT_PORCELAIN: - short_print(s, null_termination); + wt_shortstatus_print(s, null_termination); break; case STATUS_FORMAT_LONG: wt_status_print(s); @@ -928,97 +926,6 @@ static int git_status_config(const char *k, const char *v, void *cb) return git_diff_ui_config(k, v, NULL); } -#define quote_path quote_path_relative - -static void short_unmerged(int null_termination, struct string_list_item *it, - struct wt_status *s) -{ - struct wt_status_change_data *d = it->util; - const char *how = "??"; - - switch (d->stagemask) { - case 1: how = "DD"; break; /* both deleted */ - case 2: how = "AU"; break; /* added by us */ - case 3: how = "UD"; break; /* deleted by them */ - case 4: how = "UA"; break; /* added by them */ - case 5: how = "DU"; break; /* deleted by us */ - case 6: how = "AA"; break; /* both added */ - case 7: how = "UU"; break; /* both modified */ - } - printf("%s ", how); - if (null_termination) { - fprintf(stdout, "%s%c", it->string, 0); - } else { - struct strbuf onebuf = STRBUF_INIT; - const char *one; - one = quote_path(it->string, -1, &onebuf, s->prefix); - printf("%s\n", one); - strbuf_release(&onebuf); - } -} - -static void short_status(int null_termination, struct string_list_item *it, - struct wt_status *s) -{ - struct wt_status_change_data *d = it->util; - - printf("%c%c ", - !d->index_status ? ' ' : d->index_status, - !d->worktree_status ? ' ' : d->worktree_status); - if (null_termination) { - fprintf(stdout, "%s%c", it->string, 0); - if (d->head_path) - fprintf(stdout, "%s%c", d->head_path, 0); - } else { - struct strbuf onebuf = STRBUF_INIT; - const char *one; - if (d->head_path) { - one = quote_path(d->head_path, -1, &onebuf, s->prefix); - printf("%s -> ", one); - strbuf_release(&onebuf); - } - one = quote_path(it->string, -1, &onebuf, s->prefix); - printf("%s\n", one); - strbuf_release(&onebuf); - } -} - -static void short_untracked(int null_termination, struct string_list_item *it, - struct wt_status *s) -{ - if (null_termination) { - fprintf(stdout, "?? %s%c", it->string, 0); - } else { - struct strbuf onebuf = STRBUF_INIT; - const char *one; - one = quote_path(it->string, -1, &onebuf, s->prefix); - printf("?? %s\n", one); - strbuf_release(&onebuf); - } -} - -static void short_print(struct wt_status *s, int null_termination) -{ - int i; - for (i = 0; i < s->change.nr; i++) { - struct wt_status_change_data *d; - struct string_list_item *it; - - it = &(s->change.items[i]); - d = it->util; - if (d->stagemask) - short_unmerged(null_termination, it, s); - else - short_status(null_termination, it, s); - } - for (i = 0; i < s->untracked.nr; i++) { - struct string_list_item *it; - - it = &(s->untracked.items[i]); - short_untracked(null_termination, it, s); - } -} - int cmd_status(int argc, const char **argv, const char *prefix) { struct wt_status s; @@ -1061,10 +968,10 @@ int cmd_status(int argc, const char **argv, const char *prefix) case STATUS_FORMAT_SHORT: if (s.relative_paths) s.prefix = prefix; - short_print(&s, null_termination); + wt_shortstatus_print(&s, null_termination); break; case STATUS_FORMAT_PORCELAIN: - short_print(&s, null_termination); + wt_shortstatus_print(&s, null_termination); break; case STATUS_FORMAT_LONG: s.verbose = verbose; diff --git a/wt-status.c b/wt-status.c index 249227c382..8ef824e0d9 100644 --- a/wt-status.c +++ b/wt-status.c @@ -592,3 +592,92 @@ void wt_status_print(struct wt_status *s) printf("nothing to commit (working directory clean)\n"); } } + +static void wt_shortstatus_unmerged(int null_termination, struct string_list_item *it, + struct wt_status *s) +{ + struct wt_status_change_data *d = it->util; + const char *how = "??"; + + switch (d->stagemask) { + case 1: how = "DD"; break; /* both deleted */ + case 2: how = "AU"; break; /* added by us */ + case 3: how = "UD"; break; /* deleted by them */ + case 4: how = "UA"; break; /* added by them */ + case 5: how = "DU"; break; /* deleted by us */ + case 6: how = "AA"; break; /* both added */ + case 7: how = "UU"; break; /* both modified */ + } + printf("%s ", how); + if (null_termination) { + fprintf(stdout, "%s%c", it->string, 0); + } else { + struct strbuf onebuf = STRBUF_INIT; + const char *one; + one = quote_path(it->string, -1, &onebuf, s->prefix); + printf("%s\n", one); + strbuf_release(&onebuf); + } +} + +static void wt_shortstatus_status(int null_termination, struct string_list_item *it, + struct wt_status *s) +{ + struct wt_status_change_data *d = it->util; + + printf("%c%c ", + !d->index_status ? ' ' : d->index_status, + !d->worktree_status ? ' ' : d->worktree_status); + if (null_termination) { + fprintf(stdout, "%s%c", it->string, 0); + if (d->head_path) + fprintf(stdout, "%s%c", d->head_path, 0); + } else { + struct strbuf onebuf = STRBUF_INIT; + const char *one; + if (d->head_path) { + one = quote_path(d->head_path, -1, &onebuf, s->prefix); + printf("%s -> ", one); + strbuf_release(&onebuf); + } + one = quote_path(it->string, -1, &onebuf, s->prefix); + printf("%s\n", one); + strbuf_release(&onebuf); + } +} + +static void wt_shortstatus_untracked(int null_termination, struct string_list_item *it, + struct wt_status *s) +{ + if (null_termination) { + fprintf(stdout, "?? %s%c", it->string, 0); + } else { + struct strbuf onebuf = STRBUF_INIT; + const char *one; + one = quote_path(it->string, -1, &onebuf, s->prefix); + printf("?? %s\n", one); + strbuf_release(&onebuf); + } +} + +void wt_shortstatus_print(struct wt_status *s, int null_termination) +{ + int i; + for (i = 0; i < s->change.nr; i++) { + struct wt_status_change_data *d; + struct string_list_item *it; + + it = &(s->change.items[i]); + d = it->util; + if (d->stagemask) + wt_shortstatus_unmerged(null_termination, it, s); + else + wt_shortstatus_status(null_termination, it, s); + } + for (i = 0; i < s->untracked.nr; i++) { + struct string_list_item *it; + + it = &(s->untracked.items[i]); + wt_shortstatus_untracked(null_termination, it, s); + } +} diff --git a/wt-status.h b/wt-status.h index 09fd9f1091..39c9aef7a5 100644 --- a/wt-status.h +++ b/wt-status.h @@ -56,4 +56,6 @@ void wt_status_prepare(struct wt_status *s); void wt_status_print(struct wt_status *s); void wt_status_collect(struct wt_status *s); +void wt_shortstatus_print(struct wt_status *s, int null_termination); + #endif /* STATUS_H */ -- cgit 1.2.3-korg From 3fe2a894e98566dd91e69982552454cfb381cf24 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Sat, 5 Dec 2009 16:04:38 +0100 Subject: status -s: obey color.status Make the short version of status obey the color.status boolean. We color the status letters only, because they carry the state information and are potentially colored differently, such as for a file with staged changes as well as changes in the worktree against the index. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- builtin-commit.c | 4 ++++ wt-status.c | 21 ++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'wt-status.c') diff --git a/builtin-commit.c b/builtin-commit.c index 8411236fda..07cc76c04a 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -968,6 +968,10 @@ int cmd_status(int argc, const char **argv, const char *prefix) case STATUS_FORMAT_SHORT: if (s.relative_paths) s.prefix = prefix; + if (s.use_color == -1) + s.use_color = git_use_color_default; + if (diff_use_color_default == -1) + diff_use_color_default = git_use_color_default; wt_shortstatus_print(&s, null_termination); break; case STATUS_FORMAT_PORCELAIN: diff --git a/wt-status.c b/wt-status.c index 8ef824e0d9..696c6b0bf1 100644 --- a/wt-status.c +++ b/wt-status.c @@ -608,14 +608,14 @@ static void wt_shortstatus_unmerged(int null_termination, struct string_list_ite case 6: how = "AA"; break; /* both added */ case 7: how = "UU"; break; /* both modified */ } - printf("%s ", how); + color_fprintf(s->fp, color(WT_STATUS_UNMERGED, s), "%s", how); if (null_termination) { - fprintf(stdout, "%s%c", it->string, 0); + fprintf(stdout, " %s%c", it->string, 0); } else { struct strbuf onebuf = STRBUF_INIT; const char *one; one = quote_path(it->string, -1, &onebuf, s->prefix); - printf("%s\n", one); + printf(" %s\n", one); strbuf_release(&onebuf); } } @@ -625,9 +625,15 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item { struct wt_status_change_data *d = it->util; - printf("%c%c ", - !d->index_status ? ' ' : d->index_status, - !d->worktree_status ? ' ' : d->worktree_status); + if (d->index_status) + color_fprintf(s->fp, color(WT_STATUS_UPDATED, s), "%c", d->index_status); + else + putchar(' '); + if (d->worktree_status) + color_fprintf(s->fp, color(WT_STATUS_CHANGED, s), "%c", d->worktree_status); + else + putchar(' '); + putchar(' '); if (null_termination) { fprintf(stdout, "%s%c", it->string, 0); if (d->head_path) @@ -655,7 +661,8 @@ static void wt_shortstatus_untracked(int null_termination, struct string_list_it struct strbuf onebuf = STRBUF_INIT; const char *one; one = quote_path(it->string, -1, &onebuf, s->prefix); - printf("?? %s\n", one); + color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "??"); + printf(" %s\n", one); strbuf_release(&onebuf); } } -- cgit 1.2.3-korg From 4a7cc2fdf39c90e6eff84d30b86490cac2c33705 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 7 Dec 2009 00:17:15 -0500 Subject: status: disable color for porcelain format The porcelain format is identical to the shortstatus format, except that it should not respect any user configuration, including color. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin-commit.c | 4 ++-- wt-status.c | 6 ++++++ wt-status.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'wt-status.c') diff --git a/builtin-commit.c b/builtin-commit.c index 07cc76c04a..ded58984ac 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -382,7 +382,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int wt_shortstatus_print(s, null_termination); break; case STATUS_FORMAT_PORCELAIN: - wt_shortstatus_print(s, null_termination); + wt_porcelain_print(s, null_termination); break; case STATUS_FORMAT_LONG: wt_status_print(s); @@ -975,7 +975,7 @@ int cmd_status(int argc, const char **argv, const char *prefix) wt_shortstatus_print(&s, null_termination); break; case STATUS_FORMAT_PORCELAIN: - wt_shortstatus_print(&s, null_termination); + wt_porcelain_print(&s, null_termination); break; case STATUS_FORMAT_LONG: s.verbose = verbose; diff --git a/wt-status.c b/wt-status.c index 696c6b0bf1..756defea1a 100644 --- a/wt-status.c +++ b/wt-status.c @@ -688,3 +688,9 @@ void wt_shortstatus_print(struct wt_status *s, int null_termination) wt_shortstatus_untracked(null_termination, it, s); } } + +void wt_porcelain_print(struct wt_status *s, int null_termination) +{ + s->use_color = 0; + wt_shortstatus_print(s, null_termination); +} diff --git a/wt-status.h b/wt-status.h index 39c9aef7a5..a4bddcf8db 100644 --- a/wt-status.h +++ b/wt-status.h @@ -57,5 +57,6 @@ void wt_status_print(struct wt_status *s); void wt_status_collect(struct wt_status *s); void wt_shortstatus_print(struct wt_status *s, int null_termination); +void wt_porcelain_print(struct wt_status *s, int null_termination); #endif /* STATUS_H */ -- cgit 1.2.3-korg From 8661768fc9cfdeeaae76693501b82940cfcbedc2 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 7 Dec 2009 00:26:25 -0500 Subject: status: reduce duplicated setup code We have three output formats: short, porcelain, and long. The short and long formats respect user-config, and the porcelain one does not. This led to us repeating config-related setup code for the short and long formats. Since the last commit, color config is explicitly cleared when showing the porcelain format. Let's do the same with relative-path configuration, which enables us to hoist the duplicated code from the switch statement in cmd_status. As a bonus, this fixes "commit --dry-run --porcelain", which was unconditionally setting up that configuration, anyway. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin-commit.c | 19 +++++++------------ wt-status.c | 2 ++ 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'wt-status.c') diff --git a/builtin-commit.c b/builtin-commit.c index ded58984ac..b39295fbf2 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -964,14 +964,15 @@ int cmd_status(int argc, const char **argv, const char *prefix) s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0; wt_status_collect(&s); + if (s.relative_paths) + s.prefix = prefix; + if (s.use_color == -1) + s.use_color = git_use_color_default; + if (diff_use_color_default == -1) + diff_use_color_default = git_use_color_default; + switch (status_format) { case STATUS_FORMAT_SHORT: - if (s.relative_paths) - s.prefix = prefix; - if (s.use_color == -1) - s.use_color = git_use_color_default; - if (diff_use_color_default == -1) - diff_use_color_default = git_use_color_default; wt_shortstatus_print(&s, null_termination); break; case STATUS_FORMAT_PORCELAIN: @@ -979,12 +980,6 @@ int cmd_status(int argc, const char **argv, const char *prefix) break; case STATUS_FORMAT_LONG: s.verbose = verbose; - if (s.relative_paths) - s.prefix = prefix; - if (s.use_color == -1) - s.use_color = git_use_color_default; - if (diff_use_color_default == -1) - diff_use_color_default = git_use_color_default; wt_status_print(&s); break; } diff --git a/wt-status.c b/wt-status.c index 756defea1a..3fdcf97e11 100644 --- a/wt-status.c +++ b/wt-status.c @@ -692,5 +692,7 @@ void wt_shortstatus_print(struct wt_status *s, int null_termination) void wt_porcelain_print(struct wt_status *s, int null_termination) { s->use_color = 0; + s->relative_paths = 0; + s->prefix = NULL; wt_shortstatus_print(s, null_termination); } -- cgit 1.2.3-korg From dd20f8af1ae54773569b78b1b71d1ea663705d2c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 12 Dec 2009 00:18:12 -0800 Subject: commit/status: "git add " is not necessarily how to resolve When the desired resolution is to remove the path, "git rm " is the command the user needs to use. Just like in "Changed but not updated" section, suggest to use "git add/rm" as appropriate. Signed-off-by: Junio C Hamano --- t/t7060-wtstatus.sh | 2 +- wt-status.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'wt-status.c') diff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh index 7b5db8066f..0919ec46f6 100755 --- a/t/t7060-wtstatus.sh +++ b/t/t7060-wtstatus.sh @@ -32,7 +32,7 @@ cat >expect <..." to unstage) -# (use "git add ..." to mark resolution) +# (use "git add/rm ..." as appropriate to mark resolution) # # deleted by us: foo # diff --git a/wt-status.c b/wt-status.c index 3fdcf97e11..56cd8741c0 100644 --- a/wt-status.c +++ b/wt-status.c @@ -52,7 +52,7 @@ static void wt_status_print_unmerged_header(struct wt_status *s) color_fprintf_ln(s->fp, c, "# (use \"git reset %s ...\" to unstage)", s->reference); else color_fprintf_ln(s->fp, c, "# (use \"git rm --cached ...\" to unstage)"); - color_fprintf_ln(s->fp, c, "# (use \"git add ...\" to mark resolution)"); + color_fprintf_ln(s->fp, c, "# (use \"git add/rm ...\" as appropriate to mark resolution)"); color_fprintf_ln(s->fp, c, "#"); } -- cgit 1.2.3-korg From 3c5884536563518ce6cd4dc782b0ebb670bf3b6d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 11 Dec 2009 23:53:41 -0800 Subject: status/commit: do not suggest "reset HEAD " while merging Suggesting "'reset HEAD ' to unstage" is dead wrong if we are about to record a merge commit. For either an unmerged path (i.e. with unresolved conflicts), or an updated path, it would result in discarding what the other branch did. Note that we do not do anything special in a case where we are amending a merge. The user is making an evil merge starting from an already committed merge, and running "reset HEAD " is the right way to get rid of the local edit that has been added to the index. Once "reset --unresolve " becomes available, we might want to suggest it for a merged path that has unresolve information, but until then, just remove the incorrect advice. We might also want to suggest "checkout --conflict " to revert the file in the work tree to the state of failed automerge for an unmerged path, but we never did that, and this commit does not change that. Signed-off-by: Junio C Hamano --- builtin-commit.c | 2 ++ t/t7060-wtstatus.sh | 1 - wt-status.c | 14 ++++++++++---- wt-status.h | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) (limited to 'wt-status.c') diff --git a/builtin-commit.c b/builtin-commit.c index 17dd462173..7218454d1e 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -960,6 +960,7 @@ int cmd_status(int argc, const char **argv, const char *prefix) read_cache(); refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED); s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0; + s.in_merge = in_merge; wt_status_collect(&s); if (s.relative_paths) @@ -1056,6 +1057,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) wt_status_prepare(&s); git_config(git_commit_config, &s); in_merge = file_exists(git_path("MERGE_HEAD")); + s.in_merge = in_merge; if (s.use_color == -1) s.use_color = git_use_color_default; diff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh index 0919ec46f6..fcac472598 100755 --- a/t/t7060-wtstatus.sh +++ b/t/t7060-wtstatus.sh @@ -31,7 +31,6 @@ test_expect_success 'Report new path with conflict' ' cat >expect <..." to unstage) # (use "git add/rm ..." as appropriate to mark resolution) # # deleted by us: foo diff --git a/wt-status.c b/wt-status.c index 56cd8741c0..c4589055bb 100644 --- a/wt-status.c +++ b/wt-status.c @@ -47,8 +47,11 @@ void wt_status_prepare(struct wt_status *s) static void wt_status_print_unmerged_header(struct wt_status *s) { const char *c = color(WT_STATUS_HEADER, s); + color_fprintf_ln(s->fp, c, "# Unmerged paths:"); - if (!s->is_initial) + if (s->in_merge) + ; + else if (!s->is_initial) color_fprintf_ln(s->fp, c, "# (use \"git reset %s ...\" to unstage)", s->reference); else color_fprintf_ln(s->fp, c, "# (use \"git rm --cached ...\" to unstage)"); @@ -59,12 +62,14 @@ static void wt_status_print_unmerged_header(struct wt_status *s) static void wt_status_print_cached_header(struct wt_status *s) { const char *c = color(WT_STATUS_HEADER, s); + color_fprintf_ln(s->fp, c, "# Changes to be committed:"); - if (!s->is_initial) { + if (s->in_merge) + ; /* NEEDSWORK: use "git reset --unresolve"??? */ + else if (!s->is_initial) color_fprintf_ln(s->fp, c, "# (use \"git reset %s ...\" to unstage)", s->reference); - } else { + else color_fprintf_ln(s->fp, c, "# (use \"git rm --cached ...\" to unstage)"); - } color_fprintf_ln(s->fp, c, "#"); } @@ -72,6 +77,7 @@ static void wt_status_print_dirty_header(struct wt_status *s, int has_deleted) { const char *c = color(WT_STATUS_HEADER, s); + color_fprintf_ln(s->fp, c, "# Changed but not updated:"); if (!has_deleted) color_fprintf_ln(s->fp, c, "# (use \"git add ...\" to update what will be committed)"); diff --git a/wt-status.h b/wt-status.h index a4bddcf8db..c60f40a34a 100644 --- a/wt-status.h +++ b/wt-status.h @@ -34,6 +34,7 @@ struct wt_status { const char **pathspec; int verbose; int amend; + int in_merge; int nowarn; int use_color; int relative_paths; -- cgit 1.2.3-korg