{"thread":{"id":"15562","subject":"Teach git status to do \"git diff --name-status HEAD\"","startedAt":"2008-09-17T06:40:10Z","lastAt":"2008-09-17T17:31:46Z","messageCount":6,"participants":["Martin Langhoff","Michael J Gruber","Jakub Narebski","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"90898","messageId":"aba84270809162340n4ea3f5feqc71d01fa6e035b79@mail.gmail.com","threadId":"15562","inReplyTo":null,"subject":"Teach git status to do \"git diff --name-status HEAD\"","fromName":"Martin Langhoff","fromEmail":"martin@laptop.org","sentAt":"2008-09-17T06:40:10Z","receivedAt":"2008-09-17T06:40:10Z","isPatch":false,"sender":{"key":"martin@laptop.org","avatar":null},"body":"I just did\n\n$ git checkout -b mdl19-offlinetony\nA       README.offline\nM       lib/javascript.php\n    (...)\nA       lib/offline/offlinemoodle.user.js\n\nI *like* this \"brief status\" style - takes me back to my cvs days :-).\nPerusing the source I found show_local_changes() which in turn led me\nto trying `git diff --name-status HEAD`. Now, including 'HEAD' in an\nalias defined in git config is going to lead to trouble... :-/\n\nI might still make an alias to `git diff --name-status`. This would be\na great thing to have as git status \"--brief\" IMHO... :-)\n\ncheers,\n\n\n\nm\n-- \n martin@laptop.org -- School Server Architect\n - ask interesting questions\n - don't get distracted with shiny stuff - working code first\n - http://wiki.laptop.org/go/User:Martinlanghoff\n"},{"id":"90906","messageId":"48D0C2DF.7010308@drmicha.warpmail.net","threadId":"15562","inReplyTo":"aba84270809162340n4ea3f5feqc71d01fa6e035b79@mail.gmail.com","subject":"Re: Teach git status to do \"git diff --name-status HEAD\"","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2008-09-17T08:42:07Z","receivedAt":"2008-09-17T08:42:07Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Martin Langhoff venit, vidit, dixit 17.09.2008 08:40:\n> I just did\n> \n> $ git checkout -b mdl19-offlinetony\n> A       README.offline\n> M       lib/javascript.php\n>     (...)\n> A       lib/offline/offlinemoodle.user.js\n> \n> I *like* this \"brief status\" style - takes me back to my cvs days :-).\n> Perusing the source I found show_local_changes() which in turn led me\n> to trying `git diff --name-status HEAD`. Now, including 'HEAD' in an\n> alias defined in git config is going to lead to trouble... :-/\n\nNice!\nHEAD is default, no need to stick your HEAD into the config ;)\n\n> I might still make an alias to `git diff --name-status`. This would be\n> a great thing to have as git status \"--brief\" IMHO... :-)\n\ngit status also shows untracked files. I don't know how to tell diff to\nshow untracked files as well. --diff-filter=X doesn't do it.\n\nMichael\n"},{"id":"90920","messageId":"m3ej3jm3ux.fsf@localhost.localdomain","threadId":"15562","inReplyTo":"48D0C2DF.7010308@drmicha.warpmail.net","subject":"Re: Teach git status to do \"git diff --name-status HEAD\"","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-09-17T11:04:30Z","receivedAt":"2008-09-17T11:04:30Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> Martin Langhoff venit, vidit, dixit 17.09.2008 08:40:\n> > I just did\n> > \n> > $ git checkout -b mdl19-offlinetony\n> > A       README.offline\n> > M       lib/javascript.php\n> >     (...)\n> > A       lib/offline/offlinemoodle.user.js\n> > \n> > I *like* this \"brief status\" style - takes me back to my cvs days :-).\n> > Perusing the source I found show_local_changes() which in turn led me\n> > to trying `git diff --name-status HEAD`. Now, including 'HEAD' in an\n> > alias defined in git config is going to lead to trouble... :-/\n[...]\n> > I might still make an alias to `git diff --name-status`. This would be\n> > a great thing to have as git status \"--brief\" IMHO... :-)\n> \n> git status also shows untracked files. I don't know how to tell diff to\n> show untracked files as well. --diff-filter=X doesn't do it.\n\ngit-ls-files?\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"90924","messageId":"48D0E960.1060402@drmicha.warpmail.net","threadId":"15562","inReplyTo":"m3ej3jm3ux.fsf@localhost.localdomain","subject":"Re: Teach git status to do \"git diff --name-status HEAD\"","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2008-09-17T11:26:24Z","receivedAt":"2008-09-17T11:26:24Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Jakub Narebski venit, vidit, dixit 17.09.2008 13:04:\n> Michael J Gruber <git@drmicha.warpmail.net> writes:\n> \n>> Martin Langhoff venit, vidit, dixit 17.09.2008 08:40:\n>>> I just did\n>>>\n>>> $ git checkout -b mdl19-offlinetony\n>>> A       README.offline\n>>> M       lib/javascript.php\n>>>     (...)\n>>> A       lib/offline/offlinemoodle.user.js\n>>>\n>>> I *like* this \"brief status\" style - takes me back to my cvs days :-).\n>>> Perusing the source I found show_local_changes() which in turn led me\n>>> to trying `git diff --name-status HEAD`. Now, including 'HEAD' in an\n>>> alias defined in git config is going to lead to trouble... :-/\n> [...]\n>>> I might still make an alias to `git diff --name-status`. This would be\n>>> a great thing to have as git status \"--brief\" IMHO... :-)\n>> git status also shows untracked files. I don't know how to tell diff to\n>> show untracked files as well. --diff-filter=X doesn't do it.\n> \n> git-ls-files?\n\nYes, \"git ls-files -t -d -m -o --directory\" does something like\n\"otherscmyouknowwho status\". But it's plumbing, and the most obvious\nporcelain place for such functionality is \"git status\", followed by \"git\ndiff\".\nI do understand that \"git status\" is mostly \"git commit --dry-run\". But\nshouldn't we have something like Martin suggested readily available\n(including, optionally, untracked or ignored files).\n\nMichael\n"},{"id":"90950","messageId":"48D11F40.4000307@drmicha.warpmail.net","threadId":"15562","inReplyTo":"m3ej3jm3ux.fsf@localhost.localdomain","subject":"Mismatch between \"git status\" and \"git ls-files\" [was Re: Teach git status to do \"git diff --name-status HEAD\"]","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2008-09-17T15:16:16Z","receivedAt":"2008-09-17T15:16:16Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Following up on the discussion about \"git status\" versus\n\"youknowwhichscm status\" and suggestions to use \"git diff --name-status\"\nor \"git ls-files -d -m -o -t\" I made a little test case, see the\nattached script and output (git version 1.6.0.2.249.g97d7f). Observations:\n\n- \"git diff --name-status\" and \"git ls-files\" use very similar form,\neven the same status letters, but with completely different meaning for\nC, M, R. That is highly confusing (this what I mean by mismatch).\n\n- \"git diff --name-status\" has no way of showing ignored or untracked files\n\n- \"git status\" has no way of showing ignored files\n\n- \"git ls-files -d -m -o -t\" does not distinguish between ignored and\nuntracked (all is ?)\n\n- \"git ls-files\" is plumbing, one should not need plumbing to get status\noutput.\n\nI guess what's needed would be a porcelain that:\n\n- shows state in concise form (\"X filename\" lines like --name-status or\nls-files -t)\n- has options to show ignored and untracked file optionally\n\nTo me the most direct approach would be: If \"git diff\" compares with the\nwork-tree, teach it to include ignored resp. untracked files optionally.\n\nI guess I wouldn't care about the mismatch then. Are there specific\nreasons (other than evolution) for the conflicting status letters?\n\nMichael\n\n\nInitialized empty Git repository in /tmp/mjg/stats/.git/\nCreated initial commit 345adf7: files to be changed\n 10 files changed, 10 insertions(+), 0 deletions(-)\n create mode 100644 copied\n create mode 100644 gitmoved\n create mode 100644 gitremoved\n create mode 100644 modified\n create mode 100644 modifiedadded\n create mode 100644 moved\n create mode 100644 removed\n create mode 100644 typechanged\n create mode 100644 typechangedadded\n create mode 100644 unchanged\nrm 'gitremoved'\n### git status ###\n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#\tnew file:   added\n#\tnew file:   copiedadded\n#\trenamed:    gitmoved -> gitmoved2\n#\tdeleted:    gitremoved\n#\tmodified:   modifiedadded\n#\tmodified:   typechangedadded\n#\n# Changed but not updated:\n#   (use \"git add/rm <file>...\" to update what will be committed)\n#\n#\tmodified:   modified\n#\tdeleted:    moved\n#\tdeleted:    removed\n#\tmodified:   typechanged\n#\n# Untracked files:\n#   (use \"git add <file>...\" to include in what will be committed)\n#\n#\tcopiedonly\n#\tmoved2\n#\tuntracked\n### git diff ###\nM\tmodified\nD\tmoved\nD\tremoved\nM\ttypechanged\n### git diff HEAD ###\nA\tadded\nC100\tcopied\tcopiedadded\nR100\tgitmoved\tgitmoved2\nD\tgitremoved\nM\tmodified\nM\tmodifiedadded\nD\tmoved\nD\tremoved\nM\ttypechanged\nM\ttypechangedadded\n### git diff --cached HEAD ###\nA\tadded\nC100\tcopied\tcopiedadded\nR100\tgitmoved\tgitmoved2\nD\tgitremoved\nM\tmodifiedadded\nM\ttypechangedadded\n### git ls-files\n? copiedonly\n? ignored\n? moved2\n? untracked\nC modified\nR moved\nC moved\nR removed\nC removed\nC typechanged\n"},{"id":"90960","messageId":"20080917173146.GA29374@coredump.intra.peff.net","threadId":"15562","inReplyTo":"48D11F40.4000307@drmicha.warpmail.net","subject":"Re: Mismatch between \"git status\" and \"git ls-files\" [was Re: Teach git status to do \"git diff --name-status HEAD\"]","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-09-17T17:31:46Z","receivedAt":"2008-09-17T17:31:46Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Sep 17, 2008 at 05:16:16PM +0200, Michael J Gruber wrote:\n\n> Following up on the discussion about \"git status\" versus\n> \"youknowwhichscm status\" and suggestions to use \"git diff --name-status\"\n> or \"git ls-files -d -m -o -t\" I made a little test case, see the\n> attached script and output (git version 1.6.0.2.249.g97d7f).\n> Observations:\n\nYou could also do something like the patch below. It produces output\nlike this:\n\n  $ git status --terse\n  # On branch next\n  # Your branch is ahead of 'origin/next' by 1 commit.\n  #\n  # Changes to be committed:\n  M\twt-status.c\n  # Changed but not updated:\n  M\tbuiltin-commit.c\n  M\twt-status.c\n  M\twt-status.h\n  # Untracked files:\n  ? untracked_file\n  nothing added to commit but untracked files present (use \"git add\" to track)\n\nThough there are a few gotchas that make this unsuitable for applying:\n\n  - replacing the callbacks with DIFF_FORMAT_NAME_STATUS isn't quite\n    right. You lose the custom colorization, and it fails to set the \"we\n    have stuff to commit\" flag (note in my example that the \"nothing\n    added to commit\" isn't correct). Instead, we would need to do our\n    own NAME_STATUS output from the callback (possibly it could be\n    factored from diff.c into a general function).\n\n  - The format has lines that don't start with a '#', so it is not\n    suitable for a commit message template. So \"git commit --terse\"\n    should be disallowed.\n\n  - There might be other lines that can be stripped.\n\nI personally don't see any real advantage of this format over the\nexisting status format, so I won't push this patch any further. But if\nsomebody wants to pick it up and get it into shape, feel free.\n\n---\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 917f638..e75b508 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -52,6 +52,7 @@ 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 terse_status;\n static char *untracked_files_arg;\n /*\n  * The default commit message cleanup mode will remove the lines\n@@ -107,6 +108,8 @@ static struct option builtin_commit_options[] = {\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 \tOPT_STRING(0, \"cleanup\", &cleanup_arg, \"default\", \"how to strip spaces and #comments from message\"),\n+\tOPT_BOOLEAN(0, \"terse\", &terse_status,\n+\t\t\t\"use a more terse format to display status\"),\n \n \tOPT_END()\n };\n@@ -348,6 +351,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int\n \t\ts.amend = 1;\n \t\ts.reference = \"HEAD^1\";\n \t}\n+\ts.terse = terse_status;\n \ts.verbose = verbose;\n \ts.untracked = (show_untracked_files == SHOW_ALL_UNTRACKED_FILES);\n \ts.index_file = index_file;\ndiff --git a/wt-status.c b/wt-status.c\nindex 7cf890f..fd3c2d5 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -87,8 +87,10 @@ static void wt_status_print_untracked_header(struct wt_status *s)\n {\n \tconst char *c = color(WT_STATUS_HEADER);\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+\tif (!s->terse) {\n+\t\tcolor_fprintf_ln(s->fp, c, \"#   (use \\\"git add <file>...\\\" to include in what will be committed)\");\n+\t\tcolor_fprintf_ln(s->fp, c, \"#\");\n+\t}\n }\n \n static void wt_status_print_trailer(struct wt_status *s)\n@@ -213,9 +215,16 @@ static void wt_status_print_updated(struct wt_status *s)\n \tstruct rev_info rev;\n \tinit_revisions(&rev, NULL);\n \tsetup_revisions(0, NULL, &rev, s->reference);\n-\trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n-\trev.diffopt.format_callback = wt_status_print_updated_cb;\n-\trev.diffopt.format_callback_data = s;\n+\tif (s->terse) {\n+\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER),\n+\t\t\t\t\"# Changes to be committed:\");\n+\t\trev.diffopt.output_format = DIFF_FORMAT_NAME_STATUS;\n+\t}\n+\telse {\n+\t\trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n+\t\trev.diffopt.format_callback = wt_status_print_updated_cb;\n+\t\trev.diffopt.format_callback_data = s;\n+\t}\n \trev.diffopt.detect_rename = 1;\n \trev.diffopt.rename_limit = 200;\n \trev.diffopt.break_opt = 0;\n@@ -227,9 +236,16 @@ static void wt_status_print_changed(struct wt_status *s)\n \tstruct rev_info rev;\n \tinit_revisions(&rev, \"\");\n \tsetup_revisions(0, NULL, &rev, NULL);\n-\trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n-\trev.diffopt.format_callback = wt_status_print_changed_cb;\n-\trev.diffopt.format_callback_data = s;\n+\tif (s->terse) {\n+\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER),\n+\t\t\t\t\"# Changed but not updated:\");\n+\t\trev.diffopt.output_format = DIFF_FORMAT_NAME_STATUS;\n+\t}\n+\telse {\n+\t\trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n+\t\trev.diffopt.format_callback = wt_status_print_changed_cb;\n+\t\trev.diffopt.format_callback_data = s;\n+\t}\n \trun_diff_files(&rev, 0);\n }\n \n@@ -300,7 +316,10 @@ 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\tif (s->terse)\n+\t\t\tcolor_fprintf(s->fp, color(WT_STATUS_UNTRACKED), \"? \");\n+\t\telse\n+\t\t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER), \"#\\t\");\n \t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED), \"%s\",\n \t\t\t\tquote_path(ent->name, ent->len,\n \t\t\t\t\t&buf, s->prefix));\ndiff --git a/wt-status.h b/wt-status.h\nindex 78add09..40fd132 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -23,6 +23,7 @@ struct wt_status {\n \tchar *branch;\n \tconst char *reference;\n \tint verbose;\n+\tint terse;\n \tint amend;\n \tint untracked;\n \tint nowarn;\n"}]}