git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-reset: allow --soft in a bare repo
@ 2007-07-14  4:49 Jeff King
  2007-07-14  5:19 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2007-07-14  4:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Previously, git-reset always required a work directory. For
--mixed and --hard resets, this makes sense, as the bare
repo doesn't have an index or a working tree. However, for
--soft, there's no reason to prohibit this behavior.

Signed-off-by: Jeff King <peff@peff.net>
---
Somebody asked about this on irc ("how do I rewind history in a bare
repo"). The only other ways right now are to update the ref manually
(which involves plumbing), or to "git-push -f" from a non-bare
repository. I can't think of any good reason why a soft reset shouldn't
be allowed.

 git-reset.sh |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/git-reset.sh b/git-reset.sh
index 1dc606f..5450289 100755
--- a/git-reset.sh
+++ b/git-reset.sh
@@ -6,7 +6,6 @@ USAGE='[--mixed | --soft | --hard]  [<commit-ish>] [ [--] <paths>...]'
 SUBDIRECTORY_OK=Yes
 . git-sh-setup
 set_reflog_action "reset $*"
-require_work_tree
 
 update= reset_type=--mixed
 unset rev
@@ -32,6 +31,13 @@ do
 	shift
 done
 
+case "$reset_type" in
+	--soft)
+		;;
+	*)
+		require_work_tree
+esac
+
 : ${rev=HEAD}
 rev=$(git rev-parse --verify $rev^0) || exit
 
-- 
1.5.3.rc1.807.g51fb9-dirty

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-07-15  1:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-14  4:49 [PATCH] git-reset: allow --soft in a bare repo Jeff King
2007-07-14  5:19 ` Junio C Hamano
2007-07-14  5:24   ` Jeff King
2007-07-14  8:33     ` Junio C Hamano
2007-07-15  1:02       ` Jeff King

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).