rugged 0.27.10.1 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/extconf.rb +23 -2
- data/ext/rugged/rugged.c +48 -2
- data/ext/rugged/rugged.h +5 -0
- data/ext/rugged/rugged_allocator.c +89 -0
- data/ext/rugged/rugged_blob.c +3 -3
- data/ext/rugged/rugged_branch.c +1 -1
- data/ext/rugged/rugged_commit.c +8 -8
- data/ext/rugged/rugged_config.c +1 -1
- data/ext/rugged/rugged_diff.c +24 -4
- data/ext/rugged/rugged_note.c +1 -1
- data/ext/rugged/rugged_repo.c +10 -10
- data/ext/rugged/rugged_settings.c +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +69 -47
- data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
- data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +5 -8
- data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -0
- data/vendor/libgit2/deps/regex/COPYING +502 -0
- data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
- data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +1 -0
- data/vendor/libgit2/deps/zlib/COPYING +27 -0
- data/vendor/libgit2/include/git2.h +3 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
- data/vendor/libgit2/include/git2/apply.h +129 -0
- data/vendor/libgit2/include/git2/attr.h +19 -8
- data/vendor/libgit2/include/git2/blame.h +41 -24
- data/vendor/libgit2/include/git2/blob.h +1 -1
- data/vendor/libgit2/include/git2/branch.h +1 -1
- data/vendor/libgit2/include/git2/buffer.h +2 -2
- data/vendor/libgit2/include/git2/checkout.h +20 -19
- data/vendor/libgit2/include/git2/cherrypick.h +6 -4
- data/vendor/libgit2/include/git2/clone.h +11 -9
- data/vendor/libgit2/include/git2/commit.h +30 -2
- data/vendor/libgit2/include/git2/common.h +54 -4
- data/vendor/libgit2/include/git2/config.h +18 -7
- data/vendor/libgit2/include/git2/deprecated.h +253 -0
- data/vendor/libgit2/include/git2/describe.h +30 -7
- data/vendor/libgit2/include/git2/diff.h +193 -143
- data/vendor/libgit2/include/git2/errors.h +54 -46
- data/vendor/libgit2/include/git2/ignore.h +2 -2
- data/vendor/libgit2/include/git2/index.h +72 -51
- data/vendor/libgit2/include/git2/indexer.h +30 -4
- data/vendor/libgit2/include/git2/mailmap.h +115 -0
- data/vendor/libgit2/include/git2/merge.h +29 -8
- data/vendor/libgit2/include/git2/net.h +1 -1
- data/vendor/libgit2/include/git2/notes.h +1 -1
- data/vendor/libgit2/include/git2/object.h +16 -16
- data/vendor/libgit2/include/git2/odb.h +10 -10
- data/vendor/libgit2/include/git2/odb_backend.h +7 -7
- data/vendor/libgit2/include/git2/oid.h +1 -1
- data/vendor/libgit2/include/git2/pack.h +2 -2
- data/vendor/libgit2/include/git2/proxy.h +9 -5
- data/vendor/libgit2/include/git2/rebase.h +7 -4
- data/vendor/libgit2/include/git2/refs.h +14 -15
- data/vendor/libgit2/include/git2/refspec.h +17 -0
- data/vendor/libgit2/include/git2/remote.h +92 -16
- data/vendor/libgit2/include/git2/repository.h +52 -37
- data/vendor/libgit2/include/git2/revert.h +5 -3
- data/vendor/libgit2/include/git2/revwalk.h +7 -7
- data/vendor/libgit2/include/git2/signature.h +2 -2
- data/vendor/libgit2/include/git2/stash.h +13 -10
- data/vendor/libgit2/include/git2/status.h +8 -4
- data/vendor/libgit2/include/git2/submodule.h +11 -10
- data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
- data/vendor/libgit2/include/git2/sys/commit.h +1 -1
- data/vendor/libgit2/include/git2/sys/config.h +13 -13
- data/vendor/libgit2/include/git2/sys/filter.h +6 -6
- data/vendor/libgit2/include/git2/sys/index.h +3 -0
- data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
- data/vendor/libgit2/include/git2/sys/merge.h +9 -4
- data/vendor/libgit2/include/git2/sys/odb_backend.h +19 -19
- data/vendor/libgit2/include/git2/sys/path.h +64 -0
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +19 -19
- data/vendor/libgit2/include/git2/sys/stream.h +92 -12
- data/vendor/libgit2/include/git2/sys/transport.h +127 -81
- data/vendor/libgit2/include/git2/tag.h +2 -2
- data/vendor/libgit2/include/git2/trace.h +1 -1
- data/vendor/libgit2/include/git2/transaction.h +1 -0
- data/vendor/libgit2/include/git2/transport.h +47 -18
- data/vendor/libgit2/include/git2/tree.h +3 -3
- data/vendor/libgit2/include/git2/types.h +35 -28
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +47 -12
- data/vendor/libgit2/src/CMakeLists.txt +87 -26
- data/vendor/libgit2/src/alloc.c +55 -0
- data/vendor/libgit2/src/alloc.h +40 -0
- data/vendor/libgit2/src/annotated_commit.c +15 -8
- data/vendor/libgit2/src/apply.c +490 -14
- data/vendor/libgit2/src/apply.h +3 -1
- data/vendor/libgit2/src/array.h +2 -2
- data/vendor/libgit2/src/attr.c +11 -11
- data/vendor/libgit2/src/attr_file.c +20 -15
- data/vendor/libgit2/src/attrcache.c +11 -11
- data/vendor/libgit2/src/blame.c +30 -15
- data/vendor/libgit2/src/blame.h +1 -0
- data/vendor/libgit2/src/blame_git.c +16 -13
- data/vendor/libgit2/src/blob.c +50 -28
- data/vendor/libgit2/src/blob.h +18 -1
- data/vendor/libgit2/src/branch.c +38 -38
- data/vendor/libgit2/src/buf_text.c +7 -6
- data/vendor/libgit2/src/buffer.c +55 -50
- data/vendor/libgit2/src/buffer.h +1 -1
- data/vendor/libgit2/src/cache.c +16 -16
- data/vendor/libgit2/src/cache.h +2 -2
- data/vendor/libgit2/src/cc-compat.h +15 -3
- data/vendor/libgit2/src/checkout.c +83 -74
- data/vendor/libgit2/src/cherrypick.c +6 -6
- data/vendor/libgit2/src/clone.c +20 -20
- data/vendor/libgit2/src/commit.c +53 -33
- data/vendor/libgit2/src/commit.h +1 -0
- data/vendor/libgit2/src/commit_list.c +6 -10
- data/vendor/libgit2/src/common.h +32 -30
- data/vendor/libgit2/src/config.c +167 -147
- data/vendor/libgit2/src/config.h +1 -14
- data/vendor/libgit2/src/config_backend.h +84 -0
- data/vendor/libgit2/src/config_cache.c +7 -1
- data/vendor/libgit2/src/config_entries.c +259 -0
- data/vendor/libgit2/src/config_entries.h +23 -0
- data/vendor/libgit2/src/config_file.c +167 -439
- data/vendor/libgit2/src/config_mem.c +224 -0
- data/vendor/libgit2/src/config_parse.c +69 -38
- data/vendor/libgit2/src/config_parse.h +4 -4
- data/vendor/libgit2/src/crlf.c +215 -186
- data/vendor/libgit2/src/delta.c +25 -18
- data/vendor/libgit2/src/describe.c +23 -23
- data/vendor/libgit2/src/diff.c +12 -12
- data/vendor/libgit2/src/diff_driver.c +14 -15
- data/vendor/libgit2/src/diff_file.c +10 -10
- data/vendor/libgit2/src/diff_generate.c +29 -23
- data/vendor/libgit2/src/diff_generate.h +1 -1
- data/vendor/libgit2/src/diff_parse.c +3 -3
- data/vendor/libgit2/src/diff_print.c +17 -17
- data/vendor/libgit2/src/diff_stats.c +22 -7
- data/vendor/libgit2/src/diff_tform.c +12 -12
- data/vendor/libgit2/src/diff_xdiff.c +15 -3
- data/vendor/libgit2/src/errors.c +42 -20
- data/vendor/libgit2/src/features.h.in +2 -1
- data/vendor/libgit2/src/fetch.c +3 -3
- data/vendor/libgit2/src/fetchhead.c +16 -16
- data/vendor/libgit2/src/filebuf.c +28 -28
- data/vendor/libgit2/src/fileops.c +54 -54
- data/vendor/libgit2/src/fileops.h +1 -1
- data/vendor/libgit2/src/filter.c +30 -30
- data/vendor/libgit2/src/filter.h +0 -10
- data/vendor/libgit2/src/global.c +36 -23
- data/vendor/libgit2/src/hash.h +4 -1
- data/vendor/libgit2/src/hash/hash_collisiondetect.h +6 -2
- data/vendor/libgit2/src/hash/hash_common_crypto.h +5 -1
- data/vendor/libgit2/src/hash/hash_generic.h +5 -1
- data/vendor/libgit2/src/hash/hash_mbedtls.c +38 -0
- data/vendor/libgit2/src/hash/hash_mbedtls.h +24 -0
- data/vendor/libgit2/src/hash/hash_openssl.h +8 -4
- data/vendor/libgit2/src/hash/hash_win32.c +13 -13
- data/vendor/libgit2/src/hashsig.c +4 -4
- data/vendor/libgit2/src/idxmap.c +25 -5
- data/vendor/libgit2/src/idxmap.h +4 -18
- data/vendor/libgit2/src/ignore.c +9 -9
- data/vendor/libgit2/src/index.c +280 -198
- data/vendor/libgit2/src/index.h +16 -0
- data/vendor/libgit2/src/indexer.c +311 -139
- data/vendor/libgit2/src/integer.h +32 -22
- data/vendor/libgit2/src/iterator.c +116 -49
- data/vendor/libgit2/src/iterator.h +15 -0
- data/vendor/libgit2/src/khash.h +3 -1
- data/vendor/libgit2/src/mailmap.c +485 -0
- data/vendor/libgit2/src/mailmap.h +35 -0
- data/vendor/libgit2/src/merge.c +89 -59
- data/vendor/libgit2/src/merge_driver.c +7 -7
- data/vendor/libgit2/src/merge_file.c +1 -1
- data/vendor/libgit2/src/mwindow.c +8 -8
- data/vendor/libgit2/src/netops.c +22 -13
- data/vendor/libgit2/src/netops.h +2 -0
- data/vendor/libgit2/src/notes.c +15 -10
- data/vendor/libgit2/src/object.c +118 -67
- data/vendor/libgit2/src/object.h +20 -9
- data/vendor/libgit2/src/object_api.c +8 -8
- data/vendor/libgit2/src/odb.c +72 -72
- data/vendor/libgit2/src/odb.h +7 -7
- data/vendor/libgit2/src/odb_loose.c +46 -46
- data/vendor/libgit2/src/odb_mempack.c +14 -14
- data/vendor/libgit2/src/odb_pack.c +14 -10
- data/vendor/libgit2/src/offmap.c +30 -0
- data/vendor/libgit2/src/offmap.h +20 -11
- data/vendor/libgit2/src/oid.c +6 -6
- data/vendor/libgit2/src/oidmap.c +20 -0
- data/vendor/libgit2/src/oidmap.h +9 -12
- data/vendor/libgit2/src/pack-objects.c +71 -63
- data/vendor/libgit2/src/pack-objects.h +1 -7
- data/vendor/libgit2/src/pack.c +58 -58
- data/vendor/libgit2/src/pack.h +6 -6
- data/vendor/libgit2/src/parse.h +1 -1
- data/vendor/libgit2/src/patch.c +3 -3
- data/vendor/libgit2/src/patch_generate.c +18 -18
- data/vendor/libgit2/src/patch_parse.c +13 -13
- data/vendor/libgit2/src/path.c +93 -225
- data/vendor/libgit2/src/path.h +2 -84
- data/vendor/libgit2/src/pathspec.c +6 -6
- data/vendor/libgit2/src/posix.c +3 -3
- data/vendor/libgit2/src/proxy.c +1 -1
- data/vendor/libgit2/src/push.c +27 -26
- data/vendor/libgit2/src/push.h +2 -1
- data/vendor/libgit2/src/reader.c +265 -0
- data/vendor/libgit2/src/reader.h +107 -0
- data/vendor/libgit2/src/rebase.c +49 -52
- data/vendor/libgit2/src/refdb.c +3 -3
- data/vendor/libgit2/src/refdb_fs.c +181 -103
- data/vendor/libgit2/src/reflog.c +3 -3
- data/vendor/libgit2/src/refs.c +98 -74
- data/vendor/libgit2/src/refs.h +5 -3
- data/vendor/libgit2/src/refspec.c +47 -21
- data/vendor/libgit2/src/refspec.h +1 -1
- data/vendor/libgit2/src/remote.c +219 -166
- data/vendor/libgit2/src/remote.h +9 -0
- data/vendor/libgit2/src/repository.c +173 -133
- data/vendor/libgit2/src/repository.h +6 -3
- data/vendor/libgit2/src/reset.c +8 -8
- data/vendor/libgit2/src/revert.c +6 -6
- data/vendor/libgit2/src/revparse.c +30 -30
- data/vendor/libgit2/src/revwalk.c +60 -30
- data/vendor/libgit2/src/revwalk.h +2 -1
- data/vendor/libgit2/src/settings.c +42 -10
- data/vendor/libgit2/src/signature.c +11 -11
- data/vendor/libgit2/src/sortedcache.c +13 -13
- data/vendor/libgit2/src/stash.c +91 -45
- data/vendor/libgit2/src/status.c +13 -13
- data/vendor/libgit2/src/stdalloc.c +120 -0
- data/vendor/libgit2/src/{streams/curl.h → stdalloc.h} +6 -6
- data/vendor/libgit2/src/stream.h +17 -2
- data/vendor/libgit2/src/streams/mbedtls.c +483 -0
- data/vendor/libgit2/src/streams/mbedtls.h +23 -0
- data/vendor/libgit2/src/streams/openssl.c +204 -114
- data/vendor/libgit2/src/streams/openssl.h +4 -108
- data/vendor/libgit2/src/streams/registry.c +118 -0
- data/vendor/libgit2/src/streams/registry.h +19 -0
- data/vendor/libgit2/src/streams/socket.c +54 -29
- data/vendor/libgit2/src/streams/stransport.c +57 -32
- data/vendor/libgit2/src/streams/stransport.h +5 -0
- data/vendor/libgit2/src/streams/tls.c +50 -19
- data/vendor/libgit2/src/streams/tls.h +12 -4
- data/vendor/libgit2/src/strmap.c +22 -2
- data/vendor/libgit2/src/strmap.h +18 -15
- data/vendor/libgit2/src/submodule.c +179 -155
- data/vendor/libgit2/src/sysdir.c +18 -18
- data/vendor/libgit2/src/tag.c +31 -26
- data/vendor/libgit2/src/tag.h +2 -1
- data/vendor/libgit2/src/trace.c +1 -1
- data/vendor/libgit2/src/trace.h +1 -1
- data/vendor/libgit2/src/trailer.c +6 -6
- data/vendor/libgit2/src/transaction.c +23 -23
- data/vendor/libgit2/src/transport.c +5 -5
- data/vendor/libgit2/src/transports/auth.c +7 -4
- data/vendor/libgit2/src/transports/auth.h +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +12 -11
- data/vendor/libgit2/src/transports/cred.c +18 -18
- data/vendor/libgit2/src/transports/git.c +15 -15
- data/vendor/libgit2/src/transports/http.c +606 -216
- data/vendor/libgit2/src/transports/http.h +2 -0
- data/vendor/libgit2/src/transports/local.c +26 -26
- data/vendor/libgit2/src/transports/smart.c +54 -31
- data/vendor/libgit2/src/transports/smart.h +1 -2
- data/vendor/libgit2/src/transports/smart_pkt.c +43 -40
- data/vendor/libgit2/src/transports/smart_protocol.c +61 -57
- data/vendor/libgit2/src/transports/ssh.c +34 -33
- data/vendor/libgit2/src/transports/winhttp.c +99 -119
- data/vendor/libgit2/src/tree-cache.c +5 -5
- data/vendor/libgit2/src/tree.c +96 -121
- data/vendor/libgit2/src/tree.h +1 -12
- data/vendor/libgit2/src/unix/map.c +2 -2
- data/vendor/libgit2/src/util.c +22 -6
- data/vendor/libgit2/src/util.h +12 -135
- data/vendor/libgit2/src/vector.c +4 -4
- data/vendor/libgit2/src/win32/dir.c +3 -3
- data/vendor/libgit2/src/win32/findfile.c +3 -3
- data/vendor/libgit2/src/win32/map.c +6 -6
- data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
- data/vendor/libgit2/src/win32/path_w32.c +101 -7
- data/vendor/libgit2/src/win32/path_w32.h +18 -0
- data/vendor/libgit2/src/win32/posix_w32.c +24 -43
- data/vendor/libgit2/src/win32/w32_buffer.c +2 -2
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +96 -2
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +28 -75
- data/vendor/libgit2/src/win32/w32_stack.c +2 -2
- data/vendor/libgit2/src/win32/w32_util.c +1 -69
- data/vendor/libgit2/src/win32/w32_util.h +1 -19
- data/vendor/libgit2/src/worktree.c +75 -54
- data/vendor/libgit2/src/worktree.h +2 -0
- data/vendor/libgit2/src/xdiff/xdiffi.c +7 -5
- data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
- data/vendor/libgit2/src/xdiff/xmerge.c +15 -15
- data/vendor/libgit2/src/zstream.c +4 -4
- metadata +33 -7
- data/vendor/libgit2/src/config_file.h +0 -73
- data/vendor/libgit2/src/streams/curl.c +0 -385
@@ -12,8 +12,8 @@
|
|
12
12
|
#include "oid.h"
|
13
13
|
#include "parse.h"
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
extern const char *git_config_escapes;
|
16
|
+
extern const char *git_config_escaped;
|
17
17
|
|
18
18
|
typedef struct config_file {
|
19
19
|
git_oid checksum;
|
@@ -36,8 +36,8 @@ typedef int (*git_config_parser_section_cb)(
|
|
36
36
|
typedef int (*git_config_parser_variable_cb)(
|
37
37
|
git_config_parser *parser,
|
38
38
|
const char *current_section,
|
39
|
-
char *var_name,
|
40
|
-
char *var_value,
|
39
|
+
const char *var_name,
|
40
|
+
const char *var_value,
|
41
41
|
const char *line,
|
42
42
|
size_t line_len,
|
43
43
|
void *data);
|
data/vendor/libgit2/src/crlf.c
CHANGED
@@ -18,65 +18,58 @@
|
|
18
18
|
#include "buf_text.h"
|
19
19
|
#include "repository.h"
|
20
20
|
|
21
|
+
typedef enum {
|
22
|
+
GIT_CRLF_UNDEFINED,
|
23
|
+
GIT_CRLF_BINARY,
|
24
|
+
GIT_CRLF_TEXT,
|
25
|
+
GIT_CRLF_TEXT_INPUT,
|
26
|
+
GIT_CRLF_TEXT_CRLF,
|
27
|
+
GIT_CRLF_AUTO,
|
28
|
+
GIT_CRLF_AUTO_INPUT,
|
29
|
+
GIT_CRLF_AUTO_CRLF,
|
30
|
+
} git_crlf_t;
|
31
|
+
|
21
32
|
struct crlf_attrs {
|
22
|
-
int
|
23
|
-
int
|
33
|
+
int attr_action; /* the .gitattributes setting */
|
34
|
+
int crlf_action; /* the core.autocrlf setting */
|
35
|
+
|
24
36
|
int auto_crlf;
|
25
37
|
int safe_crlf;
|
38
|
+
int core_eol;
|
26
39
|
};
|
27
40
|
|
28
41
|
struct crlf_filter {
|
29
42
|
git_filter f;
|
30
43
|
};
|
31
44
|
|
32
|
-
static
|
45
|
+
static git_crlf_t check_crlf(const char *value)
|
33
46
|
{
|
34
47
|
if (GIT_ATTR_TRUE(value))
|
35
48
|
return GIT_CRLF_TEXT;
|
36
|
-
|
37
|
-
if (GIT_ATTR_FALSE(value))
|
49
|
+
else if (GIT_ATTR_FALSE(value))
|
38
50
|
return GIT_CRLF_BINARY;
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
if (strcmp(value, "
|
44
|
-
return GIT_CRLF_INPUT;
|
45
|
-
|
46
|
-
if (strcmp(value, "auto") == 0)
|
51
|
+
else if (GIT_ATTR_UNSPECIFIED(value))
|
52
|
+
;
|
53
|
+
else if (strcmp(value, "input") == 0)
|
54
|
+
return GIT_CRLF_TEXT_INPUT;
|
55
|
+
else if (strcmp(value, "auto") == 0)
|
47
56
|
return GIT_CRLF_AUTO;
|
48
57
|
|
49
|
-
return
|
58
|
+
return GIT_CRLF_UNDEFINED;
|
50
59
|
}
|
51
60
|
|
52
|
-
static
|
61
|
+
static git_cvar_value check_eol(const char *value)
|
53
62
|
{
|
54
63
|
if (GIT_ATTR_UNSPECIFIED(value))
|
55
|
-
|
56
|
-
|
57
|
-
if (strcmp(value, "lf") == 0)
|
64
|
+
;
|
65
|
+
else if (strcmp(value, "lf") == 0)
|
58
66
|
return GIT_EOL_LF;
|
59
|
-
|
60
|
-
if (strcmp(value, "crlf") == 0)
|
67
|
+
else if (strcmp(value, "crlf") == 0)
|
61
68
|
return GIT_EOL_CRLF;
|
62
69
|
|
63
70
|
return GIT_EOL_UNSET;
|
64
71
|
}
|
65
72
|
|
66
|
-
static int crlf_input_action(struct crlf_attrs *ca)
|
67
|
-
{
|
68
|
-
if (ca->crlf_action == GIT_CRLF_BINARY)
|
69
|
-
return GIT_CRLF_BINARY;
|
70
|
-
|
71
|
-
if (ca->eol == GIT_EOL_LF)
|
72
|
-
return GIT_CRLF_INPUT;
|
73
|
-
|
74
|
-
if (ca->eol == GIT_EOL_CRLF)
|
75
|
-
return GIT_CRLF_CRLF;
|
76
|
-
|
77
|
-
return ca->crlf_action;
|
78
|
-
}
|
79
|
-
|
80
73
|
static int has_cr_in_index(const git_filter_source *src)
|
81
74
|
{
|
82
75
|
git_repository *repo = git_filter_source_repo(src);
|
@@ -92,7 +85,7 @@ static int has_cr_in_index(const git_filter_source *src)
|
|
92
85
|
return false;
|
93
86
|
|
94
87
|
if (git_repository_index__weakptr(&index, repo) < 0) {
|
95
|
-
|
88
|
+
git_error_clear();
|
96
89
|
return false;
|
97
90
|
}
|
98
91
|
|
@@ -119,146 +112,168 @@ static int has_cr_in_index(const git_filter_source *src)
|
|
119
112
|
return found_cr;
|
120
113
|
}
|
121
114
|
|
122
|
-
static int
|
123
|
-
struct crlf_attrs *ca,
|
124
|
-
git_buf *to,
|
125
|
-
const git_buf *from,
|
126
|
-
const git_filter_source *src)
|
115
|
+
static int text_eol_is_crlf(struct crlf_attrs *ca)
|
127
116
|
{
|
128
|
-
|
129
|
-
|
117
|
+
if (ca->auto_crlf == GIT_AUTO_CRLF_TRUE)
|
118
|
+
return 1;
|
119
|
+
else if (ca->auto_crlf == GIT_AUTO_CRLF_INPUT)
|
130
120
|
return 0;
|
131
121
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
git_buf_text_stats stats;
|
122
|
+
if (ca->core_eol == GIT_EOL_CRLF)
|
123
|
+
return 1;
|
124
|
+
if (ca->core_eol == GIT_EOL_UNSET && GIT_EOL_NATIVE == GIT_EOL_CRLF)
|
125
|
+
return 1;
|
137
126
|
|
138
|
-
|
139
|
-
|
140
|
-
return GIT_PASSTHROUGH;
|
127
|
+
return 0;
|
128
|
+
}
|
141
129
|
|
142
|
-
|
143
|
-
|
144
|
-
|
130
|
+
static git_cvar_value output_eol(struct crlf_attrs *ca)
|
131
|
+
{
|
132
|
+
switch (ca->crlf_action) {
|
133
|
+
case GIT_CRLF_BINARY:
|
134
|
+
return GIT_EOL_UNSET;
|
135
|
+
case GIT_CRLF_TEXT_CRLF:
|
136
|
+
return GIT_EOL_CRLF;
|
137
|
+
case GIT_CRLF_TEXT_INPUT:
|
138
|
+
return GIT_EOL_LF;
|
139
|
+
case GIT_CRLF_UNDEFINED:
|
140
|
+
case GIT_CRLF_AUTO_CRLF:
|
141
|
+
return GIT_EOL_CRLF;
|
142
|
+
case GIT_CRLF_AUTO_INPUT:
|
143
|
+
return GIT_EOL_LF;
|
144
|
+
case GIT_CRLF_TEXT:
|
145
|
+
case GIT_CRLF_AUTO:
|
146
|
+
return text_eol_is_crlf(ca) ? GIT_EOL_CRLF : GIT_EOL_LF;
|
147
|
+
}
|
148
|
+
|
149
|
+
/* TODO: warn when available */
|
150
|
+
return ca->core_eol;
|
151
|
+
}
|
152
|
+
|
153
|
+
GIT_INLINE(int) check_safecrlf(
|
154
|
+
struct crlf_attrs *ca,
|
155
|
+
const git_filter_source *src,
|
156
|
+
git_buf_text_stats *stats)
|
157
|
+
{
|
158
|
+
const char *filename = git_filter_source_path(src);
|
159
|
+
|
160
|
+
if (!ca->safe_crlf)
|
161
|
+
return 0;
|
162
|
+
|
163
|
+
if (output_eol(ca) == GIT_EOL_LF) {
|
164
|
+
/*
|
165
|
+
* CRLFs would not be restored by checkout:
|
166
|
+
* check if we'd remove CRLFs
|
167
|
+
*/
|
168
|
+
if (stats->crlf) {
|
169
|
+
if (ca->safe_crlf == GIT_SAFE_CRLF_WARN) {
|
170
|
+
/* TODO: issue a warning when available */
|
171
|
+
} else {
|
172
|
+
if (filename && *filename)
|
173
|
+
git_error_set(
|
174
|
+
GIT_ERROR_FILTER, "CRLF would be replaced by LF in '%s'",
|
175
|
+
filename);
|
176
|
+
else
|
177
|
+
git_error_set(
|
178
|
+
GIT_ERROR_FILTER, "CRLF would be replaced by LF");
|
145
179
|
|
146
|
-
/* If safecrlf is enabled, sanity-check the result. */
|
147
|
-
if (stats.cr != stats.crlf || stats.lf != stats.crlf) {
|
148
|
-
switch (ca->safe_crlf) {
|
149
|
-
case GIT_SAFE_CRLF_FAIL:
|
150
|
-
giterr_set(
|
151
|
-
GITERR_FILTER, "LF would be replaced by CRLF in '%s'",
|
152
|
-
git_filter_source_path(src));
|
153
180
|
return -1;
|
154
|
-
case GIT_SAFE_CRLF_WARN:
|
155
|
-
/* TODO: issue warning when warning API is available */;
|
156
|
-
break;
|
157
|
-
default:
|
158
|
-
break;
|
159
181
|
}
|
160
182
|
}
|
161
|
-
|
183
|
+
} else if (output_eol(ca) == GIT_EOL_CRLF) {
|
162
184
|
/*
|
163
|
-
*
|
164
|
-
*
|
165
|
-
* stuff?
|
185
|
+
* CRLFs would be added by checkout:
|
186
|
+
* check if we have "naked" LFs
|
166
187
|
*/
|
167
|
-
if (stats
|
168
|
-
|
188
|
+
if (stats->crlf != stats->lf) {
|
189
|
+
if (ca->safe_crlf == GIT_SAFE_CRLF_WARN) {
|
190
|
+
/* TODO: issue a warning when available */
|
191
|
+
} else {
|
192
|
+
if (filename && *filename)
|
193
|
+
git_error_set(
|
194
|
+
GIT_ERROR_FILTER, "LF would be replaced by CRLF in '%s'",
|
195
|
+
filename);
|
196
|
+
else
|
197
|
+
git_error_set(
|
198
|
+
GIT_ERROR_FILTER, "LF would be replaced by CRLF");
|
169
199
|
|
170
|
-
|
171
|
-
|
172
|
-
* If the file in the index has any CR in it, do not convert.
|
173
|
-
* This is the new safer autocrlf handling.
|
174
|
-
*/
|
175
|
-
if (has_cr_in_index(src))
|
176
|
-
return GIT_PASSTHROUGH;
|
200
|
+
return -1;
|
201
|
+
}
|
177
202
|
}
|
178
|
-
|
179
|
-
if (!stats.cr)
|
180
|
-
return GIT_PASSTHROUGH;
|
181
203
|
}
|
182
204
|
|
183
|
-
|
184
|
-
return git_buf_text_crlf_to_lf(to, from);
|
205
|
+
return 0;
|
185
206
|
}
|
186
207
|
|
187
|
-
static
|
208
|
+
static int crlf_apply_to_odb(
|
209
|
+
struct crlf_attrs *ca,
|
210
|
+
git_buf *to,
|
211
|
+
const git_buf *from,
|
212
|
+
const git_filter_source *src)
|
188
213
|
{
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
return "\n";
|
214
|
+
git_buf_text_stats stats;
|
215
|
+
bool is_binary;
|
216
|
+
int error;
|
193
217
|
|
194
|
-
|
195
|
-
|
218
|
+
/* Binary attribute? Empty file? Nothing to do */
|
219
|
+
if (ca->crlf_action == GIT_CRLF_BINARY || !git_buf_len(from))
|
220
|
+
return GIT_PASSTHROUGH;
|
196
221
|
|
197
|
-
|
198
|
-
if (ca->auto_crlf == GIT_AUTO_CRLF_FALSE)
|
199
|
-
return "\n";
|
200
|
-
break;
|
222
|
+
is_binary = git_buf_text_gather_stats(&stats, from, false);
|
201
223
|
|
202
|
-
|
203
|
-
|
204
|
-
|
224
|
+
/* Heuristics to see if we can skip the conversion.
|
225
|
+
* Straight from Core Git.
|
226
|
+
*/
|
227
|
+
if (ca->crlf_action == GIT_CRLF_AUTO ||
|
228
|
+
ca->crlf_action == GIT_CRLF_AUTO_INPUT ||
|
229
|
+
ca->crlf_action == GIT_CRLF_AUTO_CRLF) {
|
230
|
+
|
231
|
+
if (is_binary)
|
232
|
+
return GIT_PASSTHROUGH;
|
205
233
|
|
206
|
-
|
207
|
-
|
234
|
+
/*
|
235
|
+
* If the file in the index has any CR in it, do not convert.
|
236
|
+
* This is the new safer autocrlf handling.
|
237
|
+
*/
|
238
|
+
if (has_cr_in_index(src))
|
239
|
+
return GIT_PASSTHROUGH;
|
208
240
|
}
|
209
241
|
|
210
|
-
if (ca
|
211
|
-
return
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
return
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
return "\r\n";
|
220
|
-
|
221
|
-
line_ending_error:
|
222
|
-
giterr_set(GITERR_INVALID, "invalid input to line ending filter");
|
223
|
-
return NULL;
|
242
|
+
if ((error = check_safecrlf(ca, src, &stats)) < 0)
|
243
|
+
return error;
|
244
|
+
|
245
|
+
/* If there are no CR characters to filter out, then just pass */
|
246
|
+
if (!stats.crlf)
|
247
|
+
return GIT_PASSTHROUGH;
|
248
|
+
|
249
|
+
/* Actually drop the carriage returns */
|
250
|
+
return git_buf_text_crlf_to_lf(to, from);
|
224
251
|
}
|
225
252
|
|
226
253
|
static int crlf_apply_to_workdir(
|
227
|
-
struct crlf_attrs *ca,
|
254
|
+
struct crlf_attrs *ca,
|
255
|
+
git_buf *to,
|
256
|
+
const git_buf *from)
|
228
257
|
{
|
229
258
|
git_buf_text_stats stats;
|
230
|
-
const char *workdir_ending = NULL;
|
231
259
|
bool is_binary;
|
232
260
|
|
233
261
|
/* Empty file? Nothing to do. */
|
234
|
-
if (git_buf_len(from) == 0)
|
235
|
-
return 0;
|
236
|
-
|
237
|
-
/* Determine proper line ending */
|
238
|
-
workdir_ending = line_ending(ca);
|
239
|
-
if (!workdir_ending)
|
240
|
-
return -1;
|
241
|
-
|
242
|
-
/* only LF->CRLF conversion is supported, do nothing on LF platforms */
|
243
|
-
if (strcmp(workdir_ending, "\r\n") != 0)
|
262
|
+
if (git_buf_len(from) == 0 || output_eol(ca) != GIT_EOL_CRLF)
|
244
263
|
return GIT_PASSTHROUGH;
|
245
264
|
|
246
|
-
/* If there are no LFs, or all LFs are part of a CRLF, nothing to do */
|
247
265
|
is_binary = git_buf_text_gather_stats(&stats, from, false);
|
248
266
|
|
267
|
+
/* If there are no LFs, or all LFs are part of a CRLF, nothing to do */
|
249
268
|
if (stats.lf == 0 || stats.lf == stats.crlf)
|
250
269
|
return GIT_PASSTHROUGH;
|
251
270
|
|
252
271
|
if (ca->crlf_action == GIT_CRLF_AUTO ||
|
253
|
-
ca->crlf_action ==
|
272
|
+
ca->crlf_action == GIT_CRLF_AUTO_INPUT ||
|
273
|
+
ca->crlf_action == GIT_CRLF_AUTO_CRLF) {
|
254
274
|
|
255
275
|
/* If we have any existing CR or CRLF line endings, do nothing */
|
256
|
-
if (
|
257
|
-
stats.cr > 0 && stats.crlf > 0)
|
258
|
-
return GIT_PASSTHROUGH;
|
259
|
-
|
260
|
-
/* If we have bare CR characters, do nothing */
|
261
|
-
if (stats.cr != stats.crlf)
|
276
|
+
if (stats.cr > 0)
|
262
277
|
return GIT_PASSTHROUGH;
|
263
278
|
|
264
279
|
/* Don't filter binary files */
|
@@ -269,85 +284,99 @@ static int crlf_apply_to_workdir(
|
|
269
284
|
return git_buf_text_lf_to_crlf(to, from);
|
270
285
|
}
|
271
286
|
|
272
|
-
static int
|
273
|
-
|
274
|
-
|
275
|
-
const git_filter_source *src
|
276
|
-
const char **attr_values)
|
287
|
+
static int convert_attrs(
|
288
|
+
struct crlf_attrs *ca,
|
289
|
+
const char **attr_values,
|
290
|
+
const git_filter_source *src)
|
277
291
|
{
|
278
292
|
int error;
|
279
|
-
struct crlf_attrs ca;
|
280
293
|
|
281
|
-
|
294
|
+
memset(ca, 0, sizeof(struct crlf_attrs));
|
295
|
+
|
296
|
+
if ((error = git_repository__cvar(&ca->auto_crlf,
|
297
|
+
git_filter_source_repo(src), GIT_CVAR_AUTO_CRLF)) < 0 ||
|
298
|
+
(error = git_repository__cvar(&ca->safe_crlf,
|
299
|
+
git_filter_source_repo(src), GIT_CVAR_SAFE_CRLF)) < 0 ||
|
300
|
+
(error = git_repository__cvar(&ca->core_eol,
|
301
|
+
git_filter_source_repo(src), GIT_CVAR_EOL)) < 0)
|
302
|
+
return error;
|
303
|
+
|
304
|
+
/* downgrade FAIL to WARN if ALLOW_UNSAFE option is used */
|
305
|
+
if ((git_filter_source_flags(src) & GIT_FILTER_ALLOW_UNSAFE) &&
|
306
|
+
ca->safe_crlf == GIT_SAFE_CRLF_FAIL)
|
307
|
+
ca->safe_crlf = GIT_SAFE_CRLF_WARN;
|
308
|
+
|
309
|
+
if (attr_values) {
|
310
|
+
/* load the text attribute */
|
311
|
+
ca->crlf_action = check_crlf(attr_values[2]); /* text */
|
312
|
+
|
313
|
+
if (ca->crlf_action == GIT_CRLF_UNDEFINED)
|
314
|
+
ca->crlf_action = check_crlf(attr_values[0]); /* crlf */
|
315
|
+
|
316
|
+
if (ca->crlf_action != GIT_CRLF_BINARY) {
|
317
|
+
/* load the eol attribute */
|
318
|
+
int eol_attr = check_eol(attr_values[1]);
|
319
|
+
|
320
|
+
if (ca->crlf_action == GIT_CRLF_AUTO && eol_attr == GIT_EOL_LF)
|
321
|
+
ca->crlf_action = GIT_CRLF_AUTO_INPUT;
|
322
|
+
else if (ca->crlf_action == GIT_CRLF_AUTO && eol_attr == GIT_EOL_CRLF)
|
323
|
+
ca->crlf_action = GIT_CRLF_AUTO_CRLF;
|
324
|
+
else if (eol_attr == GIT_EOL_LF)
|
325
|
+
ca->crlf_action = GIT_CRLF_TEXT_INPUT;
|
326
|
+
else if (eol_attr == GIT_EOL_CRLF)
|
327
|
+
ca->crlf_action = GIT_CRLF_TEXT_CRLF;
|
328
|
+
}
|
282
329
|
|
283
|
-
|
284
|
-
ca.crlf_action = GIT_CRLF_GUESS;
|
285
|
-
ca.eol = GIT_EOL_UNSET;
|
330
|
+
ca->attr_action = ca->crlf_action;
|
286
331
|
} else {
|
287
|
-
ca
|
288
|
-
if (ca.crlf_action == GIT_CRLF_GUESS)
|
289
|
-
ca.crlf_action = check_crlf(attr_values[0]); /* clrf */
|
290
|
-
ca.eol = check_eol(attr_values[1]); /* eol */
|
332
|
+
ca->crlf_action = GIT_CRLF_UNDEFINED;
|
291
333
|
}
|
292
|
-
ca.auto_crlf = GIT_AUTO_CRLF_DEFAULT;
|
293
|
-
ca.safe_crlf = GIT_SAFE_CRLF_DEFAULT;
|
294
334
|
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
ca
|
335
|
+
if (ca->crlf_action == GIT_CRLF_TEXT)
|
336
|
+
ca->crlf_action = text_eol_is_crlf(ca) ? GIT_CRLF_TEXT_CRLF : GIT_CRLF_TEXT_INPUT;
|
337
|
+
if (ca->crlf_action == GIT_CRLF_UNDEFINED && ca->auto_crlf == GIT_AUTO_CRLF_FALSE)
|
338
|
+
ca->crlf_action = GIT_CRLF_BINARY;
|
339
|
+
if (ca->crlf_action == GIT_CRLF_UNDEFINED && ca->auto_crlf == GIT_AUTO_CRLF_TRUE)
|
340
|
+
ca->crlf_action = GIT_CRLF_AUTO_CRLF;
|
341
|
+
if (ca->crlf_action == GIT_CRLF_UNDEFINED && ca->auto_crlf == GIT_AUTO_CRLF_INPUT)
|
342
|
+
ca->crlf_action = GIT_CRLF_AUTO_INPUT;
|
300
343
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
if (ca.crlf_action == GIT_CRLF_GUESS ||
|
305
|
-
((ca.crlf_action == GIT_CRLF_AUTO || ca.crlf_action == GIT_CRLF_TEXT) &&
|
306
|
-
git_filter_source_mode(src) == GIT_FILTER_SMUDGE)) {
|
307
|
-
|
308
|
-
error = git_repository__cvar(
|
309
|
-
&ca.auto_crlf, git_filter_source_repo(src), GIT_CVAR_AUTO_CRLF);
|
310
|
-
if (error < 0)
|
311
|
-
return error;
|
344
|
+
return 0;
|
345
|
+
}
|
312
346
|
|
313
|
-
|
314
|
-
|
315
|
-
|
347
|
+
static int crlf_check(
|
348
|
+
git_filter *self,
|
349
|
+
void **payload, /* points to NULL ptr on entry, may be set */
|
350
|
+
const git_filter_source *src,
|
351
|
+
const char **attr_values)
|
352
|
+
{
|
353
|
+
struct crlf_attrs ca;
|
316
354
|
|
317
|
-
|
318
|
-
git_filter_source_mode(src) == GIT_FILTER_SMUDGE)
|
319
|
-
return GIT_PASSTHROUGH;
|
320
|
-
}
|
355
|
+
GIT_UNUSED(self);
|
321
356
|
|
322
|
-
|
323
|
-
error = git_repository__cvar(
|
324
|
-
&ca.safe_crlf, git_filter_source_repo(src), GIT_CVAR_SAFE_CRLF);
|
325
|
-
if (error < 0)
|
326
|
-
return error;
|
357
|
+
convert_attrs(&ca, attr_values, src);
|
327
358
|
|
328
|
-
|
329
|
-
|
330
|
-
ca.safe_crlf == GIT_SAFE_CRLF_FAIL)
|
331
|
-
ca.safe_crlf = GIT_SAFE_CRLF_WARN;
|
332
|
-
}
|
359
|
+
if (ca.crlf_action == GIT_CRLF_BINARY)
|
360
|
+
return GIT_PASSTHROUGH;
|
333
361
|
|
334
362
|
*payload = git__malloc(sizeof(ca));
|
335
|
-
|
363
|
+
GIT_ERROR_CHECK_ALLOC(*payload);
|
336
364
|
memcpy(*payload, &ca, sizeof(ca));
|
337
365
|
|
338
366
|
return 0;
|
339
367
|
}
|
340
368
|
|
341
369
|
static int crlf_apply(
|
342
|
-
git_filter
|
343
|
-
void
|
344
|
-
git_buf
|
370
|
+
git_filter *self,
|
371
|
+
void **payload, /* may be read and/or set */
|
372
|
+
git_buf *to,
|
345
373
|
const git_buf *from,
|
346
374
|
const git_filter_source *src)
|
347
375
|
{
|
348
376
|
/* initialize payload in case `check` was bypassed */
|
349
377
|
if (!*payload) {
|
350
378
|
int error = crlf_check(self, payload, src, NULL);
|
379
|
+
|
351
380
|
if (error < 0)
|
352
381
|
return error;
|
353
382
|
}
|