summaryrefslogtreecommitdiff
path: root/builtin-commit.c
diff options
context:
space:
mode:
authorMichael J Gruber <git@drmicha.warpmail.net>2009-12-05 16:04:37 +0100
committerJunio C Hamano <gitster@pobox.com>2009-12-05 09:27:23 -0800
commit84dbe7b867cfaaa929ed1941f930d564514ae714 (patch)
tree7a00257519fb5420080680a2d8372f4c7143dccf /builtin-commit.c
parent14ed05ddd6a8cdd3cb792e2c991207d1640943d1 (diff)
downloadgit-84dbe7b867cfaaa929ed1941f930d564514ae714.tar.gz
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 <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-commit.c')
-rw-r--r--builtin-commit.c101
1 files changed, 4 insertions, 97 deletions
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;