From: Jeff King <peff@peff.net>
To: Debayan Banerjee <debayanin@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Possible bug with argument parsing in git blame
Date: Mon, 24 May 2010 02:46:41 -0400 [thread overview]
Message-ID: <20100524064641.GA10858@coredump.intra.peff.net> (raw)
In-Reply-To: <AANLkTikEiRuitD7lrZQIaOruCBrL1Vu5K74Y4wGoiC1z@mail.gmail.com>
On Mon, May 24, 2010 at 11:47:02AM +0530, Debayan Banerjee wrote:
> I used master too. The test cases you provided work fine for me too.
> It also seems that '/' is not a problem. I tested myself with some
> combinations and i could not reproduced the bug. But the strange
> behaviour i reported with my particular case still exists. My repo
> structure can be cloned from http://github.com/debayan/git-blame-test
> .
OK, I see what is happening. The issue is that you are blaming a file
from some revision, but that file doesn't exist in the working tree. You
can recreate it with:
git init
echo contents >>foo && git add foo && git commit -m one
echo contents >>foo && git add foo && git commit -m two
echo contents >>foo && git add foo && git commit -m three
git mv foo bar && git commit -m moved
Now "git blame HEAD~2..HEAD~1 -- foo" will work, but "git blame
HEAD~2..HEAD~1 foo" will not work.
This is as expected. When parsing revision/filename combinations, if
there is no explicit "--" separator, then we only allow filenames if the
file exists in the working tree. The idea is to prevent typos. For
example, in the same repo:
git bar ;# works, we have bar in the working tree
git log foo ;# complains, foo is not a revision and not a file, so
# maybe a typo
git log -- foo ;# works, filters on foo. The "--" makes it explicit
Things are a little bit funny with blame because:
1. It should take exactly one filename, so it doesn't have this
ambiguity.
2. The error message isn't very helpful. I think this is because blame
actually accepts several different combinations (like "<path>
<rev>", and it ends up confused.
I would be tempted to improve this, but I think (1) may no longer be the
case soon. As I understand it, some of Bo Yang's work in this area may
mean that blame will soon accept multiple files, and the argument
parsing may change.
-Peff
prev parent reply other threads:[~2010-05-24 6:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-17 10:21 Possible bug with argument parsing in git blame Debayan Banerjee
2010-05-23 8:00 ` Jeff King
[not found] ` <AANLkTinMlvmOneGgkIqxE8qWlhoOlqgALl-YHprqPI6h@mail.gmail.com>
2010-05-23 20:08 ` Jeff King
2010-05-24 6:17 ` Debayan Banerjee
2010-05-24 6:46 ` Jeff King [this message]
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=20100524064641.GA10858@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=debayanin@gmail.com \
--cc=git@vger.kernel.org \
/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).