From cfbe4be3fb639d96587974794fe437ace0c383c4 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Sat, 17 Nov 2012 19:54:47 -0800 Subject: More external API cleanup Conflicts: src/branch.c tests-clar/refs/branches/create.c --- tests-clar/object/blob/filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests-clar/object/blob/filter.c') diff --git a/tests-clar/object/blob/filter.c b/tests-clar/object/blob/filter.c index 0b87b2b46..4b058049a 100644 --- a/tests-clar/object/blob/filter.c +++ b/tests-clar/object/blob/filter.c @@ -14,7 +14,7 @@ static const char *g_raw[NUM_TEST_OBJECTS] = { "foo\nbar\rboth\r\nreversed\n\ragain\nproblems\r", "123\n\000\001\002\003\004abc\255\254\253\r\n" }; -static int g_len[NUM_TEST_OBJECTS] = { -1, -1, -1, -1, -1, 17 }; +static git_off_t g_len[NUM_TEST_OBJECTS] = { -1, -1, -1, -1, -1, 17 }; static git_text_stats g_stats[NUM_TEST_OBJECTS] = { { 0, 0, 0, 0, 0, 0 }, { 0, 0, 2, 0, 6, 0 }, @@ -65,7 +65,7 @@ void test_object_blob_filter__unfiltered(void) for (i = 0; i < NUM_TEST_OBJECTS; i++) { cl_git_pass(git_blob_lookup(&blob, g_repo, &g_oids[i])); - cl_assert((size_t)g_len[i] == git_blob_rawsize(blob)); + cl_assert(g_len[i] == git_blob_rawsize(blob)); cl_assert(memcmp(git_blob_rawcontent(blob), g_raw[i], g_len[i]) == 0); git_blob_free(blob); } -- cgit v1.2.3 From a8122b5d4a179456b1a1d9af8d09313e22bfab8d Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Wed, 21 Nov 2012 15:39:03 -0800 Subject: Fix warnings on Win64 build --- tests-clar/object/blob/filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests-clar/object/blob/filter.c') diff --git a/tests-clar/object/blob/filter.c b/tests-clar/object/blob/filter.c index 4b058049a..785489849 100644 --- a/tests-clar/object/blob/filter.c +++ b/tests-clar/object/blob/filter.c @@ -43,7 +43,7 @@ void test_object_blob_filter__initialize(void) for (i = 0; i < NUM_TEST_OBJECTS; i++) { size_t len = (g_len[i] < 0) ? strlen(g_raw[i]) : (size_t)g_len[i]; - g_len[i] = (int)len; + g_len[i] = (git_off_t)len; cl_git_pass( git_blob_create_frombuffer(&g_oids[i], g_repo, g_raw[i], len) @@ -66,7 +66,7 @@ void test_object_blob_filter__unfiltered(void) for (i = 0; i < NUM_TEST_OBJECTS; i++) { cl_git_pass(git_blob_lookup(&blob, g_repo, &g_oids[i])); cl_assert(g_len[i] == git_blob_rawsize(blob)); - cl_assert(memcmp(git_blob_rawcontent(blob), g_raw[i], g_len[i]) == 0); + cl_assert(memcmp(git_blob_rawcontent(blob), g_raw[i], (size_t)g_len[i]) == 0); git_blob_free(blob); } } -- cgit v1.2.3 From 7bf87ab6987cf6b9e166e23d2d9dbdcd2511fb32 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Wed, 28 Nov 2012 09:58:48 -0800 Subject: Consolidate text buffer functions There are many scattered functions that look into the contents of buffers to do various text manipulations (such as escaping or unescaping data, calculating text stats, guessing if content is binary, etc). This groups all those functions together into a new file and converts the code to use that. This has two enhancements to existing functionality. The old text stats function is significantly rewritten and the BOM detection code was extended (although largely we can't deal with anything other than a UTF8 BOM). --- tests-clar/object/blob/filter.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'tests-clar/object/blob/filter.c') diff --git a/tests-clar/object/blob/filter.c b/tests-clar/object/blob/filter.c index 785489849..b9bbfff0c 100644 --- a/tests-clar/object/blob/filter.c +++ b/tests-clar/object/blob/filter.c @@ -4,7 +4,7 @@ #include "filter.h" static git_repository *g_repo = NULL; -#define NUM_TEST_OBJECTS 6 +#define NUM_TEST_OBJECTS 8 static git_oid g_oids[NUM_TEST_OBJECTS]; static const char *g_raw[NUM_TEST_OBJECTS] = { "", @@ -12,16 +12,20 @@ static const char *g_raw[NUM_TEST_OBJECTS] = { "foo\rbar\r", "foo\r\nbar\r\n", "foo\nbar\rboth\r\nreversed\n\ragain\nproblems\r", - "123\n\000\001\002\003\004abc\255\254\253\r\n" + "123\n\000\001\002\003\004abc\255\254\253\r\n", + "\xEF\xBB\xBFThis is UTF-8\n", + "\xFE\xFF\x00T\x00h\x00i\x00s\x00!" }; -static git_off_t g_len[NUM_TEST_OBJECTS] = { -1, -1, -1, -1, -1, 17 }; -static git_text_stats g_stats[NUM_TEST_OBJECTS] = { - { 0, 0, 0, 0, 0, 0 }, - { 0, 0, 2, 0, 6, 0 }, - { 0, 2, 0, 0, 6, 0 }, - { 0, 2, 2, 2, 6, 0 }, - { 0, 4, 4, 1, 31, 0 }, - { 1, 1, 2, 1, 9, 5 } +static git_off_t g_len[NUM_TEST_OBJECTS] = { -1, -1, -1, -1, -1, 17, -1, 12 }; +static git_buf_text_stats g_stats[NUM_TEST_OBJECTS] = { + { 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 2, 0, 6, 0 }, + { 0, 0, 2, 0, 0, 6, 0 }, + { 0, 0, 2, 2, 2, 6, 0 }, + { 0, 0, 4, 4, 1, 31, 0 }, + { 0, 1, 1, 2, 1, 9, 5 }, + { GIT_BOM_UTF8, 0, 0, 1, 0, 16, 0 }, + { GIT_BOM_UTF16_BE, 5, 0, 0, 0, 7, 5 }, }; static git_buf g_crlf_filtered[NUM_TEST_OBJECTS] = { { "", 0, 0 }, @@ -29,7 +33,9 @@ static git_buf g_crlf_filtered[NUM_TEST_OBJECTS] = { { "foo\rbar\r", 0, 8 }, { "foo\nbar\n", 0, 8 }, { "foo\nbar\rboth\nreversed\n\ragain\nproblems\r", 0, 38 }, - { "123\n\000\001\002\003\004abc\255\254\253\n", 0, 16 } + { "123\n\000\001\002\003\004abc\255\254\253\n", 0, 16 }, + { "\xEF\xBB\xBFThis is UTF-8\n", 0, 17 }, + { "\xFE\xFF\x00T\x00h\x00i\x00s\x00!", 0, 12 } }; void test_object_blob_filter__initialize(void) @@ -76,12 +82,12 @@ void test_object_blob_filter__stats(void) int i; git_blob *blob; git_buf buf = GIT_BUF_INIT; - git_text_stats stats; + git_buf_text_stats stats; for (i = 0; i < NUM_TEST_OBJECTS; i++) { cl_git_pass(git_blob_lookup(&blob, g_repo, &g_oids[i])); cl_git_pass(git_blob__getbuf(&buf, blob)); - git_text_gather_stats(&stats, &buf); + git_buf_text_gather_stats(&stats, &buf, false); cl_assert(memcmp(&g_stats[i], &stats, sizeof(stats)) == 0); git_blob_free(blob); } -- cgit v1.2.3 From 3658e81e3499f874dc9f323d4d9127df7e219e12 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 25 Mar 2013 14:20:07 -0700 Subject: Move crlf conversion into buf_text This adds crlf/lf conversion functions into buf_text with more efficient implementations that bypass the high level buffer functions. They attempt to minimize the number of reallocations done and they directly write the buffer data as needed if they know that there is enough memory allocated to memcpy data. Tests are added for these new functions. The crlf.c code is updated to use the new functions. Removed the include of buf_text.h from filter.h and just include it more narrowly in the places that need it. --- tests-clar/object/blob/filter.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests-clar/object/blob/filter.c') diff --git a/tests-clar/object/blob/filter.c b/tests-clar/object/blob/filter.c index b9bbfff0c..042bddab7 100644 --- a/tests-clar/object/blob/filter.c +++ b/tests-clar/object/blob/filter.c @@ -2,6 +2,7 @@ #include "posix.h" #include "blob.h" #include "filter.h" +#include "buf_text.h" static git_repository *g_repo = NULL; #define NUM_TEST_OBJECTS 8 -- cgit v1.2.3