diff options
-rw-r--r-- | examples/status.c | 5 | ||||
-rw-r--r-- | src/crlf.c | 4 | ||||
-rw-r--r-- | src/transports/smart.c | 12 | ||||
-rw-r--r-- | tests/filter/crlf.c | 6 | ||||
-rw-r--r-- | tests/index/crlf.c | 18 |
5 files changed, 40 insertions, 5 deletions
diff --git a/examples/status.c b/examples/status.c index 9c99744cb..a59f34454 100644 --- a/examples/status.c +++ b/examples/status.c @@ -14,9 +14,10 @@ #include "common.h" #ifdef _WIN32 -#define sleep(a) Sleep(a * 1000) +# include <Windows.h> +# define sleep(a) Sleep(a * 1000) #else -#include <unistd.h> +# include <unistd.h> #endif /** diff --git a/src/crlf.c b/src/crlf.c index dad3ecebc..821e04eb2 100644 --- a/src/crlf.c +++ b/src/crlf.c @@ -138,6 +138,10 @@ static int crlf_apply_to_odb( if (git_buf_text_gather_stats(&stats, from, false)) return GIT_PASSTHROUGH; + /* If there are no CR characters to filter out, then just pass */ + if (!stats.cr) + return GIT_PASSTHROUGH; + /* If safecrlf is enabled, sanity-check the result. */ if (stats.cr != stats.crlf || stats.lf != stats.crlf) { switch (ca->safe_crlf) { diff --git a/src/transports/smart.c b/src/transports/smart.c index 47ef5038c..c9845bff9 100644 --- a/src/transports/smart.c +++ b/src/transports/smart.c @@ -311,6 +311,18 @@ static int git_smart__close(git_transport *transport) unsigned int i; git_pkt *p; int ret; + git_smart_subtransport_stream *stream; + const char flush[] = "0000"; + + /* + * If we're still connected at this point and not using RPC, + * we should say goodbye by sending a flush, or git-daemon + * will complain that we disconnected unexpectedly. + */ + if (t->connected && !t->rpc && + !t->wrapped->action(&stream, t->wrapped, t->url, GIT_SERVICE_UPLOADPACK)) { + t->current_stream->write(t->current_stream, flush, 4); + } ret = git_smart__reset_stream(t, true); diff --git a/tests/filter/crlf.c b/tests/filter/crlf.c index 66c267e31..334b1e349 100644 --- a/tests/filter/crlf.c +++ b/tests/filter/crlf.c @@ -103,12 +103,12 @@ void test_filter_crlf__with_safecrlf(void) cl_git_fail(git_filter_list_apply_to_data(&out, fl, &in)); cl_assert_equal_i(giterr_last()->klass, GITERR_FILTER); - /* Normalized \n fails with safecrlf */ + /* Normalized \n is reversible, so does not fail with safecrlf */ in.ptr = "Normal\nLF\nonly\nline-endings.\n"; in.size = strlen(in.ptr); - cl_git_fail(git_filter_list_apply_to_data(&out, fl, &in)); - cl_assert_equal_i(giterr_last()->klass, GITERR_FILTER); + cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in)); + cl_assert_equal_s(in.ptr, out.ptr); git_filter_list_free(fl); git_buf_free(&out); diff --git a/tests/index/crlf.c b/tests/index/crlf.c index cf69c6226..7babd5939 100644 --- a/tests/index/crlf.c +++ b/tests/index/crlf.c @@ -134,3 +134,21 @@ void test_index_crlf__autocrlf_input_text_auto_attr(void) cl_git_pass(git_oid_fromstr(&oid, FILE_OID_LF)); cl_assert(git_oid_cmp(&oid, &entry->id) == 0); } + +void test_index_crlf__safecrlf_true_no_attrs(void) +{ + cl_repo_set_bool(g_repo, "core.autocrlf", true); + cl_repo_set_bool(g_repo, "core.safecrlf", true); + + cl_git_mkfile("crlf/newfile.txt", ALL_LF_TEXT_RAW); + cl_git_pass(git_index_add_bypath(g_index, "newfile.txt")); + + cl_git_mkfile("crlf/newfile.txt", ALL_CRLF_TEXT_RAW); + cl_git_pass(git_index_add_bypath(g_index, "newfile.txt")); + + cl_git_mkfile("crlf/newfile.txt", MORE_CRLF_TEXT_RAW); + cl_git_fail(git_index_add_bypath(g_index, "newfile.txt")); + + cl_git_mkfile("crlf/newfile.txt", MORE_LF_TEXT_RAW); + cl_git_fail(git_index_add_bypath(g_index, "newfile.txt")); +} |