{"thread":{"id":"20515","subject":"[PATCH v3 1/8] commit: --dry-run","startedAt":"2009-08-10T08:54:17Z","lastAt":"2009-08-10T09:12:50Z","messageCount":11,"participants":["Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":3,"patchTotal":8},"messages":[{"id":"120120","messageId":"1249894465-11018-1-git-send-email-gitster@pobox.com","threadId":"20515","inReplyTo":null,"subject":"[PATCH v3 0/8] shortstatus updates","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-10T08:54:17Z","receivedAt":"2009-08-10T08:54:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Another round of \"git status won't be a preview of git commit someday\".\nThis builds on the part that are already in 'pu', and is queued in 'pu'.\n\nJunio C Hamano (8):\n  commit: --dry-run\n  wt-status: move many global settings to wt_status structure\n  wt-status: move wt_status_colors[] into wt_status structure\n  Make git_status_config() file scope static to builtin-commit.c\n  wt-status: collect untracked files in a separate \"collect\" phase\n  git stat: the beginning\n  git stat: pathspec limits, unlike traditional \"git status\"\n  git stat -s: short status output\n\n Documentation/git-commit.txt |    7 +-\n Makefile                     |    1 +\n builtin-commit.c             |  312 +++++++++++++++++++++++++++++++++++-------\n builtin.h                    |    1 +\n git.c                        |    1 +\n wt-status.c                  |  206 ++++++++++++----------------\n wt-status.h                  |   17 ++-\n 7 files changed, 367 insertions(+), 178 deletions(-)\n"},{"id":"120119","messageId":"1249894465-11018-2-git-send-email-gitster@pobox.com","threadId":"20515","inReplyTo":"1249894465-11018-1-git-send-email-gitster@pobox.com","subject":"[PATCH v3 1/8] commit: --dry-run","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-10T08:54:18Z","receivedAt":"2009-08-10T08:54:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This teaches --dry-run option to \"git commit\".\n\nIt is the same as \"git status\", but in the longer term we would want to\nchange the semantics of \"git status\" not to be the preview of commit, and\nthis is the first step for doing so.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/git-commit.txt |    7 ++++++-\n builtin-commit.c             |   29 ++++++++++++++++-------------\n 2 files changed, 22 insertions(+), 14 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex b5d81be..d01ff5a 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -8,7 +8,7 @@ git-commit - Record changes to the repository\n SYNOPSIS\n --------\n [verse]\n-'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend]\n+'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]\n \t   [(-c | -C) <commit>] [-F <file> | -m <msg>]\n \t   [--allow-empty] [--no-verify] [-e] [--author=<author>]\n \t   [--cleanup=<mode>] [--] [[-i | -o ]<file>...]\n@@ -198,6 +198,11 @@ specified.\n --quiet::\n \tSuppress commit summary message.\n \n+--dry-run::\n+\tDo not create a commit, but show a list of paths that are\n+\tto be committed, paths with local changes that will be left\n+\tuncommitted and paths that are untracked.\n+\n \\--::\n \tDo not interpret any more arguments as options.\n \ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 6d12c2e..3a7e35d 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -51,7 +51,7 @@ static const char *template_file;\n static char *edit_message, *use_message;\n static char *author_name, *author_email, *author_date;\n static int all, edit_flag, also, interactive, only, amend, signoff;\n-static int quiet, verbose, no_verify, allow_empty;\n+static int quiet, verbose, no_verify, allow_empty, dry_run;\n static char *untracked_files_arg;\n /*\n  * The default commit message cleanup mode will remove the lines\n@@ -103,6 +103,7 @@ static struct option builtin_commit_options[] = {\n \tOPT_BOOLEAN(0, \"interactive\", &interactive, \"interactively add files\"),\n \tOPT_BOOLEAN('o', \"only\", &only, \"commit only specified files\"),\n \tOPT_BOOLEAN('n', \"no-verify\", &no_verify, \"bypass pre-commit hook\"),\n+\tOPT_BOOLEAN(0, \"dry-run\", &dry_run, \"show what would be committed\"),\n \tOPT_BOOLEAN(0, \"amend\", &amend, \"amend previous commit\"),\n \t{ OPTION_STRING, 'u', \"untracked-files\", &untracked_files_arg, \"mode\", \"show untracked files, optional modes: all, normal, no. (Default: all)\", PARSE_OPT_OPTARG, NULL, (intptr_t)\"all\" },\n \tOPT_BOOLEAN(0, \"allow-empty\", &allow_empty, \"ok to record an empty change\"),\n@@ -813,28 +814,28 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \treturn argc;\n }\n \n-int cmd_status(int argc, const char **argv, const char *prefix)\n+static int dry_run_commit(int argc, const char **argv, const char *prefix)\n {\n-\tconst char *index_file;\n \tint commitable;\n+\tconst char *index_file;\n \n-\tgit_config(git_status_config, NULL);\n+\tindex_file = prepare_index(argc, argv, prefix, 1);\n+\tcommitable = run_status(stdout, index_file, prefix, 0);\n+\trollback_index_files();\n \n+\treturn commitable ? 0 : 1;\n+}\n+\n+int cmd_status(int argc, const char **argv, const char *prefix)\n+{\n+\tgit_config(git_status_config, NULL);\n \tif (wt_status_use_color == -1)\n \t\twt_status_use_color = git_use_color_default;\n-\n \tif (diff_use_color_default == -1)\n \t\tdiff_use_color_default = git_use_color_default;\n \n \targc = parse_and_validate_options(argc, argv, builtin_status_usage, prefix);\n-\n-\tindex_file = prepare_index(argc, argv, prefix, 1);\n-\n-\tcommitable = run_status(stdout, index_file, prefix, 0);\n-\n-\trollback_index_files();\n-\n-\treturn commitable ? 0 : 1;\n+\treturn dry_run_commit(argc, argv, prefix);\n }\n \n static void print_summary(const char *prefix, const unsigned char *sha1)\n@@ -909,6 +910,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\twt_status_use_color = git_use_color_default;\n \n \targc = parse_and_validate_options(argc, argv, builtin_commit_usage, prefix);\n+\tif (dry_run)\n+\t\treturn dry_run_commit(argc, argv, prefix);\n \n \tindex_file = prepare_index(argc, argv, prefix, 0);\n \n-- \n1.6.4.173.g72959\n"},{"id":"120121","messageId":"1249894465-11018-3-git-send-email-gitster@pobox.com","threadId":"20515","inReplyTo":"1249894465-11018-2-git-send-email-gitster@pobox.com","subject":"[PATCH v3 2/8] wt-status: move many global settings to wt_status structure","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-10T08:54:19Z","receivedAt":"2009-08-10T08:54:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Turn four global variables (wt_status_use_color, show_tracked_files,\nwt_status_relative_paths, and wt_status_submodule_summary) into fields of\nwt_status structure.  Get rid of \"untracked\" field that was used only to\nkeep track of otherwise available information redundantly.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin-commit.c |   87 +++++++++++++++++++++++++++++------------------------\n wt-status.c      |   81 +++++++++++++++++++++++++-------------------------\n wt-status.h      |    9 +++--\n 3 files changed, 93 insertions(+), 84 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 3a7e35d..ca36ba2 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -343,27 +343,24 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int\n \treturn false_lock.filename;\n }\n \n-static int run_status(FILE *fp, const char *index_file, const char *prefix, int nowarn)\n+static int run_status(FILE *fp, const char *index_file, const char *prefix, int nowarn,\n+\t\t      struct wt_status *s)\n {\n-\tstruct wt_status s;\n-\n-\twt_status_prepare(&s);\n-\tif (wt_status_relative_paths)\n-\t\ts.prefix = prefix;\n+\tif (s->wt_status_relative_paths)\n+\t\ts->prefix = prefix;\n \n \tif (amend) {\n-\t\ts.amend = 1;\n-\t\ts.reference = \"HEAD^1\";\n+\t\ts->amend = 1;\n+\t\ts->reference = \"HEAD^1\";\n \t}\n-\ts.verbose = verbose;\n-\ts.untracked = (show_untracked_files == SHOW_ALL_UNTRACKED_FILES);\n-\ts.index_file = index_file;\n-\ts.fp = fp;\n-\ts.nowarn = nowarn;\n+\ts->verbose = verbose;\n+\ts->index_file = index_file;\n+\ts->fp = fp;\n+\ts->nowarn = nowarn;\n \n-\twt_status_print(&s);\n+\twt_status_print(s);\n \n-\treturn s.commitable;\n+\treturn s->commitable;\n }\n \n static int is_a_merge(const unsigned char *sha1)\n@@ -417,7 +414,8 @@ static void determine_author_info(void)\n \tauthor_date = date;\n }\n \n-static int prepare_to_commit(const char *index_file, const char *prefix)\n+static int prepare_to_commit(const char *index_file, const char *prefix,\n+\t\t\t     struct wt_status *s)\n {\n \tstruct stat statbuf;\n \tint commitable, saved_color_setting;\n@@ -559,10 +557,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix)\n \t\tif (ident_shown)\n \t\t\tfprintf(fp, \"#\\n\");\n \n-\t\tsaved_color_setting = wt_status_use_color;\n-\t\twt_status_use_color = 0;\n-\t\tcommitable = run_status(fp, index_file, prefix, 1);\n-\t\twt_status_use_color = saved_color_setting;\n+\t\tsaved_color_setting = s->wt_status_use_color;\n+\t\ts->wt_status_use_color = 0;\n+\t\tcommitable = run_status(fp, index_file, prefix, 1, s);\n+\t\ts->wt_status_use_color = saved_color_setting;\n \t} else {\n \t\tunsigned char sha1[20];\n \t\tconst char *parent = \"HEAD\";\n@@ -583,7 +581,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)\n \n \tif (!commitable && !in_merge && !allow_empty &&\n \t    !(amend && is_a_merge(head_sha1))) {\n-\t\trun_status(stdout, index_file, prefix, 0);\n+\t\trun_status(stdout, index_file, prefix, 0, s);\n \t\treturn 0;\n \t}\n \n@@ -695,7 +693,8 @@ static const char *find_author_by_nickname(const char *name)\n \n static int parse_and_validate_options(int argc, const char *argv[],\n \t\t\t\t      const char * const usage[],\n-\t\t\t\t      const char *prefix)\n+\t\t\t\t      const char *prefix,\n+\t\t\t\t      struct wt_status *s)\n {\n \tint f = 0;\n \n@@ -798,11 +797,11 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \tif (!untracked_files_arg)\n \t\t; /* default already initialized */\n \telse if (!strcmp(untracked_files_arg, \"no\"))\n-\t\tshow_untracked_files = SHOW_NO_UNTRACKED_FILES;\n+\t\ts->show_untracked_files = SHOW_NO_UNTRACKED_FILES;\n \telse if (!strcmp(untracked_files_arg, \"normal\"))\n-\t\tshow_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n+\t\ts->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n \telse if (!strcmp(untracked_files_arg, \"all\"))\n-\t\tshow_untracked_files = SHOW_ALL_UNTRACKED_FILES;\n+\t\ts->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;\n \telse\n \t\tdie(\"Invalid untracked files mode '%s'\", untracked_files_arg);\n \n@@ -814,13 +813,14 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \treturn argc;\n }\n \n-static int dry_run_commit(int argc, const char **argv, const char *prefix)\n+static int dry_run_commit(int argc, const char **argv, const char *prefix,\n+\t\t\t  struct wt_status *s)\n {\n \tint commitable;\n \tconst char *index_file;\n \n \tindex_file = prepare_index(argc, argv, prefix, 1);\n-\tcommitable = run_status(stdout, index_file, prefix, 0);\n+\tcommitable = run_status(stdout, index_file, prefix, 0, s);\n \trollback_index_files();\n \n \treturn commitable ? 0 : 1;\n@@ -828,14 +828,18 @@ static int dry_run_commit(int argc, const char **argv, const char *prefix)\n \n int cmd_status(int argc, const char **argv, const char *prefix)\n {\n-\tgit_config(git_status_config, NULL);\n-\tif (wt_status_use_color == -1)\n-\t\twt_status_use_color = git_use_color_default;\n+\tstruct wt_status s;\n+\n+\twt_status_prepare(&s);\n+\tgit_config(git_status_config, &s);\n+\tif (s.wt_status_use_color == -1)\n+\t\ts.wt_status_use_color = git_use_color_default;\n \tif (diff_use_color_default == -1)\n \t\tdiff_use_color_default = git_use_color_default;\n \n-\targc = parse_and_validate_options(argc, argv, builtin_status_usage, prefix);\n-\treturn dry_run_commit(argc, argv, prefix);\n+\targc = parse_and_validate_options(argc, argv, builtin_status_usage,\n+\t\t\t\t\t  prefix, &s);\n+\treturn dry_run_commit(argc, argv, prefix, &s);\n }\n \n static void print_summary(const char *prefix, const unsigned char *sha1)\n@@ -887,10 +891,12 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \n static int git_commit_config(const char *k, const char *v, void *cb)\n {\n+\tstruct wt_status *s = cb;\n+\n \tif (!strcmp(k, \"commit.template\"))\n \t\treturn git_config_string(&template_file, k, v);\n \n-\treturn git_status_config(k, v, cb);\n+\treturn git_status_config(k, v, s);\n }\n \n int cmd_commit(int argc, const char **argv, const char *prefix)\n@@ -903,21 +909,24 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \tstruct commit_list *parents = NULL, **pptr = &parents;\n \tstruct stat statbuf;\n \tint allow_fast_forward = 1;\n+\tstruct wt_status s;\n \n-\tgit_config(git_commit_config, NULL);\n+\twt_status_prepare(&s);\n+\tgit_config(git_commit_config, &s);\n \n-\tif (wt_status_use_color == -1)\n-\t\twt_status_use_color = git_use_color_default;\n+\tif (s.wt_status_use_color == -1)\n+\t\ts.wt_status_use_color = git_use_color_default;\n \n-\targc = parse_and_validate_options(argc, argv, builtin_commit_usage, prefix);\n+\targc = parse_and_validate_options(argc, argv, builtin_commit_usage,\n+\t\t\t\t\t  prefix, &s);\n \tif (dry_run)\n-\t\treturn dry_run_commit(argc, argv, prefix);\n+\t\treturn dry_run_commit(argc, argv, prefix, &s);\n \n \tindex_file = prepare_index(argc, argv, prefix, 0);\n \n \t/* Set up everything for writing the commit object.  This includes\n \t   running hooks, writing the trees, and interacting with the user.  */\n-\tif (!prepare_to_commit(index_file, prefix)) {\n+\tif (!prepare_to_commit(index_file, prefix, &s)) {\n \t\trollback_index_files();\n \t\treturn 1;\n \t}\ndiff --git a/wt-status.c b/wt-status.c\nindex 97fedfa..c84a18a 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -11,9 +11,6 @@\n #include \"run-command.h\"\n #include \"remote.h\"\n \n-int wt_status_relative_paths = 1;\n-int wt_status_use_color = -1;\n-static int wt_status_submodule_summary;\n static char wt_status_colors[][COLOR_MAXLEN] = {\n \tGIT_COLOR_NORMAL, /* WT_STATUS_HEADER */\n \tGIT_COLOR_GREEN,  /* WT_STATUS_UPDATED */\n@@ -23,8 +20,6 @@ static char wt_status_colors[][COLOR_MAXLEN] = {\n \tGIT_COLOR_RED,    /* WT_STATUS_UNMERGED */\n };\n \n-enum untracked_status_type show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n-\n static int parse_status_slot(const char *var, int offset)\n {\n \tif (!strcasecmp(var+offset, \"header\"))\n@@ -43,9 +38,9 @@ static int parse_status_slot(const char *var, int offset)\n \tdie(\"bad config variable '%s'\", var);\n }\n \n-static const char *color(int slot)\n+static const char *color(int slot, struct wt_status *s)\n {\n-\treturn wt_status_use_color > 0 ? wt_status_colors[slot] : \"\";\n+\treturn s->wt_status_use_color > 0 ? wt_status_colors[slot] : \"\";\n }\n \n void wt_status_prepare(struct wt_status *s)\n@@ -54,6 +49,9 @@ void wt_status_prepare(struct wt_status *s)\n \tconst char *head;\n \n \tmemset(s, 0, sizeof(*s));\n+\ts->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n+\ts->wt_status_use_color = -1;\n+\ts->wt_status_relative_paths = 1;\n \thead = resolve_ref(\"HEAD\", sha1, 0, NULL);\n \ts->branch = head ? xstrdup(head) : NULL;\n \ts->reference = \"HEAD\";\n@@ -64,7 +62,7 @@ void wt_status_prepare(struct wt_status *s)\n \n static void wt_status_print_unmerged_header(struct wt_status *s)\n {\n-\tconst char *c = color(WT_STATUS_HEADER);\n+\tconst char *c = color(WT_STATUS_HEADER, s);\n \tcolor_fprintf_ln(s->fp, c, \"# Unmerged paths:\");\n \tif (!s->is_initial)\n \t\tcolor_fprintf_ln(s->fp, c, \"#   (use \\\"git reset %s <file>...\\\" to unstage)\", s->reference);\n@@ -76,7 +74,7 @@ static void wt_status_print_unmerged_header(struct wt_status *s)\n \n static void wt_status_print_cached_header(struct wt_status *s)\n {\n-\tconst char *c = color(WT_STATUS_HEADER);\n+\tconst char *c = color(WT_STATUS_HEADER, s);\n \tcolor_fprintf_ln(s->fp, c, \"# Changes to be committed:\");\n \tif (!s->is_initial) {\n \t\tcolor_fprintf_ln(s->fp, c, \"#   (use \\\"git reset %s <file>...\\\" to unstage)\", s->reference);\n@@ -89,7 +87,7 @@ static void wt_status_print_cached_header(struct wt_status *s)\n static void wt_status_print_dirty_header(struct wt_status *s,\n \t\t\t\t\t int has_deleted)\n {\n-\tconst char *c = color(WT_STATUS_HEADER);\n+\tconst char *c = color(WT_STATUS_HEADER, s);\n \tcolor_fprintf_ln(s->fp, c, \"# Changed but not updated:\");\n \tif (!has_deleted)\n \t\tcolor_fprintf_ln(s->fp, c, \"#   (use \\\"git add <file>...\\\" to update what will be committed)\");\n@@ -101,7 +99,7 @@ static void wt_status_print_dirty_header(struct wt_status *s,\n \n static void wt_status_print_untracked_header(struct wt_status *s)\n {\n-\tconst char *c = color(WT_STATUS_HEADER);\n+\tconst char *c = color(WT_STATUS_HEADER, s);\n \tcolor_fprintf_ln(s->fp, c, \"# Untracked files:\");\n \tcolor_fprintf_ln(s->fp, c, \"#   (use \\\"git add <file>...\\\" to include in what will be committed)\");\n \tcolor_fprintf_ln(s->fp, c, \"#\");\n@@ -109,7 +107,7 @@ static void wt_status_print_untracked_header(struct wt_status *s)\n \n static void wt_status_print_trailer(struct wt_status *s)\n {\n-\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER), \"#\");\n+\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), \"#\");\n }\n \n #define quote_path quote_path_relative\n@@ -117,13 +115,13 @@ static void wt_status_print_trailer(struct wt_status *s)\n static void wt_status_print_unmerged_data(struct wt_status *s,\n \t\t\t\t\t  struct string_list_item *it)\n {\n-\tconst char *c = color(WT_STATUS_UNMERGED);\n+\tconst char *c = color(WT_STATUS_UNMERGED, s);\n \tstruct wt_status_change_data *d = it->util;\n \tstruct strbuf onebuf = STRBUF_INIT;\n \tconst char *one, *how = \"bug\";\n \n \tone = quote_path(it->string, -1, &onebuf, s->prefix);\n-\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER), \"#\\t\");\n+\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER, s), \"#\\t\");\n \tswitch (d->stagemask) {\n \tcase 1: how = \"both deleted:\"; break;\n \tcase 2: how = \"added by us:\"; break;\n@@ -142,7 +140,7 @@ static void wt_status_print_change_data(struct wt_status *s,\n \t\t\t\t\tstruct string_list_item *it)\n {\n \tstruct wt_status_change_data *d = it->util;\n-\tconst char *c = color(change_type);\n+\tconst char *c = color(change_type, s);\n \tint status = status;\n \tchar *one_name;\n \tchar *two_name;\n@@ -164,7 +162,7 @@ static void wt_status_print_change_data(struct wt_status *s,\n \tone = quote_path(one_name, -1, &onebuf, s->prefix);\n \ttwo = quote_path(two_name, -1, &twobuf, s->prefix);\n \n-\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER), \"#\\t\");\n+\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER, s), \"#\\t\");\n \tswitch (status) {\n \tcase DIFF_STATUS_ADDED:\n \t\tcolor_fprintf(s->fp, c, \"new file:   %s\", one);\n@@ -450,7 +448,7 @@ static void wt_status_print_submodule_summary(struct wt_status *s)\n \t\tNULL\n \t};\n \n-\tsprintf(summary_limit, \"%d\", wt_status_submodule_summary);\n+\tsprintf(summary_limit, \"%d\", s->wt_status_submodule_summary);\n \tsnprintf(index, sizeof(index), \"GIT_INDEX_FILE=%s\", s->index_file);\n \n \tmemset(&sm_summary, 0, sizeof(sm_summary));\n@@ -471,8 +469,7 @@ static void wt_status_print_untracked(struct wt_status *s)\n \tstruct strbuf buf = STRBUF_INIT;\n \n \tmemset(&dir, 0, sizeof(dir));\n-\n-\tif (!s->untracked)\n+\tif (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES)\n \t\tdir.flags |=\n \t\t\tDIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;\n \tsetup_standard_excludes(&dir);\n@@ -487,8 +484,8 @@ static void wt_status_print_untracked(struct wt_status *s)\n \t\t\twt_status_print_untracked_header(s);\n \t\t\tshown_header = 1;\n \t\t}\n-\t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER), \"#\\t\");\n-\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED), \"%s\",\n+\t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER, s), \"#\\t\");\n+\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED, s), \"%s\",\n \t\t\t\tquote_path(ent->name, ent->len,\n \t\t\t\t\t&buf, s->prefix));\n \t}\n@@ -532,15 +529,15 @@ static void wt_status_print_tracking(struct wt_status *s)\n \t\treturn;\n \n \tfor (cp = sb.buf; (ep = strchr(cp, '\\n')) != NULL; cp = ep + 1)\n-\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER),\n+\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s),\n \t\t\t\t \"# %.*s\", (int)(ep - cp), cp);\n-\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER), \"#\");\n+\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), \"#\");\n }\n \n void wt_status_print(struct wt_status *s)\n {\n \tunsigned char sha1[20];\n-\tconst char *branch_color = color(WT_STATUS_HEADER);\n+\tconst char *branch_color = color(WT_STATUS_HEADER, s);\n \n \ts->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;\n \tif (s->branch) {\n@@ -550,10 +547,10 @@ void wt_status_print(struct wt_status *s)\n \t\t\tbranch_name += 11;\n \t\telse if (!strcmp(branch_name, \"HEAD\")) {\n \t\t\tbranch_name = \"\";\n-\t\t\tbranch_color = color(WT_STATUS_NOBRANCH);\n+\t\t\tbranch_color = color(WT_STATUS_NOBRANCH, s);\n \t\t\ton_what = \"Not currently on any branch.\";\n \t\t}\n-\t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER), \"# \");\n+\t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER, s), \"# \");\n \t\tcolor_fprintf_ln(s->fp, branch_color, \"%s%s\", on_what, branch_name);\n \t\tif (!s->is_initial)\n \t\t\twt_status_print_tracking(s);\n@@ -562,17 +559,17 @@ void wt_status_print(struct wt_status *s)\n \twt_status_collect_changes(s);\n \n \tif (s->is_initial) {\n-\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER), \"#\");\n-\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER), \"# Initial commit\");\n-\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER), \"#\");\n+\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), \"#\");\n+\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), \"# Initial commit\");\n+\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), \"#\");\n \t}\n \n \twt_status_print_unmerged(s);\n \twt_status_print_updated(s);\n \twt_status_print_changed(s);\n-\tif (wt_status_submodule_summary)\n+\tif (s->wt_status_submodule_summary)\n \t\twt_status_print_submodule_summary(s);\n-\tif (show_untracked_files)\n+\tif (s->show_untracked_files)\n \t\twt_status_print_untracked(s);\n \telse if (s->commitable)\n \t\t fprintf(s->fp, \"# Untracked files not listed (use -u option to show untracked files)\\n\");\n@@ -590,7 +587,7 @@ void wt_status_print(struct wt_status *s)\n \t\t\tprintf(\"nothing added to commit but untracked files present (use \\\"git add\\\" to track)\\n\");\n \t\telse if (s->is_initial)\n \t\t\tprintf(\"nothing to commit (create/copy files and use \\\"git add\\\" to track)\\n\");\n-\t\telse if (!show_untracked_files)\n+\t\telse if (!s->show_untracked_files)\n \t\t\tprintf(\"nothing to commit (use -u to show untracked files)\\n\");\n \t\telse\n \t\t\tprintf(\"nothing to commit (working directory clean)\\n\");\n@@ -599,15 +596,17 @@ void wt_status_print(struct wt_status *s)\n \n int git_status_config(const char *k, const char *v, void *cb)\n {\n+\tstruct wt_status *s = cb;\n+\n \tif (!strcmp(k, \"status.submodulesummary\")) {\n \t\tint is_bool;\n-\t\twt_status_submodule_summary = git_config_bool_or_int(k, v, &is_bool);\n-\t\tif (is_bool && wt_status_submodule_summary)\n-\t\t\twt_status_submodule_summary = -1;\n+\t\ts->wt_status_submodule_summary = git_config_bool_or_int(k, v, &is_bool);\n+\t\tif (is_bool && s->wt_status_submodule_summary)\n+\t\t\ts->wt_status_submodule_summary = -1;\n \t\treturn 0;\n \t}\n \tif (!strcmp(k, \"status.color\") || !strcmp(k, \"color.status\")) {\n-\t\twt_status_use_color = git_config_colorbool(k, v, -1);\n+\t\ts->wt_status_use_color = git_config_colorbool(k, v, -1);\n \t\treturn 0;\n \t}\n \tif (!prefixcmp(k, \"status.color.\") || !prefixcmp(k, \"color.status.\")) {\n@@ -618,21 +617,21 @@ int git_status_config(const char *k, const char *v, void *cb)\n \t\treturn 0;\n \t}\n \tif (!strcmp(k, \"status.relativepaths\")) {\n-\t\twt_status_relative_paths = git_config_bool(k, v);\n+\t\ts->wt_status_relative_paths = git_config_bool(k, v);\n \t\treturn 0;\n \t}\n \tif (!strcmp(k, \"status.showuntrackedfiles\")) {\n \t\tif (!v)\n \t\t\treturn config_error_nonbool(k);\n \t\telse if (!strcmp(v, \"no\"))\n-\t\t\tshow_untracked_files = SHOW_NO_UNTRACKED_FILES;\n+\t\t\ts->show_untracked_files = SHOW_NO_UNTRACKED_FILES;\n \t\telse if (!strcmp(v, \"normal\"))\n-\t\t\tshow_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n+\t\t\ts->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n \t\telse if (!strcmp(v, \"all\"))\n-\t\t\tshow_untracked_files = SHOW_ALL_UNTRACKED_FILES;\n+\t\t\ts->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;\n \t\telse\n \t\t\treturn error(\"Invalid untracked files mode '%s'\", v);\n \t\treturn 0;\n \t}\n-\treturn git_diff_ui_config(k, v, cb);\n+\treturn git_diff_ui_config(k, v, NULL);\n }\ndiff --git a/wt-status.h b/wt-status.h\nindex f80142f..3d7fe30 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -18,7 +18,6 @@ enum untracked_status_type {\n \tSHOW_NORMAL_UNTRACKED_FILES,\n \tSHOW_ALL_UNTRACKED_FILES\n };\n-extern enum untracked_status_type show_untracked_files;\n \n struct wt_status_change_data {\n \tint worktree_status;\n@@ -33,8 +32,12 @@ struct wt_status {\n \tconst char *reference;\n \tint verbose;\n \tint amend;\n-\tint untracked;\n \tint nowarn;\n+\tint wt_status_use_color;\n+\tint wt_status_relative_paths;\n+\tint wt_status_submodule_summary;\n+\tenum untracked_status_type show_untracked_files;\n+\n \t/* These are computed during processing of the individual sections */\n \tint commitable;\n \tint workdir_dirty;\n@@ -46,8 +49,6 @@ struct wt_status {\n };\n \n int git_status_config(const char *var, const char *value, void *cb);\n-extern int wt_status_use_color;\n-extern int wt_status_relative_paths;\n void wt_status_prepare(struct wt_status *s);\n void wt_status_print(struct wt_status *s);\n void wt_status_collect_changes(struct wt_status *s);\n-- \n1.6.4.173.g72959\n"},{"id":"120124","messageId":"1249894465-11018-4-git-send-email-gitster@pobox.com","threadId":"20515","inReplyTo":"1249894465-11018-3-git-send-email-gitster@pobox.com","subject":"[PATCH v3 3/8] wt-status: move wt_status_colors[] into wt_status structure","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-10T08:54:20Z","receivedAt":"2009-08-10T08:54:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The benefit of this one alone is somewhat iffy, but for completeness this\nmoves the wt_status_colors[] color palette to the wt_status structure to\ncomplete what the previous commit started.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n wt-status.c |    9 +++++----\n wt-status.h |    2 ++\n 2 files changed, 7 insertions(+), 4 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex c84a18a..a2a7257 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1,6 +1,5 @@\n #include \"cache.h\"\n #include \"wt-status.h\"\n-#include \"color.h\"\n #include \"object.h\"\n #include \"dir.h\"\n #include \"commit.h\"\n@@ -11,7 +10,7 @@\n #include \"run-command.h\"\n #include \"remote.h\"\n \n-static char wt_status_colors[][COLOR_MAXLEN] = {\n+static char default_wt_status_colors[][COLOR_MAXLEN] = {\n \tGIT_COLOR_NORMAL, /* WT_STATUS_HEADER */\n \tGIT_COLOR_GREEN,  /* WT_STATUS_UPDATED */\n \tGIT_COLOR_RED,    /* WT_STATUS_CHANGED */\n@@ -40,7 +39,7 @@ static int parse_status_slot(const char *var, int offset)\n \n static const char *color(int slot, struct wt_status *s)\n {\n-\treturn s->wt_status_use_color > 0 ? wt_status_colors[slot] : \"\";\n+\treturn s->wt_status_use_color > 0 ? s->wt_status_colors[slot] : \"\";\n }\n \n void wt_status_prepare(struct wt_status *s)\n@@ -49,6 +48,8 @@ void wt_status_prepare(struct wt_status *s)\n \tconst char *head;\n \n \tmemset(s, 0, sizeof(*s));\n+\tmemcpy(s->wt_status_colors, default_wt_status_colors,\n+\t       sizeof(default_wt_status_colors));\n \ts->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n \ts->wt_status_use_color = -1;\n \ts->wt_status_relative_paths = 1;\n@@ -613,7 +614,7 @@ int git_status_config(const char *k, const char *v, void *cb)\n \t\tint slot = parse_status_slot(k, 13);\n \t\tif (!v)\n \t\t\treturn config_error_nonbool(k);\n-\t\tcolor_parse(v, k, wt_status_colors[slot]);\n+\t\tcolor_parse(v, k, s->wt_status_colors[slot]);\n \t\treturn 0;\n \t}\n \tif (!strcmp(k, \"status.relativepaths\")) {\ndiff --git a/wt-status.h b/wt-status.h\nindex 3d7fe30..f22c3c1 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -3,6 +3,7 @@\n \n #include <stdio.h>\n #include \"string-list.h\"\n+#include \"color.h\"\n \n enum color_wt_status {\n \tWT_STATUS_HEADER,\n@@ -37,6 +38,7 @@ struct wt_status {\n \tint wt_status_relative_paths;\n \tint wt_status_submodule_summary;\n \tenum untracked_status_type show_untracked_files;\n+\tchar wt_status_colors[6][COLOR_MAXLEN];\n \n \t/* These are computed during processing of the individual sections */\n \tint commitable;\n-- \n1.6.4.173.g72959\n"},{"id":"120125","messageId":"1249894465-11018-5-git-send-email-gitster@pobox.com","threadId":"20515","inReplyTo":"1249894465-11018-4-git-send-email-gitster@pobox.com","subject":"[PATCH v3 4/8] Make git_status_config() file scope static to builtin-commit.c","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-10T08:54:21Z","receivedAt":"2009-08-10T08:54:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Signed-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin-commit.c |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++\n wt-status.c      |   60 ------------------------------------------------------\n wt-status.h      |    1 -\n 3 files changed, 60 insertions(+), 61 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex ca36ba2..601118f 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -826,6 +826,66 @@ static int dry_run_commit(int argc, const char **argv, const char *prefix,\n \treturn commitable ? 0 : 1;\n }\n \n+static int parse_status_slot(const char *var, int offset)\n+{\n+\tif (!strcasecmp(var+offset, \"header\"))\n+\t\treturn WT_STATUS_HEADER;\n+\tif (!strcasecmp(var+offset, \"updated\")\n+\t\t|| !strcasecmp(var+offset, \"added\"))\n+\t\treturn WT_STATUS_UPDATED;\n+\tif (!strcasecmp(var+offset, \"changed\"))\n+\t\treturn WT_STATUS_CHANGED;\n+\tif (!strcasecmp(var+offset, \"untracked\"))\n+\t\treturn WT_STATUS_UNTRACKED;\n+\tif (!strcasecmp(var+offset, \"nobranch\"))\n+\t\treturn WT_STATUS_NOBRANCH;\n+\tif (!strcasecmp(var+offset, \"unmerged\"))\n+\t\treturn WT_STATUS_UNMERGED;\n+\tdie(\"bad config variable '%s'\", var);\n+}\n+\n+static int git_status_config(const char *k, const char *v, void *cb)\n+{\n+\tstruct wt_status *s = cb;\n+\n+\tif (!strcmp(k, \"status.submodulesummary\")) {\n+\t\tint is_bool;\n+\t\ts->wt_status_submodule_summary = git_config_bool_or_int(k, v, &is_bool);\n+\t\tif (is_bool && s->wt_status_submodule_summary)\n+\t\t\ts->wt_status_submodule_summary = -1;\n+\t\treturn 0;\n+\t}\n+\tif (!strcmp(k, \"status.color\") || !strcmp(k, \"color.status\")) {\n+\t\ts->wt_status_use_color = git_config_colorbool(k, v, -1);\n+\t\treturn 0;\n+\t}\n+\tif (!prefixcmp(k, \"status.color.\") || !prefixcmp(k, \"color.status.\")) {\n+\t\tint slot = parse_status_slot(k, 13);\n+\t\tif (!v)\n+\t\t\treturn config_error_nonbool(k);\n+\t\tcolor_parse(v, k, s->wt_status_colors[slot]);\n+\t\treturn 0;\n+\t}\n+\tif (!strcmp(k, \"status.relativepaths\")) {\n+\t\ts->wt_status_relative_paths = git_config_bool(k, v);\n+\t\treturn 0;\n+\t}\n+\tif (!strcmp(k, \"status.showuntrackedfiles\")) {\n+\t\tif (!v)\n+\t\t\treturn config_error_nonbool(k);\n+\t\telse if (!strcmp(v, \"no\"))\n+\t\t\ts->show_untracked_files = SHOW_NO_UNTRACKED_FILES;\n+\t\telse if (!strcmp(v, \"normal\"))\n+\t\t\ts->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n+\t\telse if (!strcmp(v, \"all\"))\n+\t\t\ts->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;\n+\t\telse\n+\t\t\treturn error(\"Invalid untracked files mode '%s'\", v);\n+\t\treturn 0;\n+\t}\n+\treturn git_diff_ui_config(k, v, NULL);\n+}\n+\n int cmd_status(int argc, const char **argv, const char *prefix)\n {\n \tstruct wt_status s;\ndiff --git a/wt-status.c b/wt-status.c\nindex a2a7257..68e4d9b 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -19,24 +19,6 @@ static char default_wt_status_colors[][COLOR_MAXLEN] = {\n \tGIT_COLOR_RED,    /* WT_STATUS_UNMERGED */\n };\n \n-static int parse_status_slot(const char *var, int offset)\n-{\n-\tif (!strcasecmp(var+offset, \"header\"))\n-\t\treturn WT_STATUS_HEADER;\n-\tif (!strcasecmp(var+offset, \"updated\")\n-\t\t|| !strcasecmp(var+offset, \"added\"))\n-\t\treturn WT_STATUS_UPDATED;\n-\tif (!strcasecmp(var+offset, \"changed\"))\n-\t\treturn WT_STATUS_CHANGED;\n-\tif (!strcasecmp(var+offset, \"untracked\"))\n-\t\treturn WT_STATUS_UNTRACKED;\n-\tif (!strcasecmp(var+offset, \"nobranch\"))\n-\t\treturn WT_STATUS_NOBRANCH;\n-\tif (!strcasecmp(var+offset, \"unmerged\"))\n-\t\treturn WT_STATUS_UNMERGED;\n-\tdie(\"bad config variable '%s'\", var);\n-}\n-\n static const char *color(int slot, struct wt_status *s)\n {\n \treturn s->wt_status_use_color > 0 ? s->wt_status_colors[slot] : \"\";\n@@ -594,45 +576,3 @@ void wt_status_print(struct wt_status *s)\n \t\t\tprintf(\"nothing to commit (working directory clean)\\n\");\n \t}\n }\n-\n-int git_status_config(const char *k, const char *v, void *cb)\n-{\n-\tstruct wt_status *s = cb;\n-\n-\tif (!strcmp(k, \"status.submodulesummary\")) {\n-\t\tint is_bool;\n-\t\ts->wt_status_submodule_summary = git_config_bool_or_int(k, v, &is_bool);\n-\t\tif (is_bool && s->wt_status_submodule_summary)\n-\t\t\ts->wt_status_submodule_summary = -1;\n-\t\treturn 0;\n-\t}\n-\tif (!strcmp(k, \"status.color\") || !strcmp(k, \"color.status\")) {\n-\t\ts->wt_status_use_color = git_config_colorbool(k, v, -1);\n-\t\treturn 0;\n-\t}\n-\tif (!prefixcmp(k, \"status.color.\") || !prefixcmp(k, \"color.status.\")) {\n-\t\tint slot = parse_status_slot(k, 13);\n-\t\tif (!v)\n-\t\t\treturn config_error_nonbool(k);\n-\t\tcolor_parse(v, k, s->wt_status_colors[slot]);\n-\t\treturn 0;\n-\t}\n-\tif (!strcmp(k, \"status.relativepaths\")) {\n-\t\ts->wt_status_relative_paths = git_config_bool(k, v);\n-\t\treturn 0;\n-\t}\n-\tif (!strcmp(k, \"status.showuntrackedfiles\")) {\n-\t\tif (!v)\n-\t\t\treturn config_error_nonbool(k);\n-\t\telse if (!strcmp(v, \"no\"))\n-\t\t\ts->show_untracked_files = SHOW_NO_UNTRACKED_FILES;\n-\t\telse if (!strcmp(v, \"normal\"))\n-\t\t\ts->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n-\t\telse if (!strcmp(v, \"all\"))\n-\t\t\ts->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;\n-\t\telse\n-\t\t\treturn error(\"Invalid untracked files mode '%s'\", v);\n-\t\treturn 0;\n-\t}\n-\treturn git_diff_ui_config(k, v, NULL);\n-}\ndiff --git a/wt-status.h b/wt-status.h\nindex f22c3c1..12dc95e 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -50,7 +50,6 @@ struct wt_status {\n \tstruct string_list change;\n };\n \n-int git_status_config(const char *var, const char *value, void *cb);\n void wt_status_prepare(struct wt_status *s);\n void wt_status_print(struct wt_status *s);\n void wt_status_collect_changes(struct wt_status *s);\n-- \n1.6.4.173.g72959\n"},{"id":"120122","messageId":"1249894465-11018-6-git-send-email-gitster@pobox.com","threadId":"20515","inReplyTo":"1249894465-11018-5-git-send-email-gitster@pobox.com","subject":"[PATCH v3 5/8] wt-status: collect untracked files in a separate \"collect\" phase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-10T08:54:22Z","receivedAt":"2009-08-10T08:54:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"In a way similar to updated and locally modified files are collected.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n wt-status.c |   58 ++++++++++++++++++++++++++++++++++++----------------------\n wt-status.h |    3 ++-\n 2 files changed, 38 insertions(+), 23 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 68e4d9b..b6ae12c 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -41,6 +41,7 @@ void wt_status_prepare(struct wt_status *s)\n \ts->fp = stdout;\n \ts->index_file = get_index_file();\n \ts->change.strdup_strings = 1;\n+\ts->untracked.strdup_strings = 1;\n }\n \n static void wt_status_print_unmerged_header(struct wt_status *s)\n@@ -311,7 +312,30 @@ static void wt_status_collect_changes_initial(struct wt_status *s)\n \t}\n }\n \n-void wt_status_collect_changes(struct wt_status *s)\n+static void wt_status_collect_untracked(struct wt_status *s)\n+{\n+\tint i;\n+\tstruct dir_struct dir;\n+\n+\tif (!s->show_untracked_files)\n+\t\treturn;\n+\tmemset(&dir, 0, sizeof(dir));\n+\tif (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES)\n+\t\tdir.flags |=\n+\t\t\tDIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;\n+\tsetup_standard_excludes(&dir);\n+\n+\tfill_directory(&dir, NULL);\n+\tfor(i = 0; i < dir.nr; i++) {\n+\t\tstruct dir_entry *ent = dir.entries[i];\n+\t\tif (!cache_name_is_other(ent->name, ent->len))\n+\t\t\tcontinue;\n+\t\ts->workdir_untracked = 1;\n+\t\tstring_list_insert(ent->name, &s->untracked);\n+\t}\n+}\n+\n+void wt_status_collect(struct wt_status *s)\n {\n \twt_status_collect_changes_worktree(s);\n \n@@ -319,6 +343,7 @@ void wt_status_collect_changes(struct wt_status *s)\n \t\twt_status_collect_changes_initial(s);\n \telse\n \t\twt_status_collect_changes_index(s);\n+\twt_status_collect_untracked(s);\n }\n \n static void wt_status_print_unmerged(struct wt_status *s)\n@@ -446,31 +471,20 @@ static void wt_status_print_submodule_summary(struct wt_status *s)\n \n static void wt_status_print_untracked(struct wt_status *s)\n {\n-\tstruct dir_struct dir;\n \tint i;\n-\tint shown_header = 0;\n \tstruct strbuf buf = STRBUF_INIT;\n \n-\tmemset(&dir, 0, sizeof(dir));\n-\tif (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES)\n-\t\tdir.flags |=\n-\t\t\tDIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;\n-\tsetup_standard_excludes(&dir);\n+\tif (!s->untracked.nr)\n+\t\treturn;\n \n-\tfill_directory(&dir, NULL);\n-\tfor(i = 0; i < dir.nr; i++) {\n-\t\tstruct dir_entry *ent = dir.entries[i];\n-\t\tif (!cache_name_is_other(ent->name, ent->len))\n-\t\t\tcontinue;\n-\t\tif (!shown_header) {\n-\t\t\ts->workdir_untracked = 1;\n-\t\t\twt_status_print_untracked_header(s);\n-\t\t\tshown_header = 1;\n-\t\t}\n+\twt_status_print_untracked_header(s);\n+\tfor (i = 0; i < s->untracked.nr; i++) {\n+\t\tstruct string_list_item *it;\n+\t\tit = &(s->untracked.items[i]);\n \t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER, s), \"#\\t\");\n \t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED, s), \"%s\",\n-\t\t\t\tquote_path(ent->name, ent->len,\n-\t\t\t\t\t&buf, s->prefix));\n+\t\t\t\t quote_path(it->string, strlen(it->string),\n+\t\t\t\t\t    &buf, s->prefix));\n \t}\n \tstrbuf_release(&buf);\n }\n@@ -539,7 +553,7 @@ void wt_status_print(struct wt_status *s)\n \t\t\twt_status_print_tracking(s);\n \t}\n \n-\twt_status_collect_changes(s);\n+\twt_status_collect(s);\n \n \tif (s->is_initial) {\n \t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), \"#\");\n@@ -566,7 +580,7 @@ void wt_status_print(struct wt_status *s)\n \t\t\t; /* nothing */\n \t\telse if (s->workdir_dirty)\n \t\t\tprintf(\"no changes added to commit (use \\\"git add\\\" and/or \\\"git commit -a\\\")\\n\");\n-\t\telse if (s->workdir_untracked)\n+\t\telse if (s->untracked.nr)\n \t\t\tprintf(\"nothing added to commit but untracked files present (use \\\"git add\\\" to track)\\n\");\n \t\telse if (s->is_initial)\n \t\t\tprintf(\"nothing to commit (create/copy files and use \\\"git add\\\" to track)\\n\");\ndiff --git a/wt-status.h b/wt-status.h\nindex 12dc95e..33240b3 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -48,10 +48,11 @@ struct wt_status {\n \tFILE *fp;\n \tconst char *prefix;\n \tstruct string_list change;\n+\tstruct string_list untracked;\n };\n \n void wt_status_prepare(struct wt_status *s);\n void wt_status_print(struct wt_status *s);\n-void wt_status_collect_changes(struct wt_status *s);\n+void wt_status_collect(struct wt_status *s);\n \n #endif /* STATUS_H */\n-- \n1.6.4.173.g72959\n"},{"id":"120123","messageId":"1249894465-11018-7-git-send-email-gitster@pobox.com","threadId":"20515","inReplyTo":"1249894465-11018-6-git-send-email-gitster@pobox.com","subject":"[PATCH v3 6/8] git stat: the beginning","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-10T08:54:23Z","receivedAt":"2009-08-10T08:54:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tentatively add \"git stat\" as a new command.  This does not munge the\nindex with paths parameters before showing the status like \"git status\"\ndoes.  In later rounds, we will take path parameters as pathspec to limit\nthe output.\n---\n Makefile         |    1 +\n builtin-commit.c |   60 +++++++++++++++++++++++++++++++++++++++++++++---------\n builtin.h        |    1 +\n git.c            |    1 +\n wt-status.c      |   24 +++++++++++++--------\n wt-status.h      |    1 +\n 6 files changed, 69 insertions(+), 19 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex daf4296..39dd334 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -378,6 +378,7 @@ BUILT_INS += git-init$X\n BUILT_INS += git-merge-subtree$X\n BUILT_INS += git-peek-remote$X\n BUILT_INS += git-repo-config$X\n+BUILT_INS += git-stat$X\n BUILT_INS += git-show$X\n BUILT_INS += git-stage$X\n BUILT_INS += git-status$X\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 601118f..bc780a8 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -24,6 +24,7 @@\n #include \"string-list.h\"\n #include \"rerere.h\"\n #include \"unpack-trees.h\"\n+#include \"quote.h\"\n \n static const char * const builtin_commit_usage[] = {\n \t\"git commit [options] [--] <filepattern>...\",\n@@ -35,6 +36,11 @@ static const char * const builtin_status_usage[] = {\n \tNULL\n };\n \n+static const char * const builtin_stat_usage[] = {\n+\t\"git stat [options]\",\n+\tNULL\n+};\n+\n static unsigned char head_sha1[20], merge_head_sha1[20];\n static char *use_message_buffer;\n static const char commit_editmsg[] = \"COMMIT_EDITMSG\";\n@@ -691,6 +697,21 @@ static const char *find_author_by_nickname(const char *name)\n \tdie(\"No existing author found with '%s'\", name);\n }\n \n+\n+static void handle_untracked_files_arg(struct wt_status *s)\n+{\n+\tif (!untracked_files_arg)\n+\t\t; /* default already initialized */\n+\telse if (!strcmp(untracked_files_arg, \"no\"))\n+\t\ts->show_untracked_files = SHOW_NO_UNTRACKED_FILES;\n+\telse if (!strcmp(untracked_files_arg, \"normal\"))\n+\t\ts->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n+\telse if (!strcmp(untracked_files_arg, \"all\"))\n+\t\ts->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;\n+\telse\n+\t\tdie(\"Invalid untracked files mode '%s'\", untracked_files_arg);\n+}\n+\n static int parse_and_validate_options(int argc, const char *argv[],\n \t\t\t\t      const char * const usage[],\n \t\t\t\t      const char *prefix,\n@@ -794,16 +815,7 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \telse\n \t\tdie(\"Invalid cleanup mode %s\", cleanup_arg);\n \n-\tif (!untracked_files_arg)\n-\t\t; /* default already initialized */\n-\telse if (!strcmp(untracked_files_arg, \"no\"))\n-\t\ts->show_untracked_files = SHOW_NO_UNTRACKED_FILES;\n-\telse if (!strcmp(untracked_files_arg, \"normal\"))\n-\t\ts->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n-\telse if (!strcmp(untracked_files_arg, \"all\"))\n-\t\ts->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;\n-\telse\n-\t\tdie(\"Invalid untracked files mode '%s'\", untracked_files_arg);\n+\thandle_untracked_files_arg(s);\n \n \tif (all && argc > 0)\n \t\tdie(\"Paths with -a does not make sense.\");\n@@ -886,6 +898,34 @@ static int git_status_config(const char *k, const char *v, void *cb)\n \treturn git_diff_ui_config(k, v, NULL);\n }\n \n+int cmd_stat(int argc, const char **argv, const char *prefix)\n+{\n+\tstruct wt_status s;\n+\tunsigned char sha1[20];\n+\tstatic struct option builtin_stat_options[] = {\n+\t\t{ OPTION_STRING, 'u', \"untracked-files\", &untracked_files_arg,\n+\t\t  \"mode\",\n+\t\t  \"show untracked files, optional modes: all, normal, no. (Default: all)\",\n+\t\t  PARSE_OPT_OPTARG, NULL, (intptr_t)\"all\" },\n+\t\tOPT_END(),\n+\t};\n+\n+\twt_status_prepare(&s);\n+\tgit_config(git_status_config, &s);\n+\targc = parse_options(argc, argv, prefix,\n+\t\t\t     builtin_stat_options,\n+\t\t\t     builtin_stat_usage, 0);\n+\thandle_untracked_files_arg(&s);\n+\n+\tread_cache();\n+\trefresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);\n+\ts.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;\n+\twt_status_collect(&s);\n+\n+\twt_status_print_body(&s);\n+\treturn 0;\n+}\n+\n int cmd_status(int argc, const char **argv, const char *prefix)\n {\n \tstruct wt_status s;\ndiff --git a/builtin.h b/builtin.h\nindex 20427d2..eeaf0b6 100644\n--- a/builtin.h\n+++ b/builtin.h\n@@ -95,6 +95,7 @@ extern int cmd_send_pack(int argc, const char **argv, const char *prefix);\n extern int cmd_shortlog(int argc, const char **argv, const char *prefix);\n extern int cmd_show(int argc, const char **argv, const char *prefix);\n extern int cmd_show_branch(int argc, const char **argv, const char *prefix);\n+extern int cmd_stat(int argc, const char **argv, const char *prefix);\n extern int cmd_status(int argc, const char **argv, const char *prefix);\n extern int cmd_stripspace(int argc, const char **argv, const char *prefix);\n extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);\ndiff --git a/git.c b/git.c\nindex 807d875..de7fcf6 100644\n--- a/git.c\n+++ b/git.c\n@@ -350,6 +350,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"shortlog\", cmd_shortlog, USE_PAGER },\n \t\t{ \"show-branch\", cmd_show_branch, RUN_SETUP },\n \t\t{ \"show\", cmd_show, RUN_SETUP | USE_PAGER },\n+\t\t{ \"stat\", cmd_stat, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"status\", cmd_status, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"stripspace\", cmd_stripspace },\n \t\t{ \"symbolic-ref\", cmd_symbolic_ref, RUN_SETUP },\ndiff --git a/wt-status.c b/wt-status.c\nindex b6ae12c..a5dbdcc 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -531,6 +531,20 @@ static void wt_status_print_tracking(struct wt_status *s)\n \tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), \"#\");\n }\n \n+void wt_status_print_body(struct wt_status *s)\n+{\n+\twt_status_print_unmerged(s);\n+\twt_status_print_updated(s);\n+\twt_status_print_changed(s);\n+\tif (s->wt_status_submodule_summary)\n+\t\twt_status_print_submodule_summary(s);\n+\tif (s->show_untracked_files)\n+\t\twt_status_print_untracked(s);\n+\telse if (s->commitable)\n+\t\tfprintf(s->fp,\n+\t\t\t\"# Untracked files not listed (use -u option to show untracked files)\\n\");\n+}\n+\n void wt_status_print(struct wt_status *s)\n {\n \tunsigned char sha1[20];\n@@ -561,15 +575,7 @@ void wt_status_print(struct wt_status *s)\n \t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), \"#\");\n \t}\n \n-\twt_status_print_unmerged(s);\n-\twt_status_print_updated(s);\n-\twt_status_print_changed(s);\n-\tif (s->wt_status_submodule_summary)\n-\t\twt_status_print_submodule_summary(s);\n-\tif (s->show_untracked_files)\n-\t\twt_status_print_untracked(s);\n-\telse if (s->commitable)\n-\t\t fprintf(s->fp, \"# Untracked files not listed (use -u option to show untracked files)\\n\");\n+\twt_status_print_body(s);\n \n \tif (s->verbose)\n \t\twt_status_print_verbose(s);\ndiff --git a/wt-status.h b/wt-status.h\nindex 33240b3..44c40ff 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -54,5 +54,6 @@ struct wt_status {\n void wt_status_prepare(struct wt_status *s);\n void wt_status_print(struct wt_status *s);\n void wt_status_collect(struct wt_status *s);\n+void wt_status_print_body(struct wt_status *s);\n \n #endif /* STATUS_H */\n-- \n1.6.4.173.g72959\n"},{"id":"120127","messageId":"1249894465-11018-8-git-send-email-gitster@pobox.com","threadId":"20515","inReplyTo":"1249894465-11018-7-git-send-email-gitster@pobox.com","subject":"[PATCH v3 7/8] git stat: pathspec limits, unlike traditional \"git status\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-10T08:54:24Z","receivedAt":"2009-08-10T08:54:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The \"git stat\" command is not \"preview of commit with the same arguments\";\nthe path parameters are not paths to be added to the pristine index (aka\n\"--only\" option), but are taken as pathspecs to limit the output.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin-commit.c |    3 +++\n wt-status.c      |    6 ++++++\n wt-status.h      |    1 +\n 3 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex bc780a8..9c2a70c 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -917,6 +917,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix)\n \t\t\t     builtin_stat_usage, 0);\n \thandle_untracked_files_arg(&s);\n \n+\tif (*argv)\n+\t\ts.pathspec = get_pathspec(prefix, argv);\n+\n \tread_cache();\n \trefresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);\n \ts.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;\ndiff --git a/wt-status.c b/wt-status.c\nindex a5dbdcc..aea3bbb 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -269,6 +269,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)\n \trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n \trev.diffopt.format_callback = wt_status_collect_changed_cb;\n \trev.diffopt.format_callback_data = s;\n+\trev.prune_data = s->pathspec;\n \trun_diff_files(&rev, 0);\n }\n \n@@ -285,6 +286,7 @@ static void wt_status_collect_changes_index(struct wt_status *s)\n \trev.diffopt.detect_rename = 1;\n \trev.diffopt.rename_limit = 200;\n \trev.diffopt.break_opt = 0;\n+\trev.prune_data = s->pathspec;\n \trun_diff_index(&rev, 1);\n }\n \n@@ -297,6 +299,8 @@ static void wt_status_collect_changes_initial(struct wt_status *s)\n \t\tstruct wt_status_change_data *d;\n \t\tstruct cache_entry *ce = active_cache[i];\n \n+\t\tif (!ce_path_match(ce, s->pathspec))\n+\t\t\tcontinue;\n \t\tit = string_list_insert(ce->name, &s->change);\n \t\td = it->util;\n \t\tif (!d) {\n@@ -330,6 +334,8 @@ static void wt_status_collect_untracked(struct wt_status *s)\n \t\tstruct dir_entry *ent = dir.entries[i];\n \t\tif (!cache_name_is_other(ent->name, ent->len))\n \t\t\tcontinue;\n+\t\tif (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))\n+\t\t\tcontinue;\n \t\ts->workdir_untracked = 1;\n \t\tstring_list_insert(ent->name, &s->untracked);\n \t}\ndiff --git a/wt-status.h b/wt-status.h\nindex 44c40ff..6dcb739 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -31,6 +31,7 @@ struct wt_status {\n \tint is_initial;\n \tchar *branch;\n \tconst char *reference;\n+\tconst char **pathspec;\n \tint verbose;\n \tint amend;\n \tint nowarn;\n-- \n1.6.4.173.g72959\n"},{"id":"120126","messageId":"1249894465-11018-9-git-send-email-gitster@pobox.com","threadId":"20515","inReplyTo":"1249894465-11018-8-git-send-email-gitster@pobox.com","subject":"[PATCH v3 8/8] git stat -s: short status output","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-10T08:54:25Z","receivedAt":"2009-08-10T08:54:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Give -s(hort) option to \"git stat\" that shows the status of paths in a\nmore concise way.\n\n    XY PATH1 -> PATH2\n\nformat to be more machine readable than output from \"git status\", which is\nabout previewing of \"git commit\" with the same arguments.\n\nPATH1 is the path in the HEAD, and \" -> PATH2\" part is shown only when\nPATH1 corresponds to a different path in the index/worktree.\n\nFor unmerged entries, X shows the status of stage #2 (i.e. ours) and Y\nshows the status of stage #3 (i.e. theirs).  For entries that do not have\nconflicts, X shows the status of the index, and Y shows the status of the\nwork tree.  For untracked paths, XY are \"??\".\n\n    X          Y     Meaning\n    -------------------------------------------------\n              [MD]   not updated\n    M        [ MD]   updated in index\n    A        [ MD]   added to index\n    D        [ MD]   deleted from index\n    R        [ MD]   renamed in index\n    C        [ MD]   copied in index\n    [MARC]           index and work tree matches\n    [ MARC]     M    work tree changed since index\n    [ MARC]     D    deleted in work tree\n\n    D           D    unmerged, both deleted\n    A           U    unmerged, added by us\n    U           D    unmerged, deleted by them\n    U           A    unmerged, added by them\n    D           U    unmerged, deleted by us\n    A           A    unmerged, both added\n    U           U    unmerged, both modified\n\n    ?           ?    untracked\n\nWhen given -z option, the records are terminated by NUL characters for\nbetter machine readability.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin-commit.c |   97 +++++++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 96 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 9c2a70c..0ed0d71 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -898,11 +898,86 @@ static int git_status_config(const char *k, const char *v, void *cb)\n \treturn git_diff_ui_config(k, v, NULL);\n }\n \n+#define quote_path quote_path_relative\n+\n+static void short_unmerged(int null_termination, struct string_list_item *it,\n+\t\t\t   struct wt_status *s)\n+{\n+\tstruct wt_status_change_data *d = it->util;\n+\tconst char *how = \"??\";\n+\n+\tswitch (d->stagemask) {\n+\tcase 1: how = \"DD\"; break; /* both deleted */\n+\tcase 2: how = \"AU\"; break; /* added by us */\n+\tcase 3: how = \"UD\"; break; /* deleted by them */\n+\tcase 4: how = \"UA\"; break; /* added by them */\n+\tcase 5: how = \"DU\"; break; /* deleted by us */\n+\tcase 6: how = \"AA\"; break; /* both added */\n+\tcase 7: how = \"UU\"; break; /* both modified */\n+\t}\n+\tprintf(\"%s \", how);\n+\tif (null_termination) {\n+\t\tfprintf(stdout, \"%s%c\", it->string, 0);\n+\t} else {\n+\t\tstruct strbuf onebuf = STRBUF_INIT;\n+\t\tconst char *one;\n+\t\tone = quote_path(it->string, -1, &onebuf, s->prefix);\n+\t\tprintf(\"%s\\n\", one);\n+\t\tstrbuf_release(&onebuf);\n+\t}\n+}\n+\n+static void short_status(int null_termination, struct string_list_item *it,\n+\t\t\t struct wt_status *s)\n+{\n+\tstruct wt_status_change_data *d = it->util;\n+\n+\tprintf(\"%c%c \",\n+\t       !d->index_status ? ' ' : d->index_status,\n+\t       !d->worktree_status ? ' ' : d->worktree_status);\n+\tif (null_termination) {\n+\t\tfprintf(stdout, \"%s%c\", it->string, 0);\n+\t\tif (d->head_path)\n+\t\t\tfprintf(stdout, \"%s%c\", d->head_path, 0);\n+\t} else {\n+\t\tstruct strbuf onebuf = STRBUF_INIT;\n+\t\tconst char *one;\n+\t\tif (d->head_path) {\n+\t\t\tone = quote_path(d->head_path, -1, &onebuf, s->prefix);\n+\t\t\tprintf(\"%s -> \", one);\n+\t\t\tstrbuf_release(&onebuf);\n+\t\t}\n+\t\tone = quote_path(it->string, -1, &onebuf, s->prefix);\n+\t\tprintf(\"%s\\n\", one);\n+\t\tstrbuf_release(&onebuf);\n+\t}\n+}\n+\n+static void short_untracked(int null_termination, struct string_list_item *it,\n+\t\t\t    struct wt_status *s)\n+{\n+\tif (null_termination) {\n+\t\tfprintf(stdout, \"?? %s%c\", it->string, 0);\n+\t} else {\n+\t\tstruct strbuf onebuf = STRBUF_INIT;\n+\t\tconst char *one;\n+\t\tone = quote_path(it->string, -1, &onebuf, s->prefix);\n+\t\tprintf(\"?? %s\\n\", one);\n+\t\tstrbuf_release(&onebuf);\n+\t}\n+}\n+\n int cmd_stat(int argc, const char **argv, const char *prefix)\n {\n \tstruct wt_status s;\n+\tstatic int null_termination, shortstatus;\n+\tint i;\n \tunsigned char sha1[20];\n \tstatic struct option builtin_stat_options[] = {\n+\t\tOPT_BOOLEAN('s', \"short\", &shortstatus,\n+\t\t\t    \"show status concicely\"),\n+\t\tOPT_BOOLEAN('z', \"null\", &null_termination,\n+\t\t\t    \"terminate entries with NUL\"),\n \t\t{ OPTION_STRING, 'u', \"untracked-files\", &untracked_files_arg,\n \t\t  \"mode\",\n \t\t  \"show untracked files, optional modes: all, normal, no. (Default: all)\",\n@@ -925,7 +1000,27 @@ int cmd_stat(int argc, const char **argv, const char *prefix)\n \ts.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;\n \twt_status_collect(&s);\n \n-\twt_status_print_body(&s);\n+\tif (shortstatus) {\n+\t\tfor (i = 0; i < s.change.nr; i++) {\n+\t\t\tstruct wt_status_change_data *d;\n+\t\t\tstruct string_list_item *it;\n+\n+\t\t\tit = &(s.change.items[i]);\n+\t\t\td = it->util;\n+\t\t\tif (d->stagemask)\n+\t\t\t\tshort_unmerged(null_termination, it, &s);\n+\t\t\telse\n+\t\t\t\tshort_status(null_termination, it, &s);\n+\t\t}\n+\t\tfor (i = 0; i < s.untracked.nr; i++) {\n+\t\t\tstruct string_list_item *it;\n+\n+\t\t\tit = &(s.untracked.items[i]);\n+\t\t\tshort_untracked(null_termination, it, &s);\n+\t\t}\n+\t} else {\n+\t\twt_status_print_body(&s);\n+\t}\n \treturn 0;\n }\n \n-- \n1.6.4.173.g72959\n"},{"id":"120131","messageId":"20090810091010.GA7513@coredump.intra.peff.net","threadId":"20515","inReplyTo":"1249894465-11018-3-git-send-email-gitster@pobox.com","subject":"Re: [PATCH v3 2/8] wt-status: move many global settings to wt_status structure","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-08-10T09:10:10Z","receivedAt":"2009-08-10T09:10:10Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Aug 10, 2009 at 01:54:19AM -0700, Junio C Hamano wrote:\n\n> --- a/wt-status.h\n> +++ b/wt-status.h\n> [...]\n> @@ -33,8 +32,12 @@ struct wt_status {\n>  \tconst char *reference;\n>  \tint verbose;\n>  \tint amend;\n> -\tint untracked;\n>  \tint nowarn;\n> +\tint wt_status_use_color;\n> +\tint wt_status_relative_paths;\n> +\tint wt_status_submodule_summary;\n> +\tenum untracked_status_type show_untracked_files;\n> +\n\nIs there a particular reason to use such enormous struct member names?\nIOW, inside wt_status, why not just \"use_color\"?\n\nOther than that, I think this is a very positive change (and in fact, I\nlike the way this whole series is shaping up).\n\n-Peff\n"},{"id":"120132","messageId":"20090810091250.GB7513@coredump.intra.peff.net","threadId":"20515","inReplyTo":"1249894465-11018-4-git-send-email-gitster@pobox.com","subject":"Re: [PATCH v3 3/8] wt-status: move wt_status_colors[] into wt_status structure","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-08-10T09:12:50Z","receivedAt":"2009-08-10T09:12:50Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Aug 10, 2009 at 01:54:20AM -0700, Junio C Hamano wrote:\n\n> @@ -37,6 +38,7 @@ struct wt_status {\n>  \tint wt_status_relative_paths;\n>  \tint wt_status_submodule_summary;\n>  \tenum untracked_status_type show_untracked_files;\n> +\tchar wt_status_colors[6][COLOR_MAXLEN];\n\nYuck on the magic \"6\". It should be safe to use\n\n  ARRAY_SIZE(wt_status_colors_default)\n\nsince that is computed purely from sizeof's. Though I am not discounting\nthe possibility that there are compilers which will screw it up.\n\n-Peff\n"}]}