* [PATCH 0/6] "git commit --dry-run" updates @ 2009-08-15 10:06 Junio C Hamano 2009-08-15 10:06 ` [PATCH 1/6] Documentation/git-commit.txt: describe --dry-run Junio C Hamano 2009-08-17 10:01 ` [PATCH 0/6] "git commit --dry-run" updates Thomas Rast 0 siblings, 2 replies; 10+ messages in thread From: Junio C Hamano @ 2009-08-15 10:06 UTC (permalink / raw) To: git; +Cc: Jeff King The first patch describes --dry-run option, and stops mentioning the equivalence to "git status" in the documentation for "git commit". The second one fixes "git commit --dry-run -v", which did not show the diff text in color when asked with the configuration. The third and the fourth ones tentatively introduce "git stat". The former is an incomplete implementation that ignores the pathspec, and the latter adds pathspec limiting to it. In the final form before it goes to 'next', these two should probably be squashed. The fifth one introduces "git stat -s" (short output format) that is designed to be machine readable, especially with -z (NUL termination). The sixth one renames "git stat" to take over the traditional "git status" and obviously is a 1.7.0 material. The tests still have breakages that future updates to the sixth patch need to fix. t4030 still assumes "git status" is "git commit --dry-run" and expects it to take "-v" to produce diffs, for example. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/6] Documentation/git-commit.txt: describe --dry-run 2009-08-15 10:06 [PATCH 0/6] "git commit --dry-run" updates Junio C Hamano @ 2009-08-15 10:06 ` Junio C Hamano 2009-08-15 10:06 ` [PATCH 2/6] git commit --dry-run -v: show diff in color when asked Junio C Hamano 2009-08-17 10:01 ` [PATCH 0/6] "git commit --dry-run" updates Thomas Rast 1 sibling, 1 reply; 10+ messages in thread From: Junio C Hamano @ 2009-08-15 10:06 UTC (permalink / raw) To: git; +Cc: Jeff King Signed-off-by: Junio C Hamano <gitster@pobox.com> --- * The --dry-run option is already in 'next', but haven't been described. Documentation/git-commit.txt | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index d01ff5a..64f94cf 100644 --- a/Documentation/git-commit.txt +++ b/Documentation/git-commit.txt @@ -9,7 +9,7 @@ SYNOPSIS -------- [verse] 'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run] - [(-c | -C) <commit>] [-F <file> | -m <msg>] + [(-c | -C) <commit>] [-F <file> | -m <msg>] [--dry-run] [--allow-empty] [--no-verify] [-e] [--author=<author>] [--cleanup=<mode>] [--] [[-i | -o ]<file>...] @@ -42,10 +42,9 @@ The content to be added can be specified in several ways: by one which files should be part of the commit, before finalizing the operation. Currently, this is done by invoking 'git-add --interactive'. -The 'git-status' command can be used to obtain a +The `--dry-run` option can be used to obtain a summary of what is included by any of the above for the next -commit by giving the same set of parameters you would give to -this command. +commit by giving the same set of parameters (options and paths). If you make a commit and then find a mistake immediately after that, you can recover from it with 'git-reset'. @@ -70,6 +69,12 @@ OPTIONS Like '-C', but with '-c' the editor is invoked, so that the user can further edit the commit message. +--dry-run:: + Do not actually make a commit, but show the list of paths + with updates in the index, paths with changes in the work tree, + and paths that are untracked, similar to the one that is given + in the commit log editor. + -F <file>:: --file=<file>:: Take the commit message from the given file. Use '-' to -- 1.6.4.224.g3be84 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/6] git commit --dry-run -v: show diff in color when asked 2009-08-15 10:06 ` [PATCH 1/6] Documentation/git-commit.txt: describe --dry-run Junio C Hamano @ 2009-08-15 10:06 ` Junio C Hamano 2009-08-15 10:06 ` [PATCH 3/6] git stat: the beginning Junio C Hamano 0 siblings, 1 reply; 10+ messages in thread From: Junio C Hamano @ 2009-08-15 10:06 UTC (permalink / raw) To: git; +Cc: Jeff King The earlier implementation of --dry-run didn't duplicate the use of color "git status -v" set up for diff output. Signed-off-by: Junio C Hamano <gitster@pobox.com> --- * Fixes what is already queued in 'next'. builtin-commit.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/builtin-commit.c b/builtin-commit.c index 1c200eb..200ffda 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -979,9 +979,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix) argc = parse_and_validate_options(argc, argv, builtin_commit_usage, prefix, &s); - if (dry_run) + if (dry_run) { + if (diff_use_color_default == -1) + diff_use_color_default = git_use_color_default; return dry_run_commit(argc, argv, prefix, &s); - + } index_file = prepare_index(argc, argv, prefix, 0); /* Set up everything for writing the commit object. This includes -- 1.6.4.224.g3be84 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/6] git stat: the beginning 2009-08-15 10:06 ` [PATCH 2/6] git commit --dry-run -v: show diff in color when asked Junio C Hamano @ 2009-08-15 10:06 ` Junio C Hamano 2009-08-15 10:06 ` [PATCH 4/6] git stat: pathspec limits, unlike traditional "git status" Junio C Hamano 0 siblings, 1 reply; 10+ messages in thread From: Junio C Hamano @ 2009-08-15 10:06 UTC (permalink / raw) To: git; +Cc: Jeff King Tentatively add "git stat" as a new command. This does not munge the index with paths parameters before showing the status like "git status" does. In later rounds, we will take path parameters as pathspec to limit the output. Signed-off-by: Junio C Hamano <gitster@pobox.com> --- * The change since the version cooking in 'pu' is that the long format honors the color (both "status" colors and "diff" colors). Makefile | 1 + builtin-commit.c | 64 +++++++++++++++++++++++++++++++++++++++++++++-------- builtin.h | 1 + git.c | 1 + wt-status.c | 23 +++++++++++------- wt-status.h | 1 + 6 files changed, 72 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index daf4296..39dd334 100644 --- a/Makefile +++ b/Makefile @@ -378,6 +378,7 @@ BUILT_INS += git-init$X BUILT_INS += git-merge-subtree$X BUILT_INS += git-peek-remote$X BUILT_INS += git-repo-config$X +BUILT_INS += git-stat$X BUILT_INS += git-show$X BUILT_INS += git-stage$X BUILT_INS += git-status$X diff --git a/builtin-commit.c b/builtin-commit.c index 200ffda..0ef7c8f 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -24,6 +24,7 @@ #include "string-list.h" #include "rerere.h" #include "unpack-trees.h" +#include "quote.h" static const char * const builtin_commit_usage[] = { "git commit [options] [--] <filepattern>...", @@ -35,6 +36,11 @@ static const char * const builtin_status_usage[] = { NULL }; +static const char * const builtin_stat_usage[] = { + "git stat [options]", + NULL +}; + static unsigned char head_sha1[20], merge_head_sha1[20]; static char *use_message_buffer; static const char commit_editmsg[] = "COMMIT_EDITMSG"; @@ -691,6 +697,21 @@ static const char *find_author_by_nickname(const char *name) die("No existing author found with '%s'", name); } + +static void handle_untracked_files_arg(struct wt_status *s) +{ + if (!untracked_files_arg) + ; /* default already initialized */ + else if (!strcmp(untracked_files_arg, "no")) + s->show_untracked_files = SHOW_NO_UNTRACKED_FILES; + else if (!strcmp(untracked_files_arg, "normal")) + s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES; + else if (!strcmp(untracked_files_arg, "all")) + s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES; + else + die("Invalid untracked files mode '%s'", untracked_files_arg); +} + static int parse_and_validate_options(int argc, const char *argv[], const char * const usage[], const char *prefix, @@ -794,16 +815,7 @@ static int parse_and_validate_options(int argc, const char *argv[], else die("Invalid cleanup mode %s", cleanup_arg); - if (!untracked_files_arg) - ; /* default already initialized */ - else if (!strcmp(untracked_files_arg, "no")) - s->show_untracked_files = SHOW_NO_UNTRACKED_FILES; - else if (!strcmp(untracked_files_arg, "normal")) - s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES; - else if (!strcmp(untracked_files_arg, "all")) - s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES; - else - die("Invalid untracked files mode '%s'", untracked_files_arg); + handle_untracked_files_arg(s); if (all && argc > 0) die("Paths with -a does not make sense."); @@ -886,6 +898,38 @@ static int git_status_config(const char *k, const char *v, void *cb) return git_diff_ui_config(k, v, NULL); } +int cmd_stat(int argc, const char **argv, const char *prefix) +{ + struct wt_status s; + unsigned char sha1[20]; + static struct option builtin_stat_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_END(), + }; + + wt_status_prepare(&s); + git_config(git_status_config, &s); + argc = parse_options(argc, argv, prefix, + builtin_stat_options, + builtin_stat_usage, 0); + handle_untracked_files_arg(&s); + + read_cache(); + refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED); + s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0; + wt_status_collect(&s); + + if (s.use_color == -1) + s.use_color = git_use_color_default; + if (diff_use_color_default == -1) + diff_use_color_default = git_use_color_default; + wt_status_print_body(&s); + return 0; +} + int cmd_status(int argc, const char **argv, const char *prefix) { struct wt_status s; diff --git a/builtin.h b/builtin.h index 20427d2..eeaf0b6 100644 --- a/builtin.h +++ b/builtin.h @@ -95,6 +95,7 @@ extern int cmd_send_pack(int argc, const char **argv, const char *prefix); extern int cmd_shortlog(int argc, const char **argv, const char *prefix); extern int cmd_show(int argc, const char **argv, const char *prefix); extern int cmd_show_branch(int argc, const char **argv, const char *prefix); +extern int cmd_stat(int argc, const char **argv, const char *prefix); extern int cmd_status(int argc, const char **argv, const char *prefix); extern int cmd_stripspace(int argc, const char **argv, const char *prefix); extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix); diff --git a/git.c b/git.c index 807d875..de7fcf6 100644 --- a/git.c +++ b/git.c @@ -350,6 +350,7 @@ static void handle_internal_command(int argc, const char **argv) { "shortlog", cmd_shortlog, USE_PAGER }, { "show-branch", cmd_show_branch, RUN_SETUP }, { "show", cmd_show, RUN_SETUP | USE_PAGER }, + { "stat", cmd_stat, RUN_SETUP | NEED_WORK_TREE }, { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE }, { "stripspace", cmd_stripspace }, { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP }, diff --git a/wt-status.c b/wt-status.c index 63598ce..c887a90 100644 --- a/wt-status.c +++ b/wt-status.c @@ -531,6 +531,19 @@ static void wt_status_print_tracking(struct wt_status *s) color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#"); } +void wt_status_print_body(struct wt_status *s) +{ + wt_status_print_unmerged(s); + wt_status_print_updated(s); + wt_status_print_changed(s); + if (s->submodule_summary) + wt_status_print_submodule_summary(s); + if (s->show_untracked_files) + wt_status_print_untracked(s); + else if (s->commitable) + fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n"); +} + void wt_status_print(struct wt_status *s) { unsigned char sha1[20]; @@ -561,15 +574,7 @@ void wt_status_print(struct wt_status *s) color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#"); } - wt_status_print_unmerged(s); - wt_status_print_updated(s); - wt_status_print_changed(s); - if (s->submodule_summary) - wt_status_print_submodule_summary(s); - if (s->show_untracked_files) - wt_status_print_untracked(s); - else if (s->commitable) - fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n"); + wt_status_print_body(s); if (s->verbose) wt_status_print_verbose(s); diff --git a/wt-status.h b/wt-status.h index a0e7517..ab52ce1 100644 --- a/wt-status.h +++ b/wt-status.h @@ -54,5 +54,6 @@ struct wt_status { void wt_status_prepare(struct wt_status *s); void wt_status_print(struct wt_status *s); void wt_status_collect(struct wt_status *s); +void wt_status_print_body(struct wt_status *s); #endif /* STATUS_H */ -- 1.6.4.224.g3be84 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/6] git stat: pathspec limits, unlike traditional "git status" 2009-08-15 10:06 ` [PATCH 3/6] git stat: the beginning Junio C Hamano @ 2009-08-15 10:06 ` Junio C Hamano 2009-08-15 10:06 ` [PATCH 5/6] git stat -s: short status output Junio C Hamano 0 siblings, 1 reply; 10+ messages in thread From: Junio C Hamano @ 2009-08-15 10:06 UTC (permalink / raw) To: git; +Cc: Jeff King The "git stat" command is not "preview of commit with the same arguments"; the path parameters are not paths to be added to the pristine index (aka "--only" option), but are taken as pathspecs to limit the output. Signed-off-by: Junio C Hamano <gitster@pobox.com> --- * Unchanged since what has been queued in 'pu'. This should probably be squashed to the previous one in the final form after review. builtin-commit.c | 3 +++ wt-status.c | 6 ++++++ wt-status.h | 1 + 3 files changed, 10 insertions(+), 0 deletions(-) diff --git a/builtin-commit.c b/builtin-commit.c index 0ef7c8f..64ae45f 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -917,6 +917,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix) builtin_stat_usage, 0); handle_untracked_files_arg(&s); + if (*argv) + s.pathspec = get_pathspec(prefix, argv); + read_cache(); refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED); s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0; diff --git a/wt-status.c b/wt-status.c index c887a90..11db07e 100644 --- a/wt-status.c +++ b/wt-status.c @@ -269,6 +269,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s) rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = wt_status_collect_changed_cb; rev.diffopt.format_callback_data = s; + rev.prune_data = s->pathspec; run_diff_files(&rev, 0); } @@ -285,6 +286,7 @@ static void wt_status_collect_changes_index(struct wt_status *s) rev.diffopt.detect_rename = 1; rev.diffopt.rename_limit = 200; rev.diffopt.break_opt = 0; + rev.prune_data = s->pathspec; run_diff_index(&rev, 1); } @@ -297,6 +299,8 @@ static void wt_status_collect_changes_initial(struct wt_status *s) struct wt_status_change_data *d; struct cache_entry *ce = active_cache[i]; + if (!ce_path_match(ce, s->pathspec)) + continue; it = string_list_insert(ce->name, &s->change); d = it->util; if (!d) { @@ -330,6 +334,8 @@ static void wt_status_collect_untracked(struct wt_status *s) struct dir_entry *ent = dir.entries[i]; if (!cache_name_is_other(ent->name, ent->len)) continue; + if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL)) + continue; s->workdir_untracked = 1; string_list_insert(ent->name, &s->untracked); } diff --git a/wt-status.h b/wt-status.h index ab52ce1..4bc1a59 100644 --- a/wt-status.h +++ b/wt-status.h @@ -31,6 +31,7 @@ struct wt_status { int is_initial; char *branch; const char *reference; + const char **pathspec; int verbose; int amend; int nowarn; -- 1.6.4.224.g3be84 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/6] git stat -s: short status output 2009-08-15 10:06 ` [PATCH 4/6] git stat: pathspec limits, unlike traditional "git status" Junio C Hamano @ 2009-08-15 10:06 ` Junio C Hamano 2009-08-15 10:06 ` [PATCH 6/6] git status: not "commit --dry-run" anymore Junio C Hamano 0 siblings, 1 reply; 10+ messages in thread From: Junio C Hamano @ 2009-08-15 10:06 UTC (permalink / raw) To: git; +Cc: Jeff King Give -s(hort) option to "git stat" that shows the status of paths in a more concise way. XY PATH1 -> PATH2 format to be more machine readable than output from "git status", which is about previewing of "git commit" with the same arguments. PATH1 is the path in the HEAD, and " -> PATH2" part is shown only when PATH1 corresponds to a different path in the index/worktree. For unmerged entries, X shows the status of stage #2 (i.e. ours) and Y shows the status of stage #3 (i.e. theirs). For entries that do not have conflicts, X shows the status of the index, and Y shows the status of the work tree. For untracked paths, XY are "??". X Y Meaning ------------------------------------------------- [MD] not updated M [ MD] updated in index A [ MD] added to index D [ MD] deleted from index R [ MD] renamed in index C [ MD] copied in index [MARC] index and work tree matches [ MARC] M work tree changed since index [ MARC] D deleted in work tree D D unmerged, both deleted A U unmerged, added by us U D unmerged, deleted by them U A unmerged, added by them D U unmerged, deleted by us A A unmerged, both added U U unmerged, both modified ? ? untracked When given -z option, the records are terminated by NUL characters for better machine readability. Because the traditional long format is designed for human consumption, NUL termination does not make sense. For this reason, -z option implies -s (short output). Signed-off-by: Junio C Hamano <gitster@pobox.com> --- * Unlike what was in 'pu', -z now implies -s. I do not think the machine readble -s format should use color, but I _could_ be talked into coloring the output when -z is not used. builtin-commit.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 103 insertions(+), 5 deletions(-) diff --git a/builtin-commit.c b/builtin-commit.c index 64ae45f..6d9bd84 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -898,11 +898,86 @@ static int git_status_config(const char *k, const char *v, void *cb) return git_diff_ui_config(k, v, NULL); } +#define quote_path quote_path_relative + +static void short_unmerged(int null_termination, struct string_list_item *it, + struct wt_status *s) +{ + struct wt_status_change_data *d = it->util; + const char *how = "??"; + + switch (d->stagemask) { + case 1: how = "DD"; break; /* both deleted */ + case 2: how = "AU"; break; /* added by us */ + case 3: how = "UD"; break; /* deleted by them */ + case 4: how = "UA"; break; /* added by them */ + case 5: how = "DU"; break; /* deleted by us */ + case 6: how = "AA"; break; /* both added */ + case 7: how = "UU"; break; /* both modified */ + } + printf("%s ", how); + if (null_termination) { + fprintf(stdout, "%s%c", it->string, 0); + } else { + struct strbuf onebuf = STRBUF_INIT; + const char *one; + one = quote_path(it->string, -1, &onebuf, s->prefix); + printf("%s\n", one); + strbuf_release(&onebuf); + } +} + +static void short_status(int null_termination, struct string_list_item *it, + struct wt_status *s) +{ + struct wt_status_change_data *d = it->util; + + printf("%c%c ", + !d->index_status ? ' ' : d->index_status, + !d->worktree_status ? ' ' : d->worktree_status); + if (null_termination) { + fprintf(stdout, "%s%c", it->string, 0); + if (d->head_path) + fprintf(stdout, "%s%c", d->head_path, 0); + } else { + struct strbuf onebuf = STRBUF_INIT; + const char *one; + if (d->head_path) { + one = quote_path(d->head_path, -1, &onebuf, s->prefix); + printf("%s -> ", one); + strbuf_release(&onebuf); + } + one = quote_path(it->string, -1, &onebuf, s->prefix); + printf("%s\n", one); + strbuf_release(&onebuf); + } +} + +static void short_untracked(int null_termination, struct string_list_item *it, + struct wt_status *s) +{ + if (null_termination) { + fprintf(stdout, "?? %s%c", it->string, 0); + } else { + struct strbuf onebuf = STRBUF_INIT; + const char *one; + one = quote_path(it->string, -1, &onebuf, s->prefix); + printf("?? %s\n", one); + strbuf_release(&onebuf); + } +} + int cmd_stat(int argc, const char **argv, const char *prefix) { struct wt_status s; + static int null_termination, shortstatus; + int i; unsigned char sha1[20]; static struct option builtin_stat_options[] = { + OPT_BOOLEAN('s', "short", &shortstatus, + "show status concicely"), + OPT_BOOLEAN('z', "null", &null_termination, + "terminate entries with NUL"), { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no. (Default: all)", @@ -910,6 +985,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix) OPT_END(), }; + if (null_termination) + shortstatus = 1; + wt_status_prepare(&s); git_config(git_status_config, &s); argc = parse_options(argc, argv, prefix, @@ -925,11 +1003,31 @@ int cmd_stat(int argc, const char **argv, const char *prefix) s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0; wt_status_collect(&s); - if (s.use_color == -1) - s.use_color = git_use_color_default; - if (diff_use_color_default == -1) - diff_use_color_default = git_use_color_default; - wt_status_print_body(&s); + if (shortstatus) { + for (i = 0; i < s.change.nr; i++) { + struct wt_status_change_data *d; + struct string_list_item *it; + + it = &(s.change.items[i]); + d = it->util; + if (d->stagemask) + short_unmerged(null_termination, it, &s); + else + short_status(null_termination, it, &s); + } + for (i = 0; i < s.untracked.nr; i++) { + struct string_list_item *it; + + it = &(s.untracked.items[i]); + short_untracked(null_termination, it, &s); + } + } else { + if (s.use_color == -1) + s.use_color = git_use_color_default; + if (diff_use_color_default == -1) + diff_use_color_default = git_use_color_default; + wt_status_print_body(&s); + } return 0; } -- 1.6.4.224.g3be84 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/6] git status: not "commit --dry-run" anymore 2009-08-15 10:06 ` [PATCH 5/6] git stat -s: short status output Junio C Hamano @ 2009-08-15 10:06 ` Junio C Hamano 0 siblings, 0 replies; 10+ messages in thread From: Junio C Hamano @ 2009-08-15 10:06 UTC (permalink / raw) To: git; +Cc: Jeff King This removes tentative "git stat" and make it take over "git status". Signed-off-by: Junio C Hamano <gitster@pobox.com> --- Documentation/git-status.txt | 79 ++++++++++++++++++++++++++++++++++++----- builtin-commit.c | 29 ++------------- builtin.h | 1 - git.c | 1 - 4 files changed, 73 insertions(+), 37 deletions(-) diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt index 84f60f3..b5939d6 100644 --- a/Documentation/git-status.txt +++ b/Documentation/git-status.txt @@ -8,7 +8,7 @@ git-status - Show the working tree status SYNOPSIS -------- -'git status' <options>... +'git status' [<options>...] [--] [<pathspec>...] DESCRIPTION ----------- @@ -20,25 +20,85 @@ are what you _would_ commit by running `git commit`; the second and third are what you _could_ commit by running 'git-add' before running `git commit`. -The command takes the same set of options as 'git-commit'; it -shows what would be committed if the same options are given to -'git-commit'. - -If there is no path that is different between the index file and -the current HEAD commit (i.e., there is nothing to commit by running -`git commit`), the command exits with non-zero status. +OPTIONS +------- + +-s:: +--short:: + Give the output in the short-format. + +-u[<mode>]:: +--untracked-files[=<mode>]:: + Show untracked files (Default: 'all'). ++ +The mode parameter is optional, and is used to specify +the handling of untracked files. The possible options are: ++ +-- + - 'no' - Show no untracked files + - 'normal' - Shows untracked files and directories + - 'all' - Also shows individual files in untracked directories. +-- ++ +See linkgit:git-config[1] for configuration variable +used to change the default for when the option is not +specified. + +-z:: + Terminate entries with NUL, instead of LF. This implies `-s` + (short status) output format. OUTPUT ------ The output from this command is designed to be used as a commit template comment, and all the output lines are prefixed with '#'. +The default, long format, is designed to be human readable, +verbose and descriptive. They are subject to change in any time. The paths mentioned in the output, unlike many other git commands, are made relative to the current directory if you are working in a subdirectory (this is on purpose, to help cutting and pasting). See the status.relativePaths config option below. +In short-format, the status of each path is shown as + + XY PATH1 -> PATH2 + +where `PATH1` is the path in the `HEAD`, and ` -> PATH2` part is +shown only when `PATH1` corresponds to a different path in the +index/worktree (i.e. renamed). + +For unmerged entries, `X` shows the status of stage #2 (i.e. ours) and `Y` +shows the status of stage #3 (i.e. theirs). + +For entries that do not have conflicts, `X` shows the status of the index, +and `Y` shows the status of the work tree. For untracked paths, `XY` are +`??`. + + X Y Meaning + ------------------------------------------------- + [MD] not updated + M [ MD] updated in index + A [ MD] added to index + D [ MD] deleted from index + R [ MD] renamed in index + C [ MD] copied in index + [MARC] index and work tree matches + [ MARC] M work tree changed since index + [ MARC] D deleted in work tree + ------------------------------------------------- + D D unmerged, both deleted + A U unmerged, added by us + U D unmerged, deleted by them + U A unmerged, added by them + D U unmerged, deleted by us + A A unmerged, both added + U U unmerged, both modified + ------------------------------------------------- + ? ? untracked + ------------------------------------------------- + CONFIGURATION ------------- @@ -63,8 +123,7 @@ linkgit:gitignore[5] Author ------ -Written by Linus Torvalds <torvalds@osdl.org> and -Junio C Hamano <gitster@pobox.com>. +Written by Junio C Hamano <gitster@pobox.com>. Documentation -------------- diff --git a/builtin-commit.c b/builtin-commit.c index 6d9bd84..efbcd16 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -36,11 +36,6 @@ static const char * const builtin_status_usage[] = { NULL }; -static const char * const builtin_stat_usage[] = { - "git stat [options]", - NULL -}; - static unsigned char head_sha1[20], merge_head_sha1[20]; static char *use_message_buffer; static const char commit_editmsg[] = "COMMIT_EDITMSG"; @@ -967,13 +962,13 @@ static void short_untracked(int null_termination, struct string_list_item *it, } } -int cmd_stat(int argc, const char **argv, const char *prefix) +int cmd_status(int argc, const char **argv, const char *prefix) { struct wt_status s; static int null_termination, shortstatus; int i; unsigned char sha1[20]; - static struct option builtin_stat_options[] = { + static struct option builtin_status_options[] = { OPT_BOOLEAN('s', "short", &shortstatus, "show status concicely"), OPT_BOOLEAN('z', "null", &null_termination, @@ -991,8 +986,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix) wt_status_prepare(&s); git_config(git_status_config, &s); argc = parse_options(argc, argv, prefix, - builtin_stat_options, - builtin_stat_usage, 0); + builtin_status_options, + builtin_status_usage, 0); handle_untracked_files_arg(&s); if (*argv) @@ -1031,22 +1026,6 @@ int cmd_stat(int argc, const char **argv, const char *prefix) return 0; } -int cmd_status(int argc, const char **argv, const char *prefix) -{ - struct wt_status s; - - wt_status_prepare(&s); - git_config(git_status_config, &s); - if (s.use_color == -1) - s.use_color = git_use_color_default; - if (diff_use_color_default == -1) - diff_use_color_default = git_use_color_default; - - argc = parse_and_validate_options(argc, argv, builtin_status_usage, - prefix, &s); - return dry_run_commit(argc, argv, prefix, &s); -} - static void print_summary(const char *prefix, const unsigned char *sha1) { struct rev_info rev; diff --git a/builtin.h b/builtin.h index eeaf0b6..20427d2 100644 --- a/builtin.h +++ b/builtin.h @@ -95,7 +95,6 @@ extern int cmd_send_pack(int argc, const char **argv, const char *prefix); extern int cmd_shortlog(int argc, const char **argv, const char *prefix); extern int cmd_show(int argc, const char **argv, const char *prefix); extern int cmd_show_branch(int argc, const char **argv, const char *prefix); -extern int cmd_stat(int argc, const char **argv, const char *prefix); extern int cmd_status(int argc, const char **argv, const char *prefix); extern int cmd_stripspace(int argc, const char **argv, const char *prefix); extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix); diff --git a/git.c b/git.c index de7fcf6..807d875 100644 --- a/git.c +++ b/git.c @@ -350,7 +350,6 @@ static void handle_internal_command(int argc, const char **argv) { "shortlog", cmd_shortlog, USE_PAGER }, { "show-branch", cmd_show_branch, RUN_SETUP }, { "show", cmd_show, RUN_SETUP | USE_PAGER }, - { "stat", cmd_stat, RUN_SETUP | NEED_WORK_TREE }, { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE }, { "stripspace", cmd_stripspace }, { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP }, -- 1.6.4.224.g3be84 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 0/6] "git commit --dry-run" updates 2009-08-15 10:06 [PATCH 0/6] "git commit --dry-run" updates Junio C Hamano 2009-08-15 10:06 ` [PATCH 1/6] Documentation/git-commit.txt: describe --dry-run Junio C Hamano @ 2009-08-17 10:01 ` Thomas Rast 2009-08-17 15:57 ` Junio C Hamano 1 sibling, 1 reply; 10+ messages in thread From: Thomas Rast @ 2009-08-17 10:01 UTC (permalink / raw) To: Junio C Hamano; +Cc: git, Jeff King Junio C Hamano wrote: > The third and the fourth ones tentatively introduce "git stat". The > former is an incomplete implementation that ignores the pathspec, and the > latter adds pathspec limiting to it. In the final form before it goes to > 'next', these two should probably be squashed. If it's not too much work, it would be nice to somehow detect if -u can have any influence at all. For example, $ git status bar # Not currently on any branch. nothing to commit (use -u to show untracked files) is a bit misleading if 'bar' is tracked because adding a -u won't make any difference. -- Thomas Rast trast@{inf,student}.ethz.ch ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/6] "git commit --dry-run" updates 2009-08-17 10:01 ` [PATCH 0/6] "git commit --dry-run" updates Thomas Rast @ 2009-08-17 15:57 ` Junio C Hamano 2009-08-17 19:16 ` Thomas Rast 0 siblings, 1 reply; 10+ messages in thread From: Junio C Hamano @ 2009-08-17 15:57 UTC (permalink / raw) To: Thomas Rast; +Cc: git, Jeff King Thomas Rast <trast@student.ethz.ch> writes: > If it's not too much work, it would be nice to somehow detect if -u > can have any influence at all. For example, > > $ git status bar > # Not currently on any branch. > nothing to commit (use -u to show untracked files) > > is a bit misleading if 'bar' is tracked because adding a -u won't make > any difference. It is an issue shared with the original "git status". Running git init >file git add file git commit -m initial git status -uno will give the same "use -u to show" message. The thing is, "use -u to show" is because you told git not to check if there is any untracked file. Whoever added -uno wanted not to run the recursive read_directory() to find them. The message says "you told me not to check about untracked files, so I can not show you any, because I did not check; if you want, please use -u to tell me to check so that I can show them to you". It is not about "we know that there are untracked files but you told me not to show it, so I am not telling". We simply do not know at the point we give that message. In other words, conditional removal of that message is fundamentally incompatible with the use of -uno. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/6] "git commit --dry-run" updates 2009-08-17 15:57 ` Junio C Hamano @ 2009-08-17 19:16 ` Thomas Rast 0 siblings, 0 replies; 10+ messages in thread From: Thomas Rast @ 2009-08-17 19:16 UTC (permalink / raw) To: Junio C Hamano; +Cc: git, Jeff King Junio C Hamano wrote: > Thomas Rast <trast@student.ethz.ch> writes: > > > If it's not too much work, it would be nice to somehow detect if -u > > can have any influence at all. For example, > > > > $ git status bar > > # Not currently on any branch. > > nothing to commit (use -u to show untracked files) > > > > is a bit misleading if 'bar' is tracked because adding a -u won't make > > any difference. [...] > It is not about "we know that there are untracked files but you told me > not to show it, so I am not telling". We simply do not know at the point > we give that message. In other words, conditional removal of that message > is fundamentally incompatible with the use of -uno. Ok. I hoped there would be an easy way to know that all pathspecs exactly matched a tracked file, and thus no untracked files can possibly change the listing. But you convinced me that it doesn't fit into the current scheme, and it doesn't really matter... -- Thomas Rast trast@{inf,student}.ethz.ch ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-08-17 19:17 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-08-15 10:06 [PATCH 0/6] "git commit --dry-run" updates Junio C Hamano 2009-08-15 10:06 ` [PATCH 1/6] Documentation/git-commit.txt: describe --dry-run Junio C Hamano 2009-08-15 10:06 ` [PATCH 2/6] git commit --dry-run -v: show diff in color when asked Junio C Hamano 2009-08-15 10:06 ` [PATCH 3/6] git stat: the beginning Junio C Hamano 2009-08-15 10:06 ` [PATCH 4/6] git stat: pathspec limits, unlike traditional "git status" Junio C Hamano 2009-08-15 10:06 ` [PATCH 5/6] git stat -s: short status output Junio C Hamano 2009-08-15 10:06 ` [PATCH 6/6] git status: not "commit --dry-run" anymore Junio C Hamano 2009-08-17 10:01 ` [PATCH 0/6] "git commit --dry-run" updates Thomas Rast 2009-08-17 15:57 ` Junio C Hamano 2009-08-17 19:16 ` Thomas Rast
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox