[RFC PATCH v2 2/3] Introduce git-discard
From: Thomas Rast <hidden>
Date: 2016-06-15 22:47:05
Subsystem:
documentation, kernel build + files below scripts/ (unless maintained elsewhere), the rest · Maintainers:
Jonathan Corbet, Nathan Chancellor, Nicolas Schier, Linus Torvalds
The new command 'git discard' is precisely the same as 'git checkout --'. Signed-off-by: Thomas Rast <redacted> --- 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' <paths> ... + + +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 \-- <paths>`.) + + +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 <file>...\" to update what will be committed)"); else color_fprintf_ln(s->fp, c, "# (use \"git add/rm <file>...\" to update what will be committed)"); - color_fprintf_ln(s->fp, c, "# (use \"git checkout -- <file>...\" to discard changes in working directory)"); + color_fprintf_ln(s->fp, c, "# (use \"git discard <file>...\" to discard changes in working directory)"); color_fprintf_ln(s->fp, c, "#"); }
--
1.6.4.rc2.217.g74c0b.dirty