From: Thomas Rast <trast@student.ethz.ch>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Pierre Habouzit <madcoder@debian.org>
Subject: [RFC PATCH v2 1/3] Introduce git-unstage
Date: Fri, 24 Jul 2009 18:24:34 +0200 [thread overview]
Message-ID: <683ed99f389d643d21bda6750bd2ee9caf287625.1248452530.git.trast@student.ethz.ch> (raw)
In-Reply-To: <2d756f643fc7d1b50cf590c95467fa029b49ff46.1248426652.git.trast@student.ethz.ch>
The new command 'git unstage' is the precise opposite of 'git stage'
(i.e., git-add). As such, it is the same as 'git reset --' unless the
current branch is unborn.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
So I decided I had wished for these frequently enough to actually
implement them. I ran out of time before getting to the tests, but
the rest should be there.
v1 had a bug where it would not correctly detect the changed files,
this is fixed in the new patch (now 3/3).
Documentation/git-unstage.txt | 26 ++++++++++++++++++++++++++
Makefile | 1 +
git-unstage.sh | 26 ++++++++++++++++++++++++++
wt-status.c | 6 +-----
4 files changed, 54 insertions(+), 5 deletions(-)
create mode 100644 Documentation/git-unstage.txt
create mode 100644 git-unstage.sh
diff --git a/Documentation/git-unstage.txt b/Documentation/git-unstage.txt
new file mode 100644
index 0000000..49d09fb
--- /dev/null
+++ b/Documentation/git-unstage.txt
@@ -0,0 +1,26 @@
+git-unstage(1)
+==============
+
+NAME
+----
+git-unstage - Remove changes to a file from the staging area
+
+
+SYNOPSIS
+--------
+[verse]
+'git unstage' <paths> ...
+
+
+DESCRIPTION
+-----------
+
+Overwrites the staged changes to the 'paths' with the values from
+HEAD, so that they are not included in the next commit. The worktree
+is not affected. (This is the same as `git reset \-- <paths>` unless
+you are on an unborn branch.)
+
+
+SEE ALSO
+--------
+linkgit:git-reset[1]
diff --git a/Makefile b/Makefile
index 75b9dcb..9e48fdc 100644
--- a/Makefile
+++ b/Makefile
@@ -329,6 +329,7 @@ SCRIPT_SH += git-request-pull.sh
SCRIPT_SH += git-sh-setup.sh
SCRIPT_SH += git-stash.sh
SCRIPT_SH += git-submodule.sh
+SCRIPT_SH += git-unstage.sh
SCRIPT_SH += git-web--browse.sh
SCRIPT_PERL += git-add--interactive.perl
diff --git a/git-unstage.sh b/git-unstage.sh
new file mode 100644
index 0000000..7f99adf
--- /dev/null
+++ b/git-unstage.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+SUBDIRECTORY_OK=Yes
+OPTIONS_KEEPDASHDASH=
+OPTIONS_SPEC="\
+git unstage file ...
+--"
+
+. git-sh-setup
+
+
+case "$1" in
+ --)
+ if [ $# -eq 1 ]; then
+ die "You must specify at least one file to unstage"
+ fi
+ if git rev-parse -q --verify HEAD >/dev/null; then
+ exec git reset "$@"
+ else
+ exec git rm --cached "$@"
+ fi
+ ;;
+ *)
+ usage
+ ;;
+esac
diff --git a/wt-status.c b/wt-status.c
index 47735d8..f1a74a4 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -62,11 +62,7 @@ static void wt_status_print_cached_header(struct wt_status *s)
{
const char *c = color(WT_STATUS_HEADER);
color_fprintf_ln(s->fp, c, "# Changes to be committed:");
- if (!s->is_initial) {
- color_fprintf_ln(s->fp, c, "# (use \"git reset %s <file>...\" to unstage)", s->reference);
- } else {
- color_fprintf_ln(s->fp, c, "# (use \"git rm --cached <file>...\" to unstage)");
- }
+ color_fprintf_ln(s->fp, c, "# (use \"git unstage %s <file>...\" to unstage)", s->reference);
color_fprintf_ln(s->fp, c, "#");
}
--
1.6.4.rc2.217.g74c0b.dirty
next prev parent reply other threads:[~2009-07-24 16:25 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-23 7:41 [PATCH] git-add -p: be able to undo a given hunk Pierre Habouzit
2009-07-23 8:41 ` Thomas Rast
2009-07-23 8:50 ` Pierre Habouzit
2009-07-24 9:15 ` [RFC PATCH] Implement unstage and reset modes for git-add--interactive Thomas Rast
2009-07-24 16:24 ` Thomas Rast [this message]
2009-07-24 17:59 ` [RFC PATCH v2 1/3] Introduce git-unstage Bert Wesarg
2009-07-24 18:02 ` Bert Wesarg
2009-07-24 18:23 ` Elijah Newren
2009-07-24 16:24 ` [RFC PATCH v2 2/3] Introduce git-discard Thomas Rast
2009-07-24 18:02 ` Elijah Newren
2009-07-24 18:12 ` Bert Wesarg
2009-07-24 18:24 ` Elijah Newren
2009-07-25 14:58 ` Pierre Habouzit
2009-07-24 16:24 ` [RFC PATCH v2 3/3] Implement unstage --patch and discard --patch Thomas Rast
2009-07-24 16:40 ` Matthias Kestenholz
2009-07-24 18:08 ` Bert Wesarg
2009-07-24 16:39 ` [RFC PATCH] Implement unstage and reset modes for git-add--interactive Junio C Hamano
2009-07-24 21:58 ` Nanako Shiraishi
2009-07-24 23:17 ` Thomas Rast
2009-07-24 23:25 ` Junio C Hamano
2009-07-25 21:29 ` [RFC PATCH v3 0/5] {checkout,reset,stash} --patch Thomas Rast
2009-07-25 21:29 ` [RFC PATCH v3 1/5] git-apply--interactive: Refactor patch mode code Thomas Rast
2009-07-25 21:29 ` [RFC PATCH v3 2/5] builtin-add: refactor the meat of interactive_add() Thomas Rast
2009-07-25 21:29 ` [RFC PATCH v3 3/5] Implement 'git reset --patch' Thomas Rast
2009-07-25 21:29 ` [RFC PATCH v3 4/5] Implement 'git checkout --patch' Thomas Rast
2009-07-25 21:29 ` [RFC PATCH v3 5/5] Implement 'git stash save --patch' Thomas Rast
2009-07-26 6:03 ` Sverre Rabbelier
2009-07-26 8:45 ` Thomas Rast
2009-07-27 10:10 ` [RFC PATCH v3 0/5] {checkout,reset,stash} --patch Thomas Rast
2009-07-28 21:20 ` [PATCH v4 " Thomas Rast
2009-07-28 21:20 ` [PATCH v4 1/5] git-apply--interactive: Refactor patch mode code Thomas Rast
2009-07-28 21:20 ` [PATCH v4 2/5] builtin-add: refactor the meat of interactive_add() Thomas Rast
2009-07-28 21:20 ` [PATCH v4 3/5] Implement 'git reset --patch' Thomas Rast
2009-07-28 21:20 ` [PATCH v4 4/5] Implement 'git checkout --patch' Thomas Rast
2009-07-28 21:20 ` [PATCH v4 5/5] Implement 'git stash save --patch' Thomas Rast
2009-07-28 21:20 ` [PATCH v4 6/5] DWIM 'git stash save -p' for 'git stash -p' Thomas Rast
2009-08-09 6:52 ` [PATCH v4 0/5] {checkout,reset,stash} --patch Jeff King
2009-08-09 9:17 ` Thomas Rast
2009-08-09 16:32 ` [PATCH v4 0/5] " Nicolas Sebrecht
2009-08-09 16:44 ` Thomas Rast
2009-08-09 21:28 ` Nicolas Sebrecht
2009-08-09 21:42 ` Thomas Rast
2009-08-09 22:26 ` Nicolas Sebrecht
2009-08-10 9:36 ` Thomas Rast
2009-08-13 12:29 ` [PATCH v5 0/6] " Thomas Rast
2009-08-13 12:29 ` [PATCH v5 1/6] git-apply--interactive: Refactor patch mode code Thomas Rast
2009-08-13 12:29 ` [PATCH v5 2/6] Add a small patch-mode testing library Thomas Rast
2009-08-13 12:29 ` [PATCH v5 3/6] builtin-add: refactor the meat of interactive_add() Thomas Rast
2009-08-13 12:29 ` [PATCH v5 4/6] Implement 'git reset --patch' Thomas Rast
2009-08-15 11:48 ` [PATCH v5.1 " Thomas Rast
2009-08-13 12:29 ` [PATCH v5 5/6] Implement 'git checkout --patch' Thomas Rast
2009-08-15 11:48 ` [PATCH v5.1 " Thomas Rast
2009-08-13 12:29 ` [PATCH v5 6/6] Implement 'git stash save --patch' Thomas Rast
2009-08-13 12:29 ` [PATCH v5 7/6] DWIM 'git stash save -p' for 'git stash -p' Thomas Rast
2009-08-14 20:57 ` [PATCH v5 0/6] Re: {checkout,reset,stash} --patch Nicolas Sebrecht
2009-08-15 6:51 ` [PATCH v5 0/6] " Jeff King
2009-08-15 7:57 ` Junio C Hamano
2009-08-15 10:14 ` Thomas Rast
2009-08-15 10:04 ` Thomas Rast
2009-08-18 16:48 ` Jeff King
2009-08-19 9:40 ` Thomas Rast
2009-08-19 10:11 ` Jeff King
2009-07-23 19:58 ` [PATCH] git-add -p: be able to undo a given hunk Junio C Hamano
2009-07-24 10:32 ` Nanako Shiraishi
2009-07-24 16:06 ` Junio C Hamano
2009-07-24 17:06 ` Jeff King
2009-07-25 0:54 ` Junio C Hamano
2009-07-25 9:35 ` Thomas Rast
2009-07-25 14:48 ` Pierre Habouzit
2009-07-25 14:52 ` Pierre Habouzit
2009-07-26 15:39 ` Jeff King
2009-07-27 8:26 ` Pierre Habouzit
2009-07-27 10:30 ` Jeff King
2009-07-27 10:06 ` Thomas Rast
2009-07-27 10:36 ` Jeff King
2009-07-24 14:58 ` Pierre Habouzit
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=683ed99f389d643d21bda6750bd2ee9caf287625.1248452530.git.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=madcoder@debian.org \
/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.
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).