From: Jeff King <peff@peff.net>
To: Zemacsh <ruini.xue@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: "git apply --check" successes but git am says "does not match index"
Date: Mon, 15 Aug 2011 16:23:18 -0700 [thread overview]
Message-ID: <20110815232318.GA4699@sigill.intra.peff.net> (raw)
In-Reply-To: <loom.20110814T113311-277@post.gmane.org>
On Sun, Aug 14, 2011 at 09:36:30AM +0000, Zemacsh wrote:
> Before applying a mbox patch, "git apply --check" reports OK. Then, I run 'git
> am', however, it complains "does not match index". Actually, both working tree
> and index are clean. what might be the problem?
>
> If I run "git am --abort" now, and re-turn "git am". To my surprise, everything
> goes well.
Hmm. I don't think this has anything to do with the "apply --check". But
rather the problem is that "git am" doesn't ever refresh the index. For
example:
git init repo &&
cd repo &&
echo one >file && git add . && git commit -m one &&
echo two >file && git add . && git commit -m two &&
git format-patch -1 --stdout >patch &&
git reset --hard HEAD^ &&
sleep 1 &&
touch file &&
git am patch
This fails with:
Applying: two
error: file: does not match index
Patch failed at 0001 two
Running "git am --abort" resets the index, which freshens it, and then a
further "git am" works:
$ git am --abort
$ git am patch
Applying: two
We should perhaps call "update-index --refresh" at the start to avoid
these sorts of false positives. Probably it should happen whenever we
"git am --continue", as well. But for efficiency reasons, not between
each patch.
I dunno. Do people want to call "git am" in a tight loop, where the
index refresh would be a problem? I would think they should instead feed
a whole mbox in one go.
-Peff
next prev parent reply other threads:[~2011-08-15 23:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-14 9:36 "git apply --check" successes but git am says "does not match index" Zemacsh
2011-08-15 23:23 ` Jeff King [this message]
2011-08-15 23:52 ` Junio C Hamano
2011-08-16 0:13 ` Jeff King
2011-08-16 4:10 ` Junio C Hamano
2011-08-16 4:14 ` Jeff King
2011-08-16 19:50 ` 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=20110815232318.GA4699@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=ruini.xue@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.
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).