From eb3359663d62f35999330797455dbe738bd5ed99 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 3 Apr 2007 16:28:46 -0700 Subject: rerere should not repeat the earlier hunks in later ones When a file has more then one conflicting hunks, it repeated the contents of previous hunks in output for later ones. Signed-off-by: Junio C Hamano --- builtin-rerere.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'builtin-rerere.c') diff --git a/builtin-rerere.c b/builtin-rerere.c index 58c5fed91d..004eda2acd 100644 --- a/builtin-rerere.c +++ b/builtin-rerere.c @@ -78,6 +78,13 @@ static void append_line(struct buffer *buffer, const char *line) buffer->nr += len; } +static void clear_buffer(struct buffer *buffer) +{ + free(buffer->ptr); + buffer->ptr = NULL; + buffer->nr = buffer->alloc = 0; +} + static int handle_file(const char *path, unsigned char *sha1, const char *output) { @@ -131,6 +138,8 @@ static int handle_file(const char *path, SHA1_Update(&ctx, two->ptr, two->nr); SHA1_Update(&ctx, "\0", 1); } + clear_buffer(one); + clear_buffer(two); } else if (hunk == 1) append_line(one, buf); else if (hunk == 2) -- cgit v1.2.3