From: Thomas Rast Date: Fri, 24 Jul 2009 16:24:35 GMT Subject: [RFC PATCH v2 2/3] Introduce git-discard Message-ID: In-Reply-To: <2d756f643fc7d1b50cf590c95467fa029b49ff46.1248426652.git.trast@student.ethz.ch> The new command 'git discard' is precisely the same as 'git checkout --'. Signed-off-by: Thomas Rast --- Documentation/git-discard.txt | 29 +++++++++++++++++++++++++++++ Makefile | 1 + git-discard.sh | 22 ++++++++++++++++++++++ wt-status.c | 2 +- 4 files changed, 53 insertions(+), 1 deletions(-) create mode 100644 Documentation/git-discard.txt create mode 100644 git-discard.sh diff --git a/Documentation/git-discard.txt b/Documentation/git-discard.txt new file mode 100644 index 0000000..4db14f0 --- /dev/null +++ b/Documentation/git-discard.txt @@ -0,0 +1,29 @@ +git-discard(1) +============== + +NAME +---- +git-discard - Remove changes to a file from the worktree + + +SYNOPSIS +-------- +[verse] +'git discard' ... + + +DESCRIPTION +----------- + +Overwrites your edits to the 'paths' with the values from the staging +area, effectively throwing them away entirely. + +*WARNING:* All unstaged changes to the 'paths' are *irreversibly* +lost. + +(This is the same as `git checkout \-- `.) + + +SEE ALSO +-------- +linkgit:git-checkout[1] diff --git a/Makefile b/Makefile index 9e48fdc..814d4b6 100644 --- a/Makefile +++ b/Makefile @@ -312,6 +312,7 @@ TEST_PROGRAMS = SCRIPT_SH += git-am.sh SCRIPT_SH += git-bisect.sh SCRIPT_SH += git-difftool--helper.sh +SCRIPT_SH += git-discard.sh SCRIPT_SH += git-filter-branch.sh SCRIPT_SH += git-lost-found.sh SCRIPT_SH += git-merge-octopus.sh diff --git a/git-discard.sh b/git-discard.sh new file mode 100644 index 0000000..595df98 --- /dev/null +++ b/git-discard.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +SUBDIRECTORY_OK=Yes +OPTIONS_KEEPDASHDASH= +OPTIONS_SPEC="\ +git discard file ... +--" + +. git-sh-setup + + +case "$1" in + --) + if [ $# -eq 1 ]; then + die "You must specify at least one file to discard changes from" + fi + exec git checkout "$@" + ;; + *) + usage + ;; +esac diff --git a/wt-status.c b/wt-status.c index f1a74a4..1dd4bed 100644 --- a/wt-status.c +++ b/wt-status.c @@ -75,7 +75,7 @@ static void wt_status_print_dirty_header(struct wt_status *s, color_fprintf_ln(s->fp, c, "# (use \"git add ...\" to update what will be committed)"); else color_fprintf_ln(s->fp, c, "# (use \"git add/rm ...\" to update what will be committed)"); - color_fprintf_ln(s->fp, c, "# (use \"git checkout -- ...\" to discard changes in working directory)"); + color_fprintf_ln(s->fp, c, "# (use \"git discard ...\" to discard changes in working directory)"); color_fprintf_ln(s->fp, c, "#"); } -- 1.6.4.rc2.217.g74c0b.dirty