summaryrefslogtreecommitdiff
path: root/examples/blame.c
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2013-10-10 14:30:31 -0700
committerBen Straub <bs@github.com>2013-10-10 14:30:31 -0700
commit607fe733700109ac171661975b60735c481ed3fc (patch)
tree757f751a59bbb12d6c9631251c84f65034042dd0 /examples/blame.c
parentc1ca2b67e1747ff4d2ba5a10ee300497d1d28dbe (diff)
downloadlibgit2-607fe733700109ac171661975b60735c481ed3fc.tar.gz
Fix post-line-range iteration
Diffstat (limited to 'examples/blame.c')
-rw-r--r--examples/blame.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/blame.c b/examples/blame.c
index 8ecf2970e..450e98aee 100644
--- a/examples/blame.c
+++ b/examples/blame.c
@@ -29,7 +29,7 @@ static void usage(const char *msg, const char *arg)
int main(int argc, char *argv[])
{
- int i, line;
+ int i, line, break_on_null_hunk;
const char *path = NULL, *a;
const char *rawdata, *commitspec=NULL, *bare_args[3] = {0};
char spec[1024] = {0};
@@ -125,12 +125,16 @@ int main(int argc, char *argv[])
/* Produce the output */
line = 1;
i = 0;
+ break_on_null_hunk = 0;
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);
+ if (break_on_null_hunk && !hunk) break;
+
if (hunk) {
+ break_on_null_hunk = 1;
char sig[128] = {0};
git_oid_tostr(oid, 10, &hunk->final_commit_id);