From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: Piotr Krukowiecki <piotr.krukowiecki.news@gmail.com>,
Jay Soffian <jaysoffian@gmail.com>,
Jonathan Nieder <jrnieder@gmail.com>,
Philip Oakley <philipoakley@iee.org>,
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
William Swanson <swansontec@gmail.com>,
Ping Yin <pkufranky@gmail.com>,
Hilco Wijbenga <hilco.wijbenga@gmail.com>,
Miles Bader <miles@gnu.org>,
Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH v2 01/14] Add proper 'stage' command
Date: Mon, 14 Oct 2013 17:29:20 -0500 [thread overview]
Message-ID: <1381789769-9893-6-git-send-email-felipe.contreras@gmail.com> (raw)
In-Reply-To: <1381789769-9893-1-git-send-email-felipe.contreras@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
Documentation/git-stage.txt | 45 +++++++++++++++++++++++++----
Makefile | 2 +-
builtin.h | 1 +
builtin/stage.c | 52 ++++++++++++++++++++++++++++++++++
contrib/completion/git-completion.bash | 24 +++++++++++++++-
git.c | 2 +-
6 files changed, 118 insertions(+), 8 deletions(-)
create mode 100644 builtin/stage.c
diff --git a/Documentation/git-stage.txt b/Documentation/git-stage.txt
index ba3fe0d..318bf45 100644
--- a/Documentation/git-stage.txt
+++ b/Documentation/git-stage.txt
@@ -3,20 +3,55 @@ git-stage(1)
NAME
----
-git-stage - Add file contents to the staging area
+git-stage - manage the staging area
SYNOPSIS
--------
[verse]
-'git stage' args...
-
+'git stage' [options] [--] [<paths>...]
+'git stage add' [options] [--] [<paths>...]
+'git stage reset' [-q|--patch] [--] [<paths>...]
+'git stage diff' [options] [<commit>] [--] [<paths>...]
+'git stage rm' [options] [--] [<paths>...]
+'git stage apply' [options] [--] [<paths>...]
DESCRIPTION
-----------
-This is a synonym for linkgit:git-add[1]. Please refer to the
-documentation of that command.
+
+COMMANDS
+--------
+
+With no arguments, it's a synonym for linkgit:git-add[1].
+
+'add'::
+
+Adds file contents to the staging area. See linkgit:git-add[1].
+
+'reset'::
+
+Resets the staging area. See linkgit:git-reset[1].
+
+'diff'::
+
+View the changes you staged for the next commit. See linkgit:git-diff[1] --staged.
+
+'rm'::
+
+Remove files from the staging area only. See linkgit:git-rm[1] --staged.
+
+'apply'::
+
+Apply a patch to the staging area. See linkgit:git-rm[1] --staged.
+
+SEE ALSO
+--------
+linkgit:git-add[1]
+linkgit:git-reset[1]
+linkgit:git-diff[1]
+linkgit:git-rm[1]
+linkgit:git-apply[1]
GIT
---
diff --git a/Makefile b/Makefile
index 3588ca1..1f7ddf3 100644
--- a/Makefile
+++ b/Makefile
@@ -598,7 +598,6 @@ BUILT_INS += git-merge-subtree$X
BUILT_INS += git-peek-remote$X
BUILT_INS += git-repo-config$X
BUILT_INS += git-show$X
-BUILT_INS += git-stage$X
BUILT_INS += git-status$X
BUILT_INS += git-whatchanged$X
@@ -982,6 +981,7 @@ BUILTIN_OBJS += builtin/send-pack.o
BUILTIN_OBJS += builtin/shortlog.o
BUILTIN_OBJS += builtin/show-branch.o
BUILTIN_OBJS += builtin/show-ref.o
+BUILTIN_OBJS += builtin/stage.o
BUILTIN_OBJS += builtin/stripspace.o
BUILTIN_OBJS += builtin/symbolic-ref.o
BUILTIN_OBJS += builtin/tag.o
diff --git a/builtin.h b/builtin.h
index 8afa2de..baf3a0f 100644
--- a/builtin.h
+++ b/builtin.h
@@ -113,6 +113,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_stage(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/builtin/stage.c b/builtin/stage.c
new file mode 100644
index 0000000..3023d17
--- /dev/null
+++ b/builtin/stage.c
@@ -0,0 +1,52 @@
+/*
+ * 'git stage' builtin command
+ *
+ * Copyright (C) 2013 Felipe Contreras
+ */
+
+#include "builtin.h"
+#include "parse-options.h"
+
+static const char *const stage_usage[] = {
+ N_("git stage [options] [--] <paths>..."),
+ N_("git stage add [options] [--] <paths>..."),
+ N_("git stage reset [-q|--patch] [--] <paths>..."),
+ N_("git stage diff [options] [<commit]> [--] <paths>..."),
+ N_("git stage rm [options] [--] <paths>..."),
+ NULL
+};
+
+int cmd_stage(int argc, const char **argv, const char *prefix)
+{
+ struct option options[] = { OPT_END() };
+
+ argc = parse_options(argc, argv, prefix, options, stage_usage,
+ PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN | PARSE_OPT_KEEP_DASHDASH);
+
+ if (argc > 1) {
+ if (!strcmp(argv[1], "add"))
+ return cmd_add(argc - 1, argv + 1, prefix);
+ if (!strcmp(argv[1], "reset"))
+ return cmd_reset(argc - 1, argv + 1, prefix);
+ if (!strcmp(argv[1], "diff")) {
+ argv[0] = "diff";
+ argv[1] = "--staged";
+
+ return cmd_diff(argc, argv, prefix);
+ }
+ if (!strcmp(argv[1], "rm")) {
+ argv[0] = "rm";
+ argv[1] = "--cached";
+
+ return cmd_rm(argc, argv, prefix);
+ }
+ if (!strcmp(argv[1], "apply")) {
+ argv[0] = "apply";
+ argv[1] = "--cached";
+
+ return cmd_apply(argc, argv, prefix);
+ }
+ }
+
+ return cmd_add(argc, argv, prefix);
+}
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 5da920e..8cf26e2 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1691,7 +1691,29 @@ _git_send_email ()
_git_stage ()
{
- _git_add
+ __git_has_doubledash && return
+
+ local subcommands="add reset diff rm apply"
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
+ if [ -z "$subcommand" ]; then
+ __gitcomp "$subcommands"
+ return
+ fi
+
+ case "$subcommand" in
+ add)
+ _git_add;;
+ reset)
+ _git_reset;;
+ diff)
+ _git_diff;;
+ rm)
+ _git_rm;;
+ apply)
+ _git_apply;;
+ *)
+ _git_add;
+ esac
}
__git_config_get_set_variables ()
diff --git a/git.c b/git.c
index 2025f77..0e639aa 100644
--- a/git.c
+++ b/git.c
@@ -409,7 +409,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "show", cmd_show, RUN_SETUP },
{ "show-branch", cmd_show_branch, RUN_SETUP },
{ "show-ref", cmd_show_ref, RUN_SETUP },
- { "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE },
+ { "stage", cmd_stage, RUN_SETUP | NEED_WORK_TREE },
{ "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
{ "stripspace", cmd_stripspace },
{ "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
--
1.8.4-fc
next prev parent reply other threads:[~2013-10-14 22:36 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-14 22:29 [PATCH v2 14/14] completion: update 'git reset' new stage options Felipe Contreras
2013-10-14 22:29 ` [PATCH v2 04/14] grep: add --staged option Felipe Contreras
2013-10-14 22:29 ` [PATCH v2 07/14] stash: add --stage to pop and apply Felipe Contreras
2013-10-14 22:29 ` [PATCH v2 00/14] Officially start moving to the term 'staging area' Felipe Contreras
2013-10-14 22:51 ` Felipe Contreras
2013-10-17 19:50 ` Junio C Hamano
2013-10-17 21:50 ` Felipe Contreras
2013-10-18 9:46 ` Matthieu Moy
2013-10-18 10:26 ` John Szakmeister
2013-10-18 10:36 ` Felipe Contreras
2013-10-18 11:38 ` Max Horn
2013-10-18 23:28 ` Karsten Blees
2013-10-19 0:41 ` Felipe Contreras
2013-10-19 14:08 ` Philip Oakley
2013-10-24 0:57 ` Karsten Blees
2013-10-24 8:32 ` Andreas Krey
2013-10-24 23:19 ` Felipe Contreras
2013-10-14 22:29 ` [PATCH v2 10/14] apply: add --work, --no-work options Felipe Contreras
2013-10-14 22:29 ` Felipe Contreras [this message]
2013-10-14 23:06 ` [PATCH v2 01/14] Add proper 'stage' command Eric Sunshine
2013-10-14 23:15 ` Felipe Contreras
2013-10-14 22:29 ` [PATCH v2 09/14] apply: add --stage option Felipe Contreras
2013-10-14 22:29 ` [PATCH v2 03/14] diff: document --staged Felipe Contreras
2013-10-14 22:29 ` [PATCH v2 05/14] rm: add --staged option Felipe Contreras
2013-10-14 22:29 ` [PATCH v2 02/14] stage: add edit command Felipe Contreras
2013-10-14 22:29 ` [PATCH v2 13/14] reset: allow --keep with --stage Felipe Contreras
2013-10-14 22:29 ` [PATCH v2 12/14] reset: add --stage and --work options Felipe Contreras
2013-10-14 22:29 ` [PATCH v2 08/14] submodule: add --staged options Felipe Contreras
2013-10-14 22:29 ` [PATCH v2 11/14] completion: update " Felipe Contreras
2013-10-14 22:29 ` [PATCH v2 06/14] stash: add --stage option to save Felipe Contreras
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1381789769-9893-6-git-send-email-felipe.contreras@gmail.com \
--to=felipe.contreras@gmail.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=hilco.wijbenga@gmail.com \
--cc=jaysoffian@gmail.com \
--cc=jrnieder@gmail.com \
--cc=miles@gnu.org \
--cc=philipoakley@iee.org \
--cc=piotr.krukowiecki.news@gmail.com \
--cc=pkufranky@gmail.com \
--cc=swansontec@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).