git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Fyn Fynn <fynfynn@gmail.com>
Cc: Nguyen Thai Ngoc Duy <pclouds@gmail.com>,
	Nanako Shiraishi <nanako3@lavabit.com>,
	git@vger.kernel.org
Subject: Re: Possible bug in 1.6.6 with reset --hard and $GIT_WORK_TREE
Date: Tue, 29 Dec 2009 16:50:15 -0500	[thread overview]
Message-ID: <20091229215015.GA1529@coredump.intra.peff.net> (raw)
In-Reply-To: <1a04eebf0912291309u7a222d9ch7e0926d30a5899b7@mail.gmail.com>

On Tue, Dec 29, 2009 at 01:09:20PM -0800, Fyn Fynn wrote:

> But it is more likely that the breaking of the original action between
> 1.6.4 and 1.6.6 came about as an untended consequence of 952dfc6,
> which oversimplified by assuming that the worktree can only be found
> if we're inside it, ignoring the possibility that GIT_WORK_TREE was
> provided.

Yes, it is an unintended breakage. We discussed the possibility of
automatically moving to the work tree when inside the repo, but decided
it could be done later, as other builtins which use NEEDS_WORK_TREE
(e.g., clean) already fail in that instance.

However, I did not take into account that those commands fail only with
automatic repo detection; they _do_ work with GIT_WORK_TREE. So instead
of just dying, we need to be emulating the code in git.c which sets up
the work tree (and which will die itself if we run into an error).

So I think what we really want is this:

diff --git a/builtin-reset.c b/builtin-reset.c
index 11d1c6e..e4418bc 100644
--- a/builtin-reset.c
+++ b/builtin-reset.c
@@ -286,10 +286,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 	if (reset_type == NONE)
 		reset_type = MIXED; /* by default */
 
-	if ((reset_type == HARD || reset_type == MERGE)
-	    && !is_inside_work_tree())
-		die("%s reset requires a work tree",
-		    reset_type_names[reset_type]);
+	if (reset_type == HARD || reset_type == MERGE)
+		setup_work_tree();
 
 	/* Soft reset does not touch the index file nor the working tree
 	 * at all, but requires them in a good order.  Other resets reset

I'll try to write a few tests and make sure that's sane.

-Peff

  reply	other threads:[~2009-12-29 21:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-29  6:47 Possible bug in 1.6.6 with reset --hard and $GIT_WORK_TREE Fyn Fynn
2009-12-29  8:12 ` Tay Ray Chuan
2009-12-29  8:38 ` Nguyen Thai Ngoc Duy
2009-12-29 11:04   ` Nanako Shiraishi
2009-12-29 11:36     ` Nguyen Thai Ngoc Duy
2009-12-29 21:09       ` Fyn Fynn
2009-12-29 21:50         ` Jeff King [this message]
2009-12-30  8:47           ` [PATCH] reset: unbreak hard resets with GIT_WORK_TREE Jeff King
2009-12-30 17:54             ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091229215015.GA1529@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=fynfynn@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=nanako3@lavabit.com \
    --cc=pclouds@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).