@@ -9,14 +9,19 @@ git-stage - Add file contents to the staging area
SYNOPSIS
--------
[verse]
-'git stage' args...
+'git stage' [options] [--] [<paths>...]
DESCRIPTION
-----------
-This is a synonym for linkgit:git-add[1]. Please refer to the
-documentation of that command.
+The staging area is a location where changes are stored in preparation for a commit.
+
+This is a synonym for linkgit:git-add[1].
+
+SEE ALSO
+--------
+linkgit:git-add[1]
GIT
---
@@ -779,7 +779,6 @@ BUILT_INS += git-maintenance$X
BUILT_INS += git-merge-subtree$X
BUILT_INS += git-restore$X
BUILT_INS += git-show$X
-BUILT_INS += git-stage$X
BUILT_INS += git-status$X
BUILT_INS += git-switch$X
BUILT_INS += git-whatchanged$X
@@ -1153,6 +1152,7 @@ BUILTIN_OBJS += builtin/show-branch.o
BUILTIN_OBJS += builtin/show-index.o
BUILTIN_OBJS += builtin/show-ref.o
BUILTIN_OBJS += builtin/sparse-checkout.o
+BUILTIN_OBJS += builtin/stage.o
BUILTIN_OBJS += builtin/stash.o
BUILTIN_OBJS += builtin/stripspace.o
BUILTIN_OBJS += builtin/submodule--helper.o
@@ -218,6 +218,7 @@ int cmd_show(int argc, const char **argv, const char *prefix);
int cmd_show_branch(int argc, const char **argv, const char *prefix);
int cmd_show_index(int argc, const char **argv, const char *prefix);
int cmd_sparse_checkout(int argc, const char **argv, const char *prefix);
+int cmd_stage(int argc, const char **argv, const char *prefix);
int cmd_status(int argc, const char **argv, const char *prefix);
int cmd_stash(int argc, const char **argv, const char *prefix);
int cmd_stripspace(int argc, const char **argv, const char *prefix);
new file mode 100644
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2013-2021 Felipe Contreras
+ */
+
+#include "builtin.h"
+#include "parse-options.h"
+
+static const char *const stage_usage[] = {
+ N_("git stage [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);
+
+ return cmd_add(argc, argv, prefix);
+}
@@ -599,7 +599,7 @@ static struct cmd_struct commands[] = {
{ "show-index", cmd_show_index, RUN_SETUP_GENTLY },
{ "show-ref", cmd_show_ref, RUN_SETUP },
{ "sparse-checkout", cmd_sparse_checkout, RUN_SETUP | NEED_WORK_TREE },
- { "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE },
+ { "stage", cmd_stage, RUN_SETUP | NEED_WORK_TREE },
{ "stash", cmd_stash, RUN_SETUP | NEED_WORK_TREE },
{ "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
{ "stripspace", cmd_stripspace },
new file mode 100755
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Felipe Contreras
+#
+
+test_description='Tests of git stage'
+
+. ./test-lib.sh
+
+in_stage () {
+ test "$(git ls-files "$1")" == "$1"
+}
+
+test_expect_success 'basic' '
+ touch foo &&
+ git stage foo &&
+ in_stage foo
+'
+
+test_done
This is still basically the same as `git add`, but now more easily extendable. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> --- Documentation/git-stage.txt | 11 ++++++++--- Makefile | 2 +- builtin.h | 1 + builtin/stage.c | 23 +++++++++++++++++++++++ git.c | 2 +- t/t3710-stage.sh | 20 ++++++++++++++++++++ 6 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 builtin/stage.c create mode 100755 t/t3710-stage.sh