From: Jan Keromnes <janx@linux.com>
To: git@vger.kernel.org
Subject: How to `git blame` individual characters?
Date: Tue, 27 Mar 2018 02:18:59 +0200 [thread overview]
Message-ID: <CAA6PgK7L04VoHT7A8M_mwq5kA+9BiQxrd6iPjPHOpa4=Z3futw@mail.gmail.com> (raw)
Dear Git developers,
I'd like to understand what would be required to run `git blame` on
individual characters instead of full lines. Could you please point me
in the right direction?
Someone asked a similar question about "Word-by-word blame/annotate"
on StackOverflow a few years ago, and one of the replies said:
> Git tracks changes snapshot by snapshot. The line-based format is calculated on-the-fly, and it would also be possible to have a word-based format.
Source: https://stackoverflow.com/q/17758008/3461173
This leaves me hopeful that a character-based format can somehow be
achieved. Here is a fake example to illustrate what I'm looking for:
$ cat myscript.js
for (int foo = 0; foo <= 11; foo++) { console.log(foo); }
$ git blame --character-based --pseudo-json myscript.js
[
{ "commit": "abcd1234", "summary": "Implement loop",
"characters": "for (int " },
{ "commit": "bcd1234a", "summary": "Rename iterator",
"characters": "foo" },
{ "commit": "abcd1234", "summary": "Implement loop",
"characters": " = 0; " },
{ "commit": "bcd1234a", "summary": "Rename iterator",
"characters": "foo" },
{ "commit": "abcd1234", "summary": "Implement loop",
"characters": " <= " },
{ "commit": "cd1234ab", "summary": "Go up to 11",
"characters": "11" },
{ "commit": "abcd1234", "summary": "Implement loop",
"characters": "; " },
{ "commit": "bcd1234a", "summary": "Rename iterator",
"characters": "foo" },
{ "commit": "abcd1234", "summary": "Implement loop",
"characters": "++) { console.log(" },
{ "commit": "bcd1234a", "summary": "Rename iterator",
"characters": "foo" },
{ "commit": "abcd1234", "summary": "Implement loop",
"characters": ")" },
{ "commit": "d1234abc", "summary": "Add missing
semicolon", "characters": ";" },
{ "commit": "abcd1234", "summary": "Implement loop",
"characters": " }" }
]
What would be the most direct way to achieve such a character-based
blame/annotate? Should I write some sort of Git extension, or hack
into Git's source code?
E.g. I looked for an option in `git-blame` or `git-annotate` to change
the "next line boundary" from "carret return" (line-based blame) to
"any whitespace" (word-based blame) or "character-by-character"
(character-based blame), but I didn't find it. Could this be
implemented in `blame.c`? If so, which methods would need tweaking?
Many thanks!
Jan
next reply other threads:[~2018-03-27 0:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-27 0:18 Jan Keromnes [this message]
2018-03-27 6:01 ` How to `git blame` individual characters? Christian Couder
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='CAA6PgK7L04VoHT7A8M_mwq5kA+9BiQxrd6iPjPHOpa4=Z3futw@mail.gmail.com' \
--to=janx@linux.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.
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).