{"thread":{"id":"10919","subject":"[PATCH] builtin-commit: Fix git-commit honoring status.color","startedAt":"2007-11-18T17:10:34Z","lastAt":"2007-11-19T18:26:59Z","messageCount":4,"participants":["Ping Yin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"60238","messageId":"1195405834-1469-1-git-send-email-pkufranky@gmail.com","threadId":"10919","inReplyTo":null,"subject":"[PATCH] builtin-commit: Fix git-commit honoring status.color","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-18T17:10:34Z","receivedAt":"2007-11-18T17:10:34Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"status.color shouldn't be honored when committing since the run-status\noutput is fed to the editor.\n---\n builtin-commit.c |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 8db74ed..4396e7d 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -45,6 +45,7 @@ static int quiet, verbose, untracked_files, no_verify;\n static int no_edit, initial_commit, in_merge;\n const char *only_include_assumed;\n struct strbuf message;\n+extern int wt_status_use_color;\n \n static int opt_parse_m(const struct option *opt, const char *arg, int unset)\n {\n@@ -325,6 +326,7 @@ static int prepare_log_message(const char *index_file, const char *prefix)\n \tif (only_include_assumed)\n \t\tfprintf(fp, \"# %s\\n\", only_include_assumed);\n \n+\twt_status_use_color = 0;\n \tcommitable = run_status(fp, index_file, prefix);\n \n \tfclose(fp);\n-- \n1.5.3.5.1876.g7ba19-dirty\n"},{"id":"60249","messageId":"7vejenuy4i.fsf@gitster.siamese.dyndns.org","threadId":"10919","inReplyTo":"1195405834-1469-1-git-send-email-pkufranky@gmail.com","subject":"Re: [PATCH] builtin-commit: Fix git-commit honoring status.color","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-18T19:55:41Z","receivedAt":"2007-11-18T19:55:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ping Yin <pkufranky@gmail.com> writes:\n\n> status.color shouldn't be honored when committing since the run-status\n> output is fed to the editor.\n> ---\n>  builtin-commit.c |    2 ++\n>  1 files changed, 2 insertions(+), 0 deletions(-)\n>\n> diff --git a/builtin-commit.c b/builtin-commit.c\n> index 8db74ed..4396e7d 100644\n> --- a/builtin-commit.c\n> +++ b/builtin-commit.c\n> @@ -45,6 +45,7 @@ static int quiet, verbose, untracked_files, no_verify;\n>  static int no_edit, initial_commit, in_merge;\n>  const char *only_include_assumed;\n>  struct strbuf message;\n> +extern int wt_status_use_color;\n>  \n>  static int opt_parse_m(const struct option *opt, const char *arg, int unset)\n>  {\n> @@ -325,6 +326,7 @@ static int prepare_log_message(const char *index_file, const char *prefix)\n>  \tif (only_include_assumed)\n>  \t\tfprintf(fp, \"# %s\\n\", only_include_assumed);\n>  \n> +\twt_status_use_color = 0;\n>  \tcommitable = run_status(fp, index_file, prefix);\n>  \n>  \tfclose(fp);\n\nAlthough I admit I do not care much about the \"status color\", I\nsuspect this patch is not quite right.\n\nWhen prepare_log_message() returns \"no committable changes\" and\nwe are not in merge, the calling cmd_commit() does another\nrun_status() to show the status of the index and the work tree\nto the stdout, and at that point, we _do_ want to honor the\nconfiguration setting you are discarding with this assignment.\n\n---\n\n builtin-commit.c |    5 ++++-\n wt-status.h      |    1 +\n 2 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 4e2f4aa..058cd32 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -300,7 +300,7 @@ static const char sign_off_header[] = \"Signed-off-by: \";\n static int prepare_log_message(const char *index_file, const char *prefix)\n {\n \tstruct stat statbuf;\n-\tint commitable;\n+\tint commitable, saved_color_setting;\n \tstruct strbuf sb;\n \tchar *buffer;\n \tFILE *fp;\n@@ -383,7 +383,10 @@ static int prepare_log_message(const char *index_file, const char *prefix)\n \tif (only_include_assumed)\n \t\tfprintf(fp, \"# %s\\n\", only_include_assumed);\n \n+\tsaved_color_setting = wt_status_use_color;\n+\twt_status_use_color = 0;\n \tcommitable = run_status(fp, index_file, prefix);\n+\twt_status_use_color = saved_color_setting;\n \n \tfclose(fp);\n \ndiff --git a/wt-status.h b/wt-status.h\nindex f58ebcb..225fb4d 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -27,6 +27,7 @@ struct wt_status {\n };\n \n int git_status_config(const char *var, const char *value);\n+int wt_status_use_color;\n void wt_status_prepare(struct wt_status *s);\n void wt_status_print(struct wt_status *s);\n \n"},{"id":"60252","messageId":"7v1wanuwiy.fsf_-_@gitster.siamese.dyndns.org","threadId":"10919","inReplyTo":"7vejenuy4i.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] builtin-commit: run commit-msg hook with correct message file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-18T20:30:13Z","receivedAt":"2007-11-18T20:30:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"It should run with $GIT_DIR/COMMIT_EDITMSG, not just COMMIT_EDITMSG.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * Other things I noticed that are still broken:\n\n   - \"git commit -v\" does not give you the diff in the message\n     template for your final review;\n\n   - message_is_empty() is bogus.  It does run stripspace() but\n     does not strip out the diff \"git commit -v\" would produce\n     before doing its comparison;\n\n builtin-commit.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 058cd32..439fcc2 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -753,7 +753,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\trollback_index_files();\n \t\tdie(\"could not read commit message\\n\");\n \t}\n-\tif (run_hook(index_file, \"commit-msg\", commit_editmsg)) {\n+\tif (run_hook(index_file, \"commit-msg\", git_path(commit_editmsg))) {\n \t\trollback_index_files();\n \t\texit(1);\n \t}\n-- \n1.5.3.5.1815.g9445b\n"},{"id":"60345","messageId":"46dff0320711191026l6d749886y4fd3879f555c6107@mail.gmail.com","threadId":"10919","inReplyTo":"7vejenuy4i.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] builtin-commit: Fix git-commit honoring status.color","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-19T18:26:59Z","receivedAt":"2007-11-19T18:26:59Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":">\n> Although I admit I do not care much about the \"status color\", I\n> suspect this patch is not quite right.\n>\n> When prepare_log_message() returns \"no committable changes\" and\n> we are not in merge, the calling cmd_commit() does another\n> run_status() to show the status of the index and the work tree\n> to the stdout, and at that point, we _do_ want to honor the\n> configuration setting you are discarding with this assignment.\n>\nYou're right. I forgot about untracked files when there are 'no\ncommittable changes'\n> ---\n>\n>  builtin-commit.c |    5 ++++-\n>  wt-status.h      |    1 +\n>  2 files changed, 5 insertions(+), 1 deletions(-)\n>\n> diff --git a/builtin-commit.c b/builtin-commit.c\n> index 4e2f4aa..058cd32 100644\n> --- a/builtin-commit.c\n> +++ b/builtin-commit.c\n> @@ -300,7 +300,7 @@ static const char sign_off_header[] = \"Signed-off-by: \";\n>  static int prepare_log_message(const char *index_file, const char *prefix)\n>  {\n>         struct stat statbuf;\n> -       int commitable;\n> +       int commitable, saved_color_setting;\n>         struct strbuf sb;\n>         char *buffer;\n>         FILE *fp;\n> @@ -383,7 +383,10 @@ static int prepare_log_message(const char *index_file, const char *prefix)\n>         if (only_include_assumed)\n>                 fprintf(fp, \"# %s\\n\", only_include_assumed);\n>\n> +       saved_color_setting = wt_status_use_color;\n> +       wt_status_use_color = 0;\n>         commitable = run_status(fp, index_file, prefix);\n> +       wt_status_use_color = saved_color_setting;\n>\n>         fclose(fp);\n>\n> diff --git a/wt-status.h b/wt-status.h\n> index f58ebcb..225fb4d 100644\n> --- a/wt-status.h\n> +++ b/wt-status.h\n> @@ -27,6 +27,7 @@ struct wt_status {\n>  };\n>\n>  int git_status_config(const char *var, const char *value);\n> +int wt_status_use_color;\n>  void wt_status_prepare(struct wt_status *s);\n>  void wt_status_print(struct wt_status *s);\n>\n>\n\n\n\n-- \nPing Yin\n"}]}