* Teach git status to do "git diff --name-status HEAD" @ 2008-09-17 6:40 Martin Langhoff 2008-09-17 8:42 ` Michael J Gruber 0 siblings, 1 reply; 6+ messages in thread From: Martin Langhoff @ 2008-09-17 6:40 UTC (permalink / raw) To: Git Mailing List I just did $ git checkout -b mdl19-offlinetony A README.offline M lib/javascript.php (...) A lib/offline/offlinemoodle.user.js I *like* this "brief status" style - takes me back to my cvs days :-). Perusing the source I found show_local_changes() which in turn led me to trying `git diff --name-status HEAD`. Now, including 'HEAD' in an alias defined in git config is going to lead to trouble... :-/ I might still make an alias to `git diff --name-status`. This would be a great thing to have as git status "--brief" IMHO... :-) cheers, m -- martin@laptop.org -- School Server Architect - ask interesting questions - don't get distracted with shiny stuff - working code first - http://wiki.laptop.org/go/User:Martinlanghoff ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Teach git status to do "git diff --name-status HEAD" 2008-09-17 6:40 Teach git status to do "git diff --name-status HEAD" Martin Langhoff @ 2008-09-17 8:42 ` Michael J Gruber 2008-09-17 11:04 ` Jakub Narebski 0 siblings, 1 reply; 6+ messages in thread From: Michael J Gruber @ 2008-09-17 8:42 UTC (permalink / raw) To: Martin Langhoff; +Cc: Git Mailing List Martin Langhoff venit, vidit, dixit 17.09.2008 08:40: > I just did > > $ git checkout -b mdl19-offlinetony > A README.offline > M lib/javascript.php > (...) > A lib/offline/offlinemoodle.user.js > > I *like* this "brief status" style - takes me back to my cvs days :-). > Perusing the source I found show_local_changes() which in turn led me > to trying `git diff --name-status HEAD`. Now, including 'HEAD' in an > alias defined in git config is going to lead to trouble... :-/ Nice! HEAD is default, no need to stick your HEAD into the config ;) > I might still make an alias to `git diff --name-status`. This would be > a great thing to have as git status "--brief" IMHO... :-) git status also shows untracked files. I don't know how to tell diff to show untracked files as well. --diff-filter=X doesn't do it. Michael ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Teach git status to do "git diff --name-status HEAD" 2008-09-17 8:42 ` Michael J Gruber @ 2008-09-17 11:04 ` Jakub Narebski 2008-09-17 11:26 ` Michael J Gruber 2008-09-17 15:16 ` Mismatch between "git status" and "git ls-files" [was Re: Teach git status to do "git diff --name-status HEAD"] Michael J Gruber 0 siblings, 2 replies; 6+ messages in thread From: Jakub Narebski @ 2008-09-17 11:04 UTC (permalink / raw) To: Michael J Gruber; +Cc: Martin Langhoff, Git Mailing List Michael J Gruber <git@drmicha.warpmail.net> writes: > Martin Langhoff venit, vidit, dixit 17.09.2008 08:40: > > I just did > > > > $ git checkout -b mdl19-offlinetony > > A README.offline > > M lib/javascript.php > > (...) > > A lib/offline/offlinemoodle.user.js > > > > I *like* this "brief status" style - takes me back to my cvs days :-). > > Perusing the source I found show_local_changes() which in turn led me > > to trying `git diff --name-status HEAD`. Now, including 'HEAD' in an > > alias defined in git config is going to lead to trouble... :-/ [...] > > I might still make an alias to `git diff --name-status`. This would be > > a great thing to have as git status "--brief" IMHO... :-) > > git status also shows untracked files. I don't know how to tell diff to > show untracked files as well. --diff-filter=X doesn't do it. git-ls-files? -- Jakub Narebski Poland ShadeHawk on #git ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Teach git status to do "git diff --name-status HEAD" 2008-09-17 11:04 ` Jakub Narebski @ 2008-09-17 11:26 ` Michael J Gruber 2008-09-17 15:16 ` Mismatch between "git status" and "git ls-files" [was Re: Teach git status to do "git diff --name-status HEAD"] Michael J Gruber 1 sibling, 0 replies; 6+ messages in thread From: Michael J Gruber @ 2008-09-17 11:26 UTC (permalink / raw) To: Jakub Narebski; +Cc: Martin Langhoff, Git Mailing List Jakub Narebski venit, vidit, dixit 17.09.2008 13:04: > Michael J Gruber <git@drmicha.warpmail.net> writes: > >> Martin Langhoff venit, vidit, dixit 17.09.2008 08:40: >>> I just did >>> >>> $ git checkout -b mdl19-offlinetony >>> A README.offline >>> M lib/javascript.php >>> (...) >>> A lib/offline/offlinemoodle.user.js >>> >>> I *like* this "brief status" style - takes me back to my cvs days :-). >>> Perusing the source I found show_local_changes() which in turn led me >>> to trying `git diff --name-status HEAD`. Now, including 'HEAD' in an >>> alias defined in git config is going to lead to trouble... :-/ > [...] >>> I might still make an alias to `git diff --name-status`. This would be >>> a great thing to have as git status "--brief" IMHO... :-) >> git status also shows untracked files. I don't know how to tell diff to >> show untracked files as well. --diff-filter=X doesn't do it. > > git-ls-files? Yes, "git ls-files -t -d -m -o --directory" does something like "otherscmyouknowwho status". But it's plumbing, and the most obvious porcelain place for such functionality is "git status", followed by "git diff". I do understand that "git status" is mostly "git commit --dry-run". But shouldn't we have something like Martin suggested readily available (including, optionally, untracked or ignored files). Michael ^ permalink raw reply [flat|nested] 6+ messages in thread
* Mismatch between "git status" and "git ls-files" [was Re: Teach git status to do "git diff --name-status HEAD"] 2008-09-17 11:04 ` Jakub Narebski 2008-09-17 11:26 ` Michael J Gruber @ 2008-09-17 15:16 ` Michael J Gruber 2008-09-17 17:31 ` Jeff King 1 sibling, 1 reply; 6+ messages in thread From: Michael J Gruber @ 2008-09-17 15:16 UTC (permalink / raw) To: Jakub Narebski; +Cc: Martin Langhoff, Git Mailing List [-- Attachment #1: Type: text/plain, Size: 1269 bytes --] Following up on the discussion about "git status" versus "youknowwhichscm status" and suggestions to use "git diff --name-status" or "git ls-files -d -m -o -t" I made a little test case, see the attached script and output (git version 1.6.0.2.249.g97d7f). Observations: - "git diff --name-status" and "git ls-files" use very similar form, even the same status letters, but with completely different meaning for C, M, R. That is highly confusing (this what I mean by mismatch). - "git diff --name-status" has no way of showing ignored or untracked files - "git status" has no way of showing ignored files - "git ls-files -d -m -o -t" does not distinguish between ignored and untracked (all is ?) - "git ls-files" is plumbing, one should not need plumbing to get status output. I guess what's needed would be a porcelain that: - shows state in concise form ("X filename" lines like --name-status or ls-files -t) - has options to show ignored and untracked file optionally To me the most direct approach would be: If "git diff" compares with the work-tree, teach it to include ignored resp. untracked files optionally. I guess I wouldn't care about the mismatch then. Are there specific reasons (other than evolution) for the conflicting status letters? Michael [-- Attachment #2: stats.out --] [-- Type: text/plain, Size: 1559 bytes --] Initialized empty Git repository in /tmp/mjg/stats/.git/ Created initial commit 345adf7: files to be changed 10 files changed, 10 insertions(+), 0 deletions(-) create mode 100644 copied create mode 100644 gitmoved create mode 100644 gitremoved create mode 100644 modified create mode 100644 modifiedadded create mode 100644 moved create mode 100644 removed create mode 100644 typechanged create mode 100644 typechangedadded create mode 100644 unchanged rm 'gitremoved' ### git status ### # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: added # new file: copiedadded # renamed: gitmoved -> gitmoved2 # deleted: gitremoved # modified: modifiedadded # modified: typechangedadded # # Changed but not updated: # (use "git add/rm <file>..." to update what will be committed) # # modified: modified # deleted: moved # deleted: removed # modified: typechanged # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # copiedonly # moved2 # untracked ### git diff ### M modified D moved D removed M typechanged ### git diff HEAD ### A added C100 copied copiedadded R100 gitmoved gitmoved2 D gitremoved M modified M modifiedadded D moved D removed M typechanged M typechangedadded ### git diff --cached HEAD ### A added C100 copied copiedadded R100 gitmoved gitmoved2 D gitremoved M modifiedadded M typechangedadded ### git ls-files ? copiedonly ? ignored ? moved2 ? untracked C modified R moved C moved R removed C removed C typechanged [-- Attachment #3: stats.sh --] [-- Type: application/x-shellscript, Size: 943 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Mismatch between "git status" and "git ls-files" [was Re: Teach git status to do "git diff --name-status HEAD"] 2008-09-17 15:16 ` Mismatch between "git status" and "git ls-files" [was Re: Teach git status to do "git diff --name-status HEAD"] Michael J Gruber @ 2008-09-17 17:31 ` Jeff King 0 siblings, 0 replies; 6+ messages in thread From: Jeff King @ 2008-09-17 17:31 UTC (permalink / raw) To: Michael J Gruber; +Cc: Jakub Narebski, Martin Langhoff, Git Mailing List On Wed, Sep 17, 2008 at 05:16:16PM +0200, Michael J Gruber wrote: > Following up on the discussion about "git status" versus > "youknowwhichscm status" and suggestions to use "git diff --name-status" > or "git ls-files -d -m -o -t" I made a little test case, see the > attached script and output (git version 1.6.0.2.249.g97d7f). > Observations: You could also do something like the patch below. It produces output like this: $ git status --terse # On branch next # Your branch is ahead of 'origin/next' by 1 commit. # # Changes to be committed: M wt-status.c # Changed but not updated: M builtin-commit.c M wt-status.c M wt-status.h # Untracked files: ? untracked_file nothing added to commit but untracked files present (use "git add" to track) Though there are a few gotchas that make this unsuitable for applying: - replacing the callbacks with DIFF_FORMAT_NAME_STATUS isn't quite right. You lose the custom colorization, and it fails to set the "we have stuff to commit" flag (note in my example that the "nothing added to commit" isn't correct). Instead, we would need to do our own NAME_STATUS output from the callback (possibly it could be factored from diff.c into a general function). - The format has lines that don't start with a '#', so it is not suitable for a commit message template. So "git commit --terse" should be disallowed. - There might be other lines that can be stripped. I personally don't see any real advantage of this format over the existing status format, so I won't push this patch any further. But if somebody wants to pick it up and get it into shape, feel free. --- diff --git a/builtin-commit.c b/builtin-commit.c index 917f638..e75b508 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -52,6 +52,7 @@ static char *edit_message, *use_message; static char *author_name, *author_email, *author_date; static int all, edit_flag, also, interactive, only, amend, signoff; static int quiet, verbose, no_verify, allow_empty; +static int terse_status; static char *untracked_files_arg; /* * The default commit message cleanup mode will remove the lines @@ -107,6 +108,8 @@ static struct option builtin_commit_options[] = { { 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" }, OPT_BOOLEAN(0, "allow-empty", &allow_empty, "ok to record an empty change"), OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"), + OPT_BOOLEAN(0, "terse", &terse_status, + "use a more terse format to display status"), OPT_END() }; @@ -348,6 +351,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int s.amend = 1; s.reference = "HEAD^1"; } + s.terse = terse_status; s.verbose = verbose; s.untracked = (show_untracked_files == SHOW_ALL_UNTRACKED_FILES); s.index_file = index_file; diff --git a/wt-status.c b/wt-status.c index 7cf890f..fd3c2d5 100644 --- a/wt-status.c +++ b/wt-status.c @@ -87,8 +87,10 @@ static void wt_status_print_untracked_header(struct wt_status *s) { const char *c = color(WT_STATUS_HEADER); color_fprintf_ln(s->fp, c, "# Untracked files:"); - color_fprintf_ln(s->fp, c, "# (use \"git add <file>...\" to include in what will be committed)"); - color_fprintf_ln(s->fp, c, "#"); + if (!s->terse) { + color_fprintf_ln(s->fp, c, "# (use \"git add <file>...\" to include in what will be committed)"); + color_fprintf_ln(s->fp, c, "#"); + } } static void wt_status_print_trailer(struct wt_status *s) @@ -213,9 +215,16 @@ static void wt_status_print_updated(struct wt_status *s) struct rev_info rev; init_revisions(&rev, NULL); setup_revisions(0, NULL, &rev, s->reference); - rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK; - rev.diffopt.format_callback = wt_status_print_updated_cb; - rev.diffopt.format_callback_data = s; + if (s->terse) { + color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), + "# Changes to be committed:"); + rev.diffopt.output_format = DIFF_FORMAT_NAME_STATUS; + } + else { + rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK; + rev.diffopt.format_callback = wt_status_print_updated_cb; + rev.diffopt.format_callback_data = s; + } rev.diffopt.detect_rename = 1; rev.diffopt.rename_limit = 200; rev.diffopt.break_opt = 0; @@ -227,9 +236,16 @@ static void wt_status_print_changed(struct wt_status *s) struct rev_info rev; init_revisions(&rev, ""); setup_revisions(0, NULL, &rev, NULL); - rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK; - rev.diffopt.format_callback = wt_status_print_changed_cb; - rev.diffopt.format_callback_data = s; + if (s->terse) { + color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), + "# Changed but not updated:"); + rev.diffopt.output_format = DIFF_FORMAT_NAME_STATUS; + } + else { + rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK; + rev.diffopt.format_callback = wt_status_print_changed_cb; + rev.diffopt.format_callback_data = s; + } run_diff_files(&rev, 0); } @@ -300,7 +316,10 @@ static void wt_status_print_untracked(struct wt_status *s) wt_status_print_untracked_header(s); shown_header = 1; } - color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t"); + if (s->terse) + color_fprintf(s->fp, color(WT_STATUS_UNTRACKED), "? "); + else + color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t"); color_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED), "%s", quote_path(ent->name, ent->len, &buf, s->prefix)); diff --git a/wt-status.h b/wt-status.h index 78add09..40fd132 100644 --- a/wt-status.h +++ b/wt-status.h @@ -23,6 +23,7 @@ struct wt_status { char *branch; const char *reference; int verbose; + int terse; int amend; int untracked; int nowarn; ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-09-17 17:33 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-09-17 6:40 Teach git status to do "git diff --name-status HEAD" Martin Langhoff 2008-09-17 8:42 ` Michael J Gruber 2008-09-17 11:04 ` Jakub Narebski 2008-09-17 11:26 ` Michael J Gruber 2008-09-17 15:16 ` Mismatch between "git status" and "git ls-files" [was Re: Teach git status to do "git diff --name-status HEAD"] Michael J Gruber 2008-09-17 17:31 ` Jeff King
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).