diff options
| author | Vicent Marti <vicent@github.com> | 2014-05-09 08:59:59 +0200 |
|---|---|---|
| committer | Vicent Marti <vicent@github.com> | 2014-05-09 08:59:59 +0200 |
| commit | e18d5e52e385c0cc2ad8d9d4fdd545517f170a11 (patch) | |
| tree | c529a250e7a234dde7194510e4a6c4692a79a92e /src/crlf.c | |
| parent | 4df53a64a18aeea88a459183437cbd033cf4ca71 (diff) | |
| parent | bb45e39063669514b84ac5b47c3520cfe99396c3 (diff) | |
| download | libgit2-e18d5e52e385c0cc2ad8d9d4fdd545517f170a11.tar.gz | |
Merge pull request #2331 from libgit2/rb/dont-stop-diff-on-safecrlf
Add filter options and ALLOW_UNSAFE
Diffstat (limited to 'src/crlf.c')
| -rw-r--r-- | src/crlf.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/crlf.c b/src/crlf.c index 8be1b9a05..dad3ecebc 100644 --- a/src/crlf.c +++ b/src/crlf.c @@ -139,10 +139,19 @@ static int crlf_apply_to_odb( return GIT_PASSTHROUGH; /* If safecrlf is enabled, sanity-check the result. */ - if (ca->safe_crlf && (stats.cr != stats.crlf || stats.lf != stats.crlf)) { - giterr_set(GITERR_FILTER, "LF would be replaced by CRLF in '%s'", - git_filter_source_path(src)); - return -1; + if (stats.cr != stats.crlf || stats.lf != stats.crlf) { + switch (ca->safe_crlf) { + case GIT_SAFE_CRLF_FAIL: + giterr_set( + GITERR_FILTER, "LF would be replaced by CRLF in '%s'", + git_filter_source_path(src)); + return -1; + case GIT_SAFE_CRLF_WARN: + /* TODO: issue warning when warning API is available */; + break; + default: + break; + } } /* @@ -267,6 +276,7 @@ static int crlf_check( if (ca.crlf_action == GIT_CRLF_GUESS || (ca.crlf_action == GIT_CRLF_AUTO && git_filter_source_mode(src) == GIT_FILTER_SMUDGE)) { + error = git_repository__cvar( &ca.auto_crlf, git_filter_source_repo(src), GIT_CVAR_AUTO_CRLF); if (error < 0) @@ -285,6 +295,11 @@ static int crlf_check( &ca.safe_crlf, git_filter_source_repo(src), GIT_CVAR_SAFE_CRLF); if (error < 0) return error; + + /* downgrade FAIL to WARN if ALLOW_UNSAFE option is used */ + if ((git_filter_source_options(src) & GIT_FILTER_OPT_ALLOW_UNSAFE) && + ca.safe_crlf == GIT_SAFE_CRLF_FAIL) + ca.safe_crlf = GIT_SAFE_CRLF_WARN; } *payload = git__malloc(sizeof(ca)); |
