mirror of
https://github.com/git/git
synced 2024-10-30 04:01:21 +00:00
for-each-ref: cope with tags with incomplete lines
If you have a tag with a single, incomplete line as its payload, asking git-for-each-ref for its %(body) element accessed a NULL pointer. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
c35539eb10
commit
e276c26b4b
2 changed files with 13 additions and 1 deletions
|
@ -459,8 +459,10 @@ static void find_subpos(const char *buf, unsigned long sz, const char **sub, con
|
||||||
return;
|
return;
|
||||||
*sub = buf; /* first non-empty line */
|
*sub = buf; /* first non-empty line */
|
||||||
buf = strchr(buf, '\n');
|
buf = strchr(buf, '\n');
|
||||||
if (!buf)
|
if (!buf) {
|
||||||
|
*body = "";
|
||||||
return; /* no body */
|
return; /* no body */
|
||||||
|
}
|
||||||
while (*buf == '\n')
|
while (*buf == '\n')
|
||||||
buf++; /* skip blank between subject and body */
|
buf++; /* skip blank between subject and body */
|
||||||
*body = buf;
|
*body = buf;
|
||||||
|
|
|
@ -262,4 +262,14 @@ for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
|
||||||
"
|
"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
test_expect_success 'an unusual tag with an incomplete line' '
|
||||||
|
|
||||||
|
git tag -m "bogo" bogo &&
|
||||||
|
bogo=$(git cat-file tag bogo) &&
|
||||||
|
bogo=$(printf "%s" "$bogo" | git mktag) &&
|
||||||
|
git tag -f bogo "$bogo" &&
|
||||||
|
git for-each-ref --format "%(body)" refs/tags/bogo
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue