{"thread":{"id":"43300","subject":"[PATCH 1/2] Suggest use of 'git add' when 'nothing to commit' gets shown.","startedAt":"2006-12-15T00:13:50Z","lastAt":"2006-12-15T15:06:32Z","messageCount":3,"participants":["Shawn O. Pearce","Shawn Pearce","Andreas Ericsson"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"294266","messageId":"20061215001350.GA26755@spearce.org","threadId":"43300","inReplyTo":null,"subject":"[PATCH 1/2] Suggest use of 'git add' when 'nothing to commit' gets shown.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-12-15T00:13:50Z","receivedAt":"2006-12-15T00:13:50Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"If a user modifies files and runs 'git commit' (without the very\nuseful -a option) and they have not yet updated the index they\nare probably coming from another SCM-like tool which would perform\nthe same as 'git commit -a' in this case.  Showing the user their\ncurrent status and a final line of \"nothing to commit\" is not very\nreassuring, as the user might believe that Git did not recognize\ntheir files were modified.\n\nInstead we can suggest as part of the 'nothing to commit' message\nthat the user invoke 'git add' to add files to their next commit.\n\nSuggested by Andy Parkins in his Git 'niggles' list\n(<200612132237.10051.andyparkins@gmail.com>).\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n git-commit.sh |    2 +-\n wt-status.c   |    7 ++++---\n 2 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/git-commit.sh b/git-commit.sh\nindex 05828bb..fb69e11 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -515,7 +515,7 @@ then\n \tcurrent=\"$(git-rev-parse --verify HEAD)\"\n else\n \tif [ -z \"$(git-ls-files)\" ]; then\n-\t\techo >&2 Nothing to commit\n+\t\techo >&2 \"Nothing to commit (use \\\"git add\\\" include for commit)\"\n \t\texit 1\n \tfi\n \tPARENTS=\"\"\ndiff --git a/wt-status.c b/wt-status.c\nindex 6e9414d..f9ed54f 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -163,7 +163,7 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,\n \tint i;\n \tif (q->nr)\n \t\twt_status_print_header(\"Changed but not updated\",\n-\t\t\t\t\"use git-add on files to include for commit\");\n+\t\t\t\t\"use \\\"git add\\\" on files to include for commit\");\n \tfor (i = 0; i < q->nr; i++)\n \t\twt_status_print_filepair(WT_STATUS_CHANGED, q->queue[i]);\n \tif (q->nr)\n@@ -250,7 +250,7 @@ static void wt_status_print_untracked(const struct wt_status *s)\n \t\t}\n \t\tif (!shown_header) {\n \t\t\twt_status_print_header(\"Untracked files\",\n-\t\t\t\t\"use \\\"git add\\\" to add to commit\");\n+\t\t\t\t\"use \\\"git add\\\" on files to include for commit\");\n \t\t\tshown_header = 1;\n \t\t}\n \t\tcolor_printf(color(WT_STATUS_HEADER), \"#\\t\");\n@@ -292,7 +292,8 @@ void wt_status_print(struct wt_status *s)\n \tif (s->verbose && !s->is_initial)\n \t\twt_status_print_verbose(s);\n \tif (!s->commitable)\n-\t\tprintf(\"%s\\n\", s->amend ? \"# No changes\" : \"nothing to commit\");\n+\t\tprintf(\"%s (use \\\"git add\\\" include for commit)\\n\",\n+\t\t\ts->amend ? \"# No changes\" : \"Nothing to commit\");\n }\n \n int git_status_config(const char *k, const char *v)\n-- \n1.4.4.2.g72f5\n"},{"id":"297702","messageId":"458266D4.5050301@op5.se","threadId":"43300","inReplyTo":"20061215001350.GA26755@spearce.org","subject":"Re: [PATCH 1/2] Suggest use of 'git add' when 'nothing to commit' gets shown.","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2006-12-15T09:11:48Z","receivedAt":"2006-12-15T09:11:48Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Shawn O. Pearce wrote:\n>  else\n>  \tif [ -z \"$(git-ls-files)\" ]; then\n> -\t\techo >&2 Nothing to commit\n> +\t\techo >&2 \"Nothing to commit (use \\\"git add\\\" include for commit)\"\n\ns/git add include/git add to include/\n\n>  \t\texit 1\n>  \tfi\n>  \tPARENTS=\"\"\n> diff --git a/wt-status.c b/wt-status.c\n> index 6e9414d..f9ed54f 100644\n> --- a/wt-status.c\n> +++ b/wt-status.c\n> @@ -163,7 +163,7 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,\n>  \tint i;\n>  \tif (q->nr)\n>  \t\twt_status_print_header(\"Changed but not updated\",\n> -\t\t\t\t\"use git-add on files to include for commit\");\n> +\t\t\t\t\"use \\\"git add\\\" on files to include for commit\");\n\nHere it's \"on files\", whereas in other threads people have stated that \ngit add adds content, so perhaps\n\nuse \\\"git add file1 file2\\\" to include for commit\n\nwhich also gives a nice \"simplest-possible-usage\" message.\n\n\n>  \t\tif (!shown_header) {\n>  \t\t\twt_status_print_header(\"Untracked files\",\n> -\t\t\t\t\"use \\\"git add\\\" to add to commit\");\n> +\t\t\t\t\"use \\\"git add\\\" on files to include for commit\");\n\nSame here.\n\n\n>  \tif (!s->commitable)\n> -\t\tprintf(\"%s\\n\", s->amend ? \"# No changes\" : \"nothing to commit\");\n> +\t\tprintf(\"%s (use \\\"git add\\\" include for commit)\\n\",\n> +\t\t\ts->amend ? \"# No changes\" : \"Nothing to commit\");\n>  }\n\nThis is same as first one (missing \"to \" before \"include\").\n\nIt would probably be nice to use one and the same message everywhere though.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\n"},{"id":"295073","messageId":"20061215150632.GD17860@spearce.org","threadId":"43300","inReplyTo":"458266D4.5050301@op5.se","subject":"Re: [PATCH 1/2] Suggest use of 'git add' when 'nothing to commit' gets shown.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-12-15T15:06:32Z","receivedAt":"2006-12-15T15:06:32Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Andreas Ericsson <ae@op5.se> wrote:\n> Shawn O. Pearce wrote:\n> > else\n> > \tif [ -z \"$(git-ls-files)\" ]; then\n> >-\t\techo >&2 Nothing to commit\n> >+\t\techo >&2 \"Nothing to commit (use \\\"git add\\\" include for \n> >commit)\"\n> \n> s/git add include/git add to include/\n\nThanks!  I'm going to rewrite this patch series as I clearly fumbled\na few items, which you were kind enough to take the time to point\nout for me.\n\n> It would probably be nice to use one and the same message everywhere though.\n\nThat was my intent.  My fingers failed me somehow.  ;-)\n\n-- \n"}]}