commit - b02560eced1f0b170085e9c5aa73e835beea3dac
commit + 548237bca5af8d72f355b42d06bafc910b13cb06
blob - df12bfb1268e9700fcdafe8129ce1e07f5248a33
blob + bff96a67e419e5a1310eac428bf293da26ebe4d1
--- lib/blame.c
+++ lib/blame.c
int lineno)
{
struct got_blame_diff_offsets *diff_offsets;
+ int offset = 0;
SLIST_FOREACH(diff_offsets, diff_offsets_list, entry)
lineno = got_diffoffset_get(diff_offsets->chunks, lineno);
- return lineno;
+ return lineno + offset;
}
static const struct got_error *
blob - 6abefa6928bbb851939d9d90766cc9645d05aab3
blob + 989570511770f9cdb9ebc76d1a75d0b30e88f363
--- lib/diffoffset.c
+++ lib/diffoffset.c
const struct got_error *err = NULL;
int offset;
- offset = new_lineno - old_lineno;
- if (offset != 0) {
- err = add_chunk(chunks, old_lineno, offset);
- if (err)
- return err;
+ if (old_length != 0) {
+ offset = new_lineno - old_lineno;
+ if (offset != 0) {
+ err = add_chunk(chunks, old_lineno, offset);
+ if (err)
+ return err;
+ }
+ } else {
+ offset = new_length;
+ if (offset != 0) {
+ err = add_chunk(chunks, old_lineno, offset);
+ if (err)
+ return err;
+ }
+ if (old_lineno == new_lineno)
+ return NULL;
}
offset = new_lineno - old_lineno + new_length - old_length;
if (offset != 0)
- err = add_chunk(chunks, old_lineno + old_length, offset);
+ err = add_chunk(chunks, old_lineno + new_length, offset);
return err;
}
int
got_diffoffset_get(struct got_diffoffset_chunks *chunks, int lineno)
{
- struct got_diffoffset_chunk *chunk, *prev;
+ struct got_diffoffset_chunk *chunk;
+ int offset = 0;
- prev = SIMPLEQ_FIRST(chunks);
SIMPLEQ_FOREACH(chunk, chunks, entry) {
if (chunk->lineno > lineno)
break;
- prev = chunk;
+ offset += chunk->offset;
}
- return lineno + prev->offset;
+ return lineno + offset;
}
blob - 66015530063440d784e2152767420965b157b0de
blob + ac29d637e011820ba1305f8c0c5c84a2eb40dfc3
--- regress/cmdline/blame.sh
+++ regress/cmdline/blame.sh
cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
if [ "$ret" != "0" ]; then
- #diff -u $testroot/stdout.expected $testroot/stdout
- test_done "$testroot" "xfail: line 3 has wrong annotation"
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
return 1
fi
test_done "$testroot" "$ret"