From: fork0@t-online.de (Alex Riesen)
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: git-blame: handling of revisions and filenames
Date: Wed, 15 Nov 2006 22:52:25 +0100 [thread overview]
Message-ID: <20061115215225.GA4595@steel.home> (raw)
I noticed that there is no safe way to give a revision to git-blame:
it can always be interpreted as an existing file:
- "git blame rev -- file.txt" can fail if "rev" is a file
- "git blame rev^0 -- file.txt" can file there is a "rev^0" file
(happens if you type too fast with a tool not designed for keyboard)
- "git blame file.txt rev" is ambiguos too, for the same reasons.
I did the simple patch (below) to resolve at least the very first one,
just because that is how git-rev-list does it.
But if all forms of git-blame command line are expected to live, a
more serious surgery of the argv[] handling code needed.
And I afraid the patch has a small chance of crashing: I don't check
if there is enough space in argv (don't actually even know how to),
so Junio, please do not apply it (it passes blame tests, though).
I also suspect git-blame is not the only command using revision
machinery which has the same problem, so this message is more like a
discussion starter.
diff --git a/builtin-blame.c b/builtin-blame.c
index 066dee7..83c8905 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -1787,6 +1787,7 @@ int cmd_blame(int argc, const char **arg
/* Now we got rev and path. We do not want the path pruning
* but we may want "bottom" processing.
*/
+ argv[unk++] = "--";
argv[unk] = NULL;
init_revisions(&revs, NULL);
next reply other threads:[~2006-11-15 21:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-15 21:52 Alex Riesen [this message]
2006-11-29 18:29 ` git-blame: handling of revisions and filenames 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=20061115215225.GA4595@steel.home \
--to=fork0@t-online.de \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=raa.lkml@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).