{"thread":{"id":"12642","subject":"[PATCH 3/3] buitin-status: Add tests for submodule summary","startedAt":"2008-03-12T02:21:50Z","lastAt":"2008-03-13T13:05:17Z","messageCount":6,"participants":["Ping Yin","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"71766","messageId":"1205288512-20435-1-git-send-email-pkufranky@gmail.com","threadId":"12642","inReplyTo":null,"subject":"[PATCH 1/3] builtin-status: submodule summary support","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-12T02:21:50Z","receivedAt":"2008-03-12T02:21:50Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"This commit teaches 'git commit/status' show 'Modified submodules'\nsection given by 'git submodule summary --cached --for-status'\njust before 'Untracked files' section.\n\nSigned-off-by: Ping Yin <pkufranky@gmail.com>\n---\n wt-status.c |   31 +++++++++++++++++++++++++++++++\n 1 files changed, 31 insertions(+), 0 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 701d13d..6d36e54 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -8,6 +8,7 @@\n #include \"revision.h\"\n #include \"diffcore.h\"\n #include \"quote.h\"\n+#include \"run-command.h\"\n \n int wt_status_relative_paths = 1;\n int wt_status_use_color = -1;\n@@ -219,6 +220,33 @@ static void wt_status_print_changed(struct wt_status *s)\n \trev.diffopt.format_callback_data = s;\n \trun_diff_files(&rev, 0);\n }\n+static void wt_status_print_submodule_summary(struct wt_status *s)\n+{\n+\tstruct child_process sm_summary;\n+\tconst char *argv[] = {\n+\t\t\"submodule\",\n+\t\t\"summary\",\n+\t\t\"--cached\",\n+\t\t\"--for-status\",\n+\t\t\"--summary-limit\",\n+\t\tsummary_limit,\n+\t\ts->amend ? \"HEAD^\" : \"HEAD\",\n+\t\tNULL\n+\t};\n+\tchar index[PATH_MAX];\n+\tconst char *env[2] = { index, NULL };\n+\tsnprintf(index, sizeof(index), \"GIT_INDEX_FILE=%s\", s->index_file);\n+\n+\tmemset(&sm_summary, 0, sizeof(sm_summary));\n+\tsm_summary.argv = argv;\n+\tsm_summary.env = env;\n+\tsm_summary.git_cmd = 1;\n+\tsm_summary.no_stdin = 1;\n+\tfflush(s->fp);\n+\tsm_summary.out = dup(fileno(s->fp));    /* run_command closes it */\n+\tsm_summary.no_stderr = 1;\n+\trun_command(&sm_summary);\n+}\n \n static void wt_status_print_untracked(struct wt_status *s)\n {\n@@ -321,6 +349,9 @@ void wt_status_print(struct wt_status *s)\n \t}\n \n \twt_status_print_changed(s);\n+\t// must flush s->fp since following call will write to s->fp in a child process\n+\tfflush(s->fp);\n+\twt_status_print_submodule_summary(s);\n \twt_status_print_untracked(s);\n \n \tif (s->verbose && !s->is_initial)\n-- \n1.5.4.3.347.g5314c\n"},{"id":"71767","messageId":"1205288512-20435-2-git-send-email-pkufranky@gmail.com","threadId":"12642","inReplyTo":"1205288512-20435-1-git-send-email-pkufranky@gmail.com","subject":"[PATCH 2/3] builtin-status: configurable submodule summary size","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-12T02:21:51Z","receivedAt":"2008-03-12T02:21:51Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"Add config variable status.submodulesummary which is passed as\narg for '--summary-limit' of 'git submodule summary' to limit the\nsubmodule summary size.\n\nstatus.submodulesummary is 0 by default which disables the summary.\n\nSigned-off-by: Ping Yin <pkufranky@gmail.com>\n---\n wt-status.c |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 6d36e54..6a58057 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -12,6 +12,7 @@\n \n int wt_status_relative_paths = 1;\n int wt_status_use_color = -1;\n+int wt_status_submodule_summary = 0;\n static char wt_status_colors[][COLOR_MAXLEN] = {\n \t\"\",         /* WT_STATUS_HEADER: normal */\n \t\"\\033[32m\", /* WT_STATUS_UPDATED: green */\n@@ -223,6 +224,8 @@ static void wt_status_print_changed(struct wt_status *s)\n static void wt_status_print_submodule_summary(struct wt_status *s)\n {\n \tstruct child_process sm_summary;\n+\tchar summary_limit[64];\n+\tsprintf(summary_limit, \"%d\", wt_status_submodule_summary);\n \tconst char *argv[] = {\n \t\t\"submodule\",\n \t\t\"summary\",\n@@ -374,6 +377,10 @@ void wt_status_print(struct wt_status *s)\n \n int git_status_config(const char *k, const char *v)\n {\n+\tif (!strcmp(k, \"status.submodulesummary\")) {\n+\t\twt_status_submodule_summary = atoi(v);\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\treturn 0;\n-- \n1.5.4.3.347.g5314c\n"},{"id":"71765","messageId":"1205288512-20435-3-git-send-email-pkufranky@gmail.com","threadId":"12642","inReplyTo":"1205288512-20435-2-git-send-email-pkufranky@gmail.com","subject":"[PATCH 3/3] buitin-status: Add tests for submodule summary","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-12T02:21:52Z","receivedAt":"2008-03-12T02:21:52Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"---\n t/t7502-status.sh |   76 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 76 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t7502-status.sh b/t/t7502-status.sh\nindex e006074..d48c0fe 100755\n--- a/t/t7502-status.sh\n+++ b/t/t7502-status.sh\n@@ -149,4 +149,80 @@ test_expect_success 'status of partial commit excluding new file in index' '\n \tdiff -u expect output\n '\n \n+test_expect_success \"setup status submodule summary\" '\n+\ttest_create_repo sm &&\n+\tcd sm &&\n+\t: >foo &&\n+\tgit add foo &&\n+\tgit commit -m \"Add foo\" &&\n+\tcd .. &&\n+\tgit add sm\n+'\n+\n+cat > expect << \\EOF\n+# On branch master\n+# Changes to be committed:\n+#   (use \"git reset HEAD <file>...\" to unstage)\n+#\n+#\tnew file:   dir2/added\n+#\tnew file:   sm\n+#\n+# Changed but not updated:\n+#   (use \"git add <file>...\" to update what will be committed)\n+#\n+#\tmodified:   dir1/modified\n+#\n+# Untracked files:\n+#   (use \"git add <file>...\" to include in what will be committed)\n+#\n+#\tdir1/untracked\n+#\tdir2/modified\n+#\tdir2/untracked\n+#\texpect\n+#\toutput\n+#\tuntracked\n+EOF\n+test_expect_success \"status submodule summary is disabled by default\" '\n+\tgit status > output &&\n+\tgit diff expect output\n+'\n+\n+cd sm &&\n+head=$(git rev-parse --verify HEAD | cut -c1-7) &&\n+cd ..\n+\n+cat > expect <<-EOF\n+# On branch master\n+# Changes to be committed:\n+#   (use \"git reset HEAD <file>...\" to unstage)\n+#\n+#\tnew file:   dir2/added\n+#\tnew file:   sm\n+#\n+# Changed but not updated:\n+#   (use \"git add <file>...\" to update what will be committed)\n+#\n+#\tmodified:   dir1/modified\n+#\n+# Modified submodules:\n+#\n+# * sm 0000000...$head (1):\n+#   > Add foo\n+#\n+# Untracked files:\n+#   (use \"git add <file>...\" to include in what will be committed)\n+#\n+#\tdir1/untracked\n+#\tdir2/modified\n+#\tdir2/untracked\n+#\texpect\n+#\toutput\n+#\tuntracked\n+EOF\n+test_expect_success \"status submodule summary\" '\n+\tgit config status.submodulesummary 10 &&\n+\tgit status > output &&\n+\tgit diff expect output\n+'\n+\n test_done\n-- \n1.5.4.3.347.g5314c\n"},{"id":"71790","messageId":"47D78753.2040902@viscovery.net","threadId":"12642","inReplyTo":"1205288512-20435-1-git-send-email-pkufranky@gmail.com","subject":"Re: [PATCH 1/3] builtin-status: submodule summary support","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-03-12T07:33:39Z","receivedAt":"2008-03-12T07:33:39Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Ping Yin schrieb:\n> +static void wt_status_print_submodule_summary(struct wt_status *s)\n> +{\n> +\tstruct child_process sm_summary;\n> +\tconst char *argv[] = {\n> +\t\t\"submodule\",\n> +\t\t\"summary\",\n> +\t\t\"--cached\",\n> +\t\t\"--for-status\",\n> +\t\t\"--summary-limit\",\n> +\t\tsummary_limit,\n\nWhere is summary_limit? Did you split this patch series incorrectly?\n\n> +\t\ts->amend ? \"HEAD^\" : \"HEAD\",\n\nAny chance that we avoid \"HEAD^\" here? Perhaps we have the SHA1 around\nsomewhere? I fear that our MSYS bash mangles it into \"HEAD\". I shall test it.\n\nBTW, you don't mention the prerequisites of this series. I assume it\nbuilds on top of your \"[PATCH v5 0/5] git-submodule summary\" series.\n\n> +\tsm_summary.no_stderr = 1;\n\nWhy this? If the submodule summary has errors we certainly want to see them.\n\n> @@ -321,6 +349,9 @@ void wt_status_print(struct wt_status *s)\n>  \t}\n>  \n>  \twt_status_print_changed(s);\n> +\t// must flush s->fp since following call will write to s->fp in a child process\n> +\tfflush(s->fp);\n> +\twt_status_print_submodule_summary(s);\n\nHmm. Aren't you unconditionally spawning \"git submodule summary\" for each\ngit-status/git-commit?\n\n-- Hannes\n"},{"id":"71791","messageId":"47D7885B.6060500@viscovery.net","threadId":"12642","inReplyTo":"1205288512-20435-3-git-send-email-pkufranky@gmail.com","subject":"Re: [PATCH 3/3] buitin-status: Add tests for submodule summary","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-03-12T07:38:03Z","receivedAt":"2008-03-12T07:38:03Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Ping Yin schrieb:\n> ---\n>  t/t7502-status.sh |   76 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n>  1 files changed, 76 insertions(+), 0 deletions(-)\n\nSigned-off-by?\n\nWould you please add a test case that uses \"git status --amend\"? It would\nhelp diagnose failures with regard to \"HEAD^\" on Windows greatly.\n\n-- Hannes\n"},{"id":"71931","messageId":"46dff0320803130605g492ebc89y9476aba6ae729d9f@mail.gmail.com","threadId":"12642","inReplyTo":"47D78753.2040902@viscovery.net","subject":"Re: [PATCH 1/3] builtin-status: submodule summary support","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-13T13:05:17Z","receivedAt":"2008-03-13T13:05:17Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":">\n>  Where is summary_limit? Did you split this patch series incorrectly?\n>\n>  > +             s->amend ? \"HEAD^\" : \"HEAD\",\n>\n>  Any chance that we avoid \"HEAD^\" here? Perhaps we have the SHA1 around\n>  somewhere? I fear that our MSYS bash mangles it into \"HEAD\". I shall test it.\n>\nI am not familiar with git core code, and don't find a way to avoid 'HEAD^' yet\n\n\n\n-- \nPing Yin\n"}]}