summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2013-10-10 13:56:45 -0700
committerBen Straub <bs@github.com>2013-10-10 13:56:45 -0700
commitebd67243d5152e2c38811ba42fcdf99eecd8ef60 (patch)
tree17ce6b02e9829e858a710a4a9c653b2c31667644
parentd2e7532f620acd467ebeef0b3c4318420f445a13 (diff)
downloadlibgit2-ebd67243d5152e2c38811ba42fcdf99eecd8ef60.tar.gz
Only show lines that had blame run on them
-rw-r--r--examples/blame.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/examples/blame.c b/examples/blame.c
index 6423b3ca6..df687a71a 100644
--- a/examples/blame.c
+++ b/examples/blame.c
@@ -128,22 +128,24 @@ int main(int argc, char *argv[])
while (i < git_blob_rawsize(blob)) {
const char *eol = strchr(rawdata+i, '\n');
char oid[10] = {0};
- const git_blame_hunk *hunk = git_blame_get_hunk_byline(blame, line);
git_commit *hunkcommit;
const git_signature *sig;
+ const git_blame_hunk *hunk = git_blame_get_hunk_byline(blame, line);
- git_oid_tostr(oid, 10, &hunk->final_commit_id);
- check(git_commit_lookup(&hunkcommit, repo, &hunk->final_commit_id), "Commit lookup error");
- sig = git_commit_author(hunkcommit);
-
- printf("%s ( %-30s %3d) %.*s\n",
- oid,
- sig->name,
- line,
- (int)(eol-rawdata-i),
- rawdata+i);
+ if (hunk) {
+ git_oid_tostr(oid, 10, &hunk->final_commit_id);
+ check(git_commit_lookup(&hunkcommit, repo, &hunk->final_commit_id), "Commit lookup error");
+ sig = git_commit_author(hunkcommit);
+
+ printf("%s ( %-30s %3d) %.*s\n",
+ oid,
+ sig->name,
+ line,
+ (int)(eol-rawdata-i),
+ rawdata+i);
+ git_commit_free(hunkcommit);
+ }
- git_commit_free(hunkcommit);
i = eol - rawdata + 1;
line++;
}