git status: not "commit --dry-run" anymore

This removes tentative "git stat" and make it take over "git status".

There are some tests that expect "git status" to exit with non-zero status
when there is something staged.  Some tests expect "git status path..." to
show the status for a partial commit.

For these, replace "git status" with "git commit --dry-run".  For the
ones that do not attempt a dry-run of a partial commit that check the
output from the command, check the output from "git status" as well, as
they should be identical.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano 2009-08-15 02:27:39 -07:00
Родитель 173e6c8852
Коммит 9e4b7ab652
9 изменённых файлов: 88 добавлений и 49 удалений

Просмотреть файл

@ -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'.
OPTIONS
-------
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.
-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
--------------

Просмотреть файл

@ -378,7 +378,6 @@ 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

Просмотреть файл

@ -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";
@ -971,13 +966,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__VERBOSE(&verbose),
OPT_BOOLEAN('s', "short", &shortstatus,
"show status concicely"),
@ -996,8 +991,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)
@ -1039,22 +1034,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;

Просмотреть файл

@ -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);

1
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 },

Просмотреть файл

@ -69,7 +69,7 @@ test_expect_success 'status' '
cd test &&
git checkout b1 >/dev/null &&
# reports nothing to commit
test_must_fail git status
test_must_fail git commit --dry-run
) >actual &&
grep "have 1 and 1 different" actual
'

Просмотреть файл

@ -50,9 +50,11 @@ test_expect_success 'M/D conflict does not segfault' '
git rm foo &&
git commit -m delete &&
test_must_fail git merge master &&
test_must_fail git status > ../actual
) &&
test_cmp expect actual
test_must_fail git commit --dry-run >../actual &&
test_cmp ../expect ../actual &&
git status >../actual &&
test_cmp ../expect ../actual
)
'
test_done

Просмотреть файл

@ -19,8 +19,8 @@ test_expect_success 'status clean' '
git status |
grep "nothing to commit"
'
test_expect_success 'status -a clean' '
git status -a |
test_expect_success 'commit --dry-run -a clean' '
git commit --dry-run -a |
grep "nothing to commit"
'
test_expect_success 'rm submodule contents' '
@ -31,7 +31,7 @@ test_expect_success 'status clean (empty submodule dir)' '
grep "nothing to commit"
'
test_expect_success 'status -a clean (empty submodule dir)' '
git status -a |
git commit --dry-run -a |
grep "nothing to commit"
'

Просмотреть файл

@ -248,8 +248,8 @@ cat <<EOF >expect
# output
# untracked
EOF
test_expect_success 'status of partial commit excluding new file in index' '
git status dir1/modified >output &&
test_expect_success 'dry-run of partial commit excluding new file in index' '
git commit --dry-run dir1/modified >output &&
test_cmp expect output
'
@ -358,7 +358,9 @@ EOF
test_expect_success 'status submodule summary (clean submodule)' '
git commit -m "commit submodule" &&
git config status.submodulesummary 10 &&
test_must_fail git status >output &&
test_must_fail git commit --dry-run >output &&
test_cmp expect output &&
git status >output &&
test_cmp expect output
'
@ -391,9 +393,9 @@ cat >expect <<EOF
# output
# untracked
EOF
test_expect_success 'status submodule summary (--amend)' '
test_expect_success 'commit --dry-run submodule summary (--amend)' '
git config status.submodulesummary 10 &&
git status --amend >output &&
git commit --dry-run --amend >output &&
test_cmp expect output
'