From: Jeff King <peff@peff.net>
To: Alex Vandiver <alex@chmrr.net>
Cc: Junio C Hamano <gitster@pobox.com>,
git discussion list <git@vger.kernel.org>
Subject: Re: "fatal: git-write-tree: error building trees" from `git stash`
Date: Thu, 27 Dec 2012 14:05:42 -0500 [thread overview]
Message-ID: <20121227190542.GB28811@sigill.intra.peff.net> (raw)
In-Reply-To: <1356634556.13818.136.camel@umgah.localdomain>
On Thu, Dec 27, 2012 at 01:55:56PM -0500, Alex Vandiver wrote:
> On Thu, 2012-12-27 at 10:51 -0800, Junio C Hamano wrote:
> > > $ git stash
> > > foo: needs merge
> > > foo: needs merge
> > > foo: unmerged (aeaa7e5e87cf309a7368d5d92a71c1f9e6a8c9e7)
> > > foo: unmerged (a77fa514de2720c72c1a861de098595959a2c97a)
> > > foo: unmerged (4a622d2b991f1a19ba7be313a46dc6f03692cd0a)
> > > fatal: git-write-tree: error building trees
> > > Cannot save the current index state
> >
> > This is totally expected, isn't it?
> >
> > You do not save state in the middle of a conflict with "git stash"
> > (instead, you would "git stash" away your own work in progress
> > before you start operation that may create and leave conflicts).
>
> Apologies for not being clear. While being unable to stash is not
> unexpected, perhaps, "Cannot stash while resolving conflicts" or similar
> would be more understandable to the end user than the above.
Yeah, I think the outcome is reasonable, but that message is just
horrible. Something like this might be better:
diff --git a/git-stash.sh b/git-stash.sh
index 688e259..7ea425c 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -217,6 +217,12 @@ save_stash () {
stash_msg="$*"
+ if ! git diff-index --cached --diff-filter=U --quiet HEAD; then
+ echo >&2 "fatal: unable to stash unmerged entries:"
+ git diff-index --cached --diff-filter=U --name-status HEAD
+ exit 1
+ fi
+
git update-index -q --refresh
if no_changes
then
but I suspect it is not sufficient:
1. There are other code paths that will end up in write-tree which
should probably be protected, too.
2. Unmerged entries are only one reason that write-tree might fail.
It's OK not to catch them all (since ultimately write-tree will
complain if need be), but we may want to also handle intent-to-add
entries with a nicer message.
-Peff
next prev parent reply other threads:[~2012-12-27 19:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-27 18:07 "fatal: git-write-tree: error building trees" from `git stash` Alex Vandiver
2012-12-27 18:51 ` Junio C Hamano
2012-12-27 18:55 ` Alex Vandiver
2012-12-27 19:05 ` Jeff King [this message]
2012-12-27 20:11 ` Junio C Hamano
2012-12-27 19:21 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121227190542.GB28811@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=alex@chmrr.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox