Commit bf3389b930b8f040cd6a929bddd6fcd0c390f8f8

John Wiegley 2011-02-01T05:57:45

Fixed bug where git__source_printf needs multiple attempts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/object.c b/src/object.c
index 87e1b6e..43698d2 100644
--- a/src/object.c
+++ b/src/object.c
@@ -109,12 +109,9 @@ int git__source_printf(git_odb_source *source, const char *format, ...)
 		if (source_resize(source) < GIT_SUCCESS)
 			return GIT_ENOMEM;
 
-		did_resize = 1;
+		len = vsnprintf(source->write_ptr, source->raw.len - source->written_bytes, format, arglist);
 	}
 
-	if (did_resize)
-		vsnprintf(source->write_ptr, source->raw.len - source->written_bytes, format, arglist);
-
 	source->write_ptr = (char *)source->write_ptr + len;
 	source->written_bytes += len;