rugged 0.17.0.b7 → 0.18.0.b1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.md +88 -32
- data/ext/rugged/extconf.rb +4 -2
- data/ext/rugged/rugged.c +72 -10
- data/ext/rugged/rugged.h +14 -10
- data/ext/rugged/rugged_blob.c +8 -10
- data/ext/rugged/rugged_branch.c +11 -14
- data/ext/rugged/rugged_commit.c +31 -24
- data/ext/rugged/rugged_config.c +2 -2
- data/ext/rugged/rugged_index.c +133 -198
- data/ext/rugged/rugged_note.c +372 -0
- data/ext/rugged/rugged_object.c +50 -22
- data/ext/rugged/rugged_reference.c +122 -130
- data/ext/rugged/rugged_remote.c +72 -29
- data/ext/rugged/rugged_repo.c +402 -20
- data/ext/rugged/rugged_revwalk.c +7 -3
- data/ext/rugged/rugged_settings.c +110 -0
- data/ext/rugged/rugged_signature.c +23 -7
- data/ext/rugged/rugged_tag.c +32 -16
- data/ext/rugged/rugged_tree.c +44 -15
- data/lib/rugged.rb +1 -0
- data/lib/rugged/index.rb +8 -0
- data/lib/rugged/remote.rb +13 -0
- data/lib/rugged/repository.rb +3 -3
- data/lib/rugged/version.rb +1 -1
- data/test/blob_test.rb +13 -15
- data/test/branch_test.rb +32 -67
- data/test/commit_test.rb +50 -12
- data/test/config_test.rb +12 -11
- data/test/coverage/HEAD.json +1 -1
- data/test/coverage/cover.rb +40 -21
- data/test/errors_test.rb +34 -0
- data/test/fixtures/alternate/objects/14/6ae76773c91e3b1d00cf7a338ec55ae58297e2 +0 -0
- data/test/fixtures/alternate/objects/14/9c32d47e99d0a3572ff1e70a2e0051bbf347a9 +0 -0
- data/test/fixtures/alternate/objects/14/fb3108588f9421bf764041e5e3ac305eb6277f +0 -0
- data/test/fixtures/testrepo.git/logs/refs/notes/commits +1 -0
- data/test/fixtures/testrepo.git/objects/44/1034f860c1d5d90e4188d11ae0d325176869a8 +1 -0
- data/test/fixtures/testrepo.git/objects/60/d415052a33de2150bf68757f6461df4f563ae4 +0 -0
- data/test/fixtures/testrepo.git/objects/68/8a8f4ef7496901d15322972f96e212a9e466cc +1 -0
- data/test/fixtures/testrepo.git/objects/94/eca2de348d5f672faf56b0decafa5937e3235e +0 -0
- data/test/fixtures/testrepo.git/objects/9b/7384fe1676186192842f5d3e129457b62db9e3 +0 -0
- data/test/fixtures/testrepo.git/objects/b7/4713326bc972cc15751ed504dca6f6f3b91f7a +3 -0
- data/test/fixtures/testrepo.git/refs/notes/commits +1 -0
- data/test/index_test.rb +65 -69
- data/test/lib_test.rb +76 -11
- data/test/note_test.rb +158 -0
- data/test/object_test.rb +8 -11
- data/test/reference_test.rb +77 -85
- data/test/remote_test.rb +86 -8
- data/test/repo_pack_test.rb +9 -7
- data/test/repo_reset_test.rb +80 -0
- data/test/repo_test.rb +176 -53
- data/test/tag_test.rb +44 -7
- data/test/test_helper.rb +63 -35
- data/test/tree_test.rb +34 -13
- data/test/walker_test.rb +14 -14
- data/vendor/libgit2/Makefile.embed +1 -1
- data/vendor/libgit2/deps/http-parser/http_parser.c +974 -578
- data/vendor/libgit2/deps/http-parser/http_parser.h +106 -70
- data/vendor/libgit2/deps/regex/regcomp.c +7 -6
- data/vendor/libgit2/deps/regex/regex_internal.c +1 -1
- data/vendor/libgit2/deps/regex/regex_internal.h +12 -3
- data/vendor/libgit2/deps/regex/regexec.c +5 -5
- data/vendor/libgit2/include/git2.h +5 -1
- data/vendor/libgit2/include/git2/attr.h +4 -2
- data/vendor/libgit2/include/git2/blob.h +39 -12
- data/vendor/libgit2/include/git2/branch.h +123 -35
- data/vendor/libgit2/include/git2/checkout.h +206 -48
- data/vendor/libgit2/include/git2/clone.h +72 -27
- data/vendor/libgit2/include/git2/commit.h +20 -17
- data/vendor/libgit2/include/git2/common.h +67 -1
- data/vendor/libgit2/include/git2/config.h +81 -60
- data/vendor/libgit2/include/git2/cred_helpers.h +53 -0
- data/vendor/libgit2/include/git2/diff.h +459 -150
- data/vendor/libgit2/include/git2/errors.h +9 -1
- data/vendor/libgit2/include/git2/graph.h +41 -0
- data/vendor/libgit2/include/git2/ignore.h +7 -6
- data/vendor/libgit2/include/git2/index.h +323 -97
- data/vendor/libgit2/include/git2/indexer.h +27 -59
- data/vendor/libgit2/include/git2/inttypes.h +4 -0
- data/vendor/libgit2/include/git2/merge.h +13 -3
- data/vendor/libgit2/include/git2/message.h +14 -8
- data/vendor/libgit2/include/git2/net.h +9 -7
- data/vendor/libgit2/include/git2/notes.h +88 -29
- data/vendor/libgit2/include/git2/object.h +16 -6
- data/vendor/libgit2/include/git2/odb.h +80 -17
- data/vendor/libgit2/include/git2/odb_backend.h +47 -11
- data/vendor/libgit2/include/git2/oid.h +26 -17
- data/vendor/libgit2/include/git2/pack.h +62 -8
- data/vendor/libgit2/include/git2/push.h +131 -0
- data/vendor/libgit2/include/git2/refdb.h +103 -0
- data/vendor/libgit2/include/git2/refdb_backend.h +109 -0
- data/vendor/libgit2/include/git2/reflog.h +30 -21
- data/vendor/libgit2/include/git2/refs.h +215 -193
- data/vendor/libgit2/include/git2/refspec.h +22 -2
- data/vendor/libgit2/include/git2/remote.h +158 -37
- data/vendor/libgit2/include/git2/repository.h +150 -31
- data/vendor/libgit2/include/git2/reset.h +43 -9
- data/vendor/libgit2/include/git2/revparse.h +48 -4
- data/vendor/libgit2/include/git2/revwalk.h +25 -10
- data/vendor/libgit2/include/git2/signature.h +20 -12
- data/vendor/libgit2/include/git2/stash.h +121 -0
- data/vendor/libgit2/include/git2/status.h +122 -53
- data/vendor/libgit2/include/git2/strarray.h +17 -11
- data/vendor/libgit2/include/git2/submodule.h +42 -7
- data/vendor/libgit2/include/git2/tag.h +72 -59
- data/vendor/libgit2/include/git2/threads.h +4 -2
- data/vendor/libgit2/include/git2/trace.h +68 -0
- data/vendor/libgit2/include/git2/transport.h +328 -0
- data/vendor/libgit2/include/git2/tree.h +149 -120
- data/vendor/libgit2/include/git2/types.h +13 -12
- data/vendor/libgit2/include/git2/version.h +3 -3
- data/vendor/libgit2/src/amiga/map.c +2 -2
- data/vendor/libgit2/src/attr.c +58 -48
- data/vendor/libgit2/src/attr.h +4 -18
- data/vendor/libgit2/src/attr_file.c +30 -6
- data/vendor/libgit2/src/attr_file.h +6 -8
- data/vendor/libgit2/src/attrcache.h +24 -0
- data/vendor/libgit2/src/blob.c +30 -7
- data/vendor/libgit2/src/blob.h +1 -1
- data/vendor/libgit2/src/branch.c +361 -68
- data/vendor/libgit2/src/branch.h +17 -0
- data/vendor/libgit2/src/bswap.h +1 -1
- data/vendor/libgit2/src/buf_text.c +291 -0
- data/vendor/libgit2/src/buf_text.h +122 -0
- data/vendor/libgit2/src/buffer.c +27 -101
- data/vendor/libgit2/src/buffer.h +54 -39
- data/vendor/libgit2/src/cache.c +15 -6
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/cc-compat.h +3 -1
- data/vendor/libgit2/src/checkout.c +1165 -222
- data/vendor/libgit2/src/checkout.h +24 -0
- data/vendor/libgit2/src/clone.c +171 -86
- data/vendor/libgit2/src/commit.c +44 -45
- data/vendor/libgit2/src/commit.h +3 -3
- data/vendor/libgit2/src/commit_list.c +194 -0
- data/vendor/libgit2/src/commit_list.h +49 -0
- data/vendor/libgit2/src/common.h +44 -10
- data/vendor/libgit2/src/compress.c +1 -1
- data/vendor/libgit2/src/compress.h +1 -1
- data/vendor/libgit2/src/config.c +211 -124
- data/vendor/libgit2/src/config.h +23 -4
- data/vendor/libgit2/src/config_cache.c +2 -2
- data/vendor/libgit2/src/config_file.c +129 -53
- data/vendor/libgit2/src/config_file.h +10 -8
- data/vendor/libgit2/src/crlf.c +66 -67
- data/vendor/libgit2/src/date.c +12 -12
- data/vendor/libgit2/src/delta-apply.c +14 -1
- data/vendor/libgit2/src/delta-apply.h +18 -1
- data/vendor/libgit2/src/delta.c +40 -107
- data/vendor/libgit2/src/delta.h +19 -17
- data/vendor/libgit2/src/diff.c +347 -496
- data/vendor/libgit2/src/diff.h +27 -1
- data/vendor/libgit2/src/diff_output.c +564 -249
- data/vendor/libgit2/src/diff_output.h +15 -8
- data/vendor/libgit2/src/diff_tform.c +687 -0
- data/vendor/libgit2/src/errors.c +27 -36
- data/vendor/libgit2/src/fetch.c +13 -351
- data/vendor/libgit2/src/fetch.h +13 -3
- data/vendor/libgit2/src/fetchhead.c +295 -0
- data/vendor/libgit2/src/fetchhead.h +34 -0
- data/vendor/libgit2/src/filebuf.c +42 -15
- data/vendor/libgit2/src/filebuf.h +4 -2
- data/vendor/libgit2/src/fileops.c +466 -113
- data/vendor/libgit2/src/fileops.h +154 -28
- data/vendor/libgit2/src/filter.c +3 -75
- data/vendor/libgit2/src/filter.h +1 -29
- data/vendor/libgit2/src/fnmatch.c +1 -1
- data/vendor/libgit2/src/fnmatch.h +1 -1
- data/vendor/libgit2/src/global.c +54 -10
- data/vendor/libgit2/src/global.h +10 -1
- data/vendor/libgit2/src/graph.c +178 -0
- data/vendor/libgit2/src/hash.c +25 -52
- data/vendor/libgit2/src/hash.h +21 -9
- data/vendor/libgit2/src/{sha1/sha1.c → hash/hash_generic.c} +20 -12
- data/vendor/libgit2/src/hash/hash_generic.h +24 -0
- data/vendor/libgit2/src/hash/hash_openssl.h +45 -0
- data/vendor/libgit2/src/hash/hash_win32.c +291 -0
- data/vendor/libgit2/src/hash/hash_win32.h +140 -0
- data/vendor/libgit2/src/hashsig.c +368 -0
- data/vendor/libgit2/src/hashsig.h +72 -0
- data/vendor/libgit2/src/ignore.c +22 -15
- data/vendor/libgit2/src/ignore.h +6 -1
- data/vendor/libgit2/src/index.c +770 -171
- data/vendor/libgit2/src/index.h +13 -5
- data/vendor/libgit2/src/indexer.c +286 -431
- data/vendor/libgit2/src/iterator.c +854 -466
- data/vendor/libgit2/src/iterator.h +134 -109
- data/vendor/libgit2/src/map.h +1 -1
- data/vendor/libgit2/src/merge.c +296 -0
- data/vendor/libgit2/src/merge.h +22 -0
- data/vendor/libgit2/src/message.c +1 -1
- data/vendor/libgit2/src/message.h +1 -1
- data/vendor/libgit2/src/mwindow.c +35 -30
- data/vendor/libgit2/src/mwindow.h +2 -2
- data/vendor/libgit2/src/netops.c +162 -98
- data/vendor/libgit2/src/netops.h +50 -15
- data/vendor/libgit2/src/notes.c +109 -58
- data/vendor/libgit2/src/notes.h +2 -1
- data/vendor/libgit2/src/object.c +46 -57
- data/vendor/libgit2/src/object.h +1 -8
- data/vendor/libgit2/src/odb.c +151 -40
- data/vendor/libgit2/src/odb.h +5 -1
- data/vendor/libgit2/src/odb_loose.c +4 -5
- data/vendor/libgit2/src/odb_pack.c +122 -80
- data/vendor/libgit2/src/offmap.h +65 -0
- data/vendor/libgit2/src/oid.c +12 -4
- data/vendor/libgit2/src/oidmap.h +1 -1
- data/vendor/libgit2/src/pack-objects.c +88 -61
- data/vendor/libgit2/src/pack-objects.h +8 -8
- data/vendor/libgit2/src/pack.c +293 -28
- data/vendor/libgit2/src/pack.h +49 -4
- data/vendor/libgit2/src/path.c +103 -14
- data/vendor/libgit2/src/path.h +23 -7
- data/vendor/libgit2/src/pathspec.c +168 -0
- data/vendor/libgit2/src/pathspec.h +40 -0
- data/vendor/libgit2/src/pool.c +29 -4
- data/vendor/libgit2/src/pool.h +8 -1
- data/vendor/libgit2/src/posix.c +26 -27
- data/vendor/libgit2/src/posix.h +2 -3
- data/vendor/libgit2/src/pqueue.c +23 -1
- data/vendor/libgit2/src/pqueue.h +23 -1
- data/vendor/libgit2/src/push.c +653 -0
- data/vendor/libgit2/src/push.h +51 -0
- data/vendor/libgit2/src/refdb.c +185 -0
- data/vendor/libgit2/src/refdb.h +46 -0
- data/vendor/libgit2/src/refdb_fs.c +1024 -0
- data/vendor/libgit2/src/refdb_fs.h +15 -0
- data/vendor/libgit2/src/reflog.c +77 -45
- data/vendor/libgit2/src/reflog.h +1 -3
- data/vendor/libgit2/src/refs.c +366 -1326
- data/vendor/libgit2/src/refs.h +22 -13
- data/vendor/libgit2/src/refspec.c +46 -7
- data/vendor/libgit2/src/refspec.h +11 -1
- data/vendor/libgit2/src/remote.c +758 -120
- data/vendor/libgit2/src/remote.h +10 -5
- data/vendor/libgit2/src/repo_template.h +6 -6
- data/vendor/libgit2/src/repository.c +315 -96
- data/vendor/libgit2/src/repository.h +5 -3
- data/vendor/libgit2/src/reset.c +99 -81
- data/vendor/libgit2/src/revparse.c +157 -84
- data/vendor/libgit2/src/revwalk.c +68 -470
- data/vendor/libgit2/src/revwalk.h +44 -0
- data/vendor/libgit2/src/sha1_lookup.c +1 -1
- data/vendor/libgit2/src/sha1_lookup.h +1 -1
- data/vendor/libgit2/src/signature.c +68 -200
- data/vendor/libgit2/src/signature.h +1 -1
- data/vendor/libgit2/src/stash.c +663 -0
- data/vendor/libgit2/src/status.c +101 -79
- data/vendor/libgit2/src/strmap.h +1 -1
- data/vendor/libgit2/src/submodule.c +67 -51
- data/vendor/libgit2/src/submodule.h +1 -1
- data/vendor/libgit2/src/tag.c +35 -29
- data/vendor/libgit2/src/tag.h +1 -1
- data/vendor/libgit2/src/thread-utils.c +1 -1
- data/vendor/libgit2/src/thread-utils.h +2 -2
- data/vendor/libgit2/src/trace.c +39 -0
- data/vendor/libgit2/src/trace.h +56 -0
- data/vendor/libgit2/src/transport.c +81 -34
- data/vendor/libgit2/src/transports/cred.c +60 -0
- data/vendor/libgit2/src/transports/cred_helpers.c +49 -0
- data/vendor/libgit2/src/transports/git.c +234 -127
- data/vendor/libgit2/src/transports/http.c +761 -433
- data/vendor/libgit2/src/transports/local.c +460 -64
- data/vendor/libgit2/src/transports/smart.c +345 -0
- data/vendor/libgit2/src/transports/smart.h +179 -0
- data/vendor/libgit2/src/{pkt.c → transports/smart_pkt.c} +131 -12
- data/vendor/libgit2/src/transports/smart_protocol.c +856 -0
- data/vendor/libgit2/src/transports/winhttp.c +1136 -0
- data/vendor/libgit2/src/tree-cache.c +2 -2
- data/vendor/libgit2/src/tree-cache.h +1 -1
- data/vendor/libgit2/src/tree.c +239 -166
- data/vendor/libgit2/src/tree.h +11 -2
- data/vendor/libgit2/src/tsort.c +39 -23
- data/vendor/libgit2/src/unix/map.c +1 -1
- data/vendor/libgit2/src/unix/posix.h +12 -2
- data/vendor/libgit2/src/unix/realpath.c +30 -0
- data/vendor/libgit2/src/util.c +250 -13
- data/vendor/libgit2/src/util.h +71 -14
- data/vendor/libgit2/src/vector.c +123 -60
- data/vendor/libgit2/src/vector.h +24 -22
- data/vendor/libgit2/src/win32/dir.c +1 -1
- data/vendor/libgit2/src/win32/dir.h +1 -1
- data/vendor/libgit2/src/win32/error.c +77 -0
- data/vendor/libgit2/src/win32/error.h +13 -0
- data/vendor/libgit2/src/win32/findfile.c +143 -54
- data/vendor/libgit2/src/win32/findfile.h +10 -6
- data/vendor/libgit2/src/win32/map.c +1 -1
- data/vendor/libgit2/src/win32/mingw-compat.h +1 -1
- data/vendor/libgit2/src/win32/msvc-compat.h +10 -1
- data/vendor/libgit2/src/win32/posix.h +10 -1
- data/vendor/libgit2/src/win32/posix_w32.c +132 -63
- data/vendor/libgit2/src/win32/precompiled.c +1 -1
- data/vendor/libgit2/src/win32/pthread.c +1 -1
- data/vendor/libgit2/src/win32/pthread.h +1 -1
- data/vendor/libgit2/src/win32/utf-conv.c +5 -5
- data/vendor/libgit2/src/win32/utf-conv.h +3 -3
- data/vendor/libgit2/src/win32/version.h +20 -0
- metadata +308 -252
- data/test/fixtures/testrepo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- data/test/fixtures/testrepo.git/objects/7f/043268ea43ce18e3540acaabf9e090c91965b0 +0 -0
- data/test/fixtures/testrepo.git/objects/a3/e05719b428a2d0ed7a55c4ce53dcc5768c6d5e +0 -0
- data/test/index_test.rb~ +0 -218
- data/vendor/libgit2/src/pkt.h +0 -91
- data/vendor/libgit2/src/ppc/sha1.c +0 -70
- data/vendor/libgit2/src/ppc/sha1.h +0 -26
- data/vendor/libgit2/src/protocol.c +0 -110
- data/vendor/libgit2/src/protocol.h +0 -21
- data/vendor/libgit2/src/sha1.h +0 -33
- data/vendor/libgit2/src/transport.h +0 -148
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (C)
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
3
|
*
|
4
4
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
5
|
* a Linking Exception. For full terms see the included COPYING file.
|
@@ -68,6 +68,17 @@ GIT_INLINE(void) git_blob_free(git_blob *blob)
|
|
68
68
|
git_object_free((git_object *) blob);
|
69
69
|
}
|
70
70
|
|
71
|
+
/**
|
72
|
+
* Get the id of a blob.
|
73
|
+
*
|
74
|
+
* @param blob a previously loaded blob.
|
75
|
+
* @return SHA1 hash for this blob.
|
76
|
+
*/
|
77
|
+
GIT_INLINE(const git_oid *) git_blob_id(const git_blob *blob)
|
78
|
+
{
|
79
|
+
return git_object_id((const git_object *)blob);
|
80
|
+
}
|
81
|
+
|
71
82
|
|
72
83
|
/**
|
73
84
|
* Get a read-only buffer with the raw content of a blob.
|
@@ -80,7 +91,7 @@ GIT_INLINE(void) git_blob_free(git_blob *blob)
|
|
80
91
|
* @param blob pointer to the blob
|
81
92
|
* @return the pointer; NULL if the blob has no contents
|
82
93
|
*/
|
83
|
-
GIT_EXTERN(const void *) git_blob_rawcontent(git_blob *blob);
|
94
|
+
GIT_EXTERN(const void *) git_blob_rawcontent(const git_blob *blob);
|
84
95
|
|
85
96
|
/**
|
86
97
|
* Get the size in bytes of the contents of a blob
|
@@ -88,32 +99,35 @@ GIT_EXTERN(const void *) git_blob_rawcontent(git_blob *blob);
|
|
88
99
|
* @param blob pointer to the blob
|
89
100
|
* @return size on bytes
|
90
101
|
*/
|
91
|
-
GIT_EXTERN(
|
102
|
+
GIT_EXTERN(git_off_t) git_blob_rawsize(const git_blob *blob);
|
92
103
|
|
93
104
|
/**
|
94
105
|
* Read a file from the working folder of a repository
|
95
106
|
* and write it to the Object Database as a loose blob
|
96
107
|
*
|
97
|
-
* @param
|
108
|
+
* @param id return the id of the written blob
|
98
109
|
* @param repo repository where the blob will be written.
|
99
110
|
* this repository cannot be bare
|
100
|
-
* @param
|
111
|
+
* @param relative_path file from which the blob will be created,
|
101
112
|
* relative to the repository's working dir
|
102
113
|
* @return 0 or an error code
|
103
114
|
*/
|
104
|
-
GIT_EXTERN(int)
|
115
|
+
GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path);
|
105
116
|
|
106
117
|
/**
|
107
118
|
* Read a file from the filesystem and write its content
|
108
119
|
* to the Object Database as a loose blob
|
109
120
|
*
|
110
|
-
* @param
|
121
|
+
* @param id return the id of the written blob
|
111
122
|
* @param repo repository where the blob will be written.
|
112
123
|
* this repository can be bare or not
|
113
124
|
* @param path file from which the blob will be created
|
114
125
|
* @return 0 or an error code
|
115
126
|
*/
|
116
|
-
GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *
|
127
|
+
GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path);
|
128
|
+
|
129
|
+
|
130
|
+
typedef int (*git_blob_chunk_cb)(char *content, size_t max_length, void *payload);
|
117
131
|
|
118
132
|
/**
|
119
133
|
* Write a loose blob to the Object Database from a
|
@@ -141,7 +155,7 @@ GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *oid, git_repository *repo, con
|
|
141
155
|
* - When an error occurs, the callback should return -1.
|
142
156
|
*
|
143
157
|
*
|
144
|
-
* @param
|
158
|
+
* @param id Return the id of the written blob
|
145
159
|
*
|
146
160
|
* @param repo repository where the blob will be written.
|
147
161
|
* This repository can be bare or not.
|
@@ -149,13 +163,13 @@ GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *oid, git_repository *repo, con
|
|
149
163
|
* @param hintpath if not NULL, will help selecting the filters
|
150
164
|
* to apply onto the content of the blob to be created.
|
151
165
|
*
|
152
|
-
* @return
|
166
|
+
* @return 0 or an error code
|
153
167
|
*/
|
154
168
|
GIT_EXTERN(int) git_blob_create_fromchunks(
|
155
|
-
git_oid *
|
169
|
+
git_oid *id,
|
156
170
|
git_repository *repo,
|
157
171
|
const char *hintpath,
|
158
|
-
|
172
|
+
git_blob_chunk_cb callback,
|
159
173
|
void *payload);
|
160
174
|
|
161
175
|
/**
|
@@ -169,6 +183,19 @@ GIT_EXTERN(int) git_blob_create_fromchunks(
|
|
169
183
|
*/
|
170
184
|
GIT_EXTERN(int) git_blob_create_frombuffer(git_oid *oid, git_repository *repo, const void *buffer, size_t len);
|
171
185
|
|
186
|
+
/**
|
187
|
+
* Determine if the blob content is most certainly binary or not.
|
188
|
+
*
|
189
|
+
* The heuristic used to guess if a file is binary is taken from core git:
|
190
|
+
* Searching for NUL bytes and looking for a reasonable ratio of printable
|
191
|
+
* to non-printable characters among the first 4000 bytes.
|
192
|
+
*
|
193
|
+
* @param blob The blob which content should be analyzed
|
194
|
+
* @return 1 if the content of the blob is detected
|
195
|
+
* as binary; 0 otherwise.
|
196
|
+
*/
|
197
|
+
GIT_EXTERN(int) git_blob_is_binary(git_blob *blob);
|
198
|
+
|
172
199
|
/** @} */
|
173
200
|
GIT_END_DECL
|
174
201
|
#endif
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (C)
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
3
|
*
|
4
4
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
5
|
* a Linking Exception. For full terms see the included COPYING file.
|
@@ -29,29 +29,30 @@ GIT_BEGIN_DECL
|
|
29
29
|
*
|
30
30
|
* The returned reference must be freed by the user.
|
31
31
|
*
|
32
|
-
*
|
32
|
+
* The branch name will be checked for validity.
|
33
|
+
* See `git_tag_create()` for rules about valid names.
|
34
|
+
*
|
35
|
+
* @param out Pointer where to store the underlying reference.
|
33
36
|
*
|
34
37
|
* @param branch_name Name for the branch; this name is
|
35
38
|
* validated for consistency. It should also not conflict with
|
36
39
|
* an already existing branch name.
|
37
40
|
*
|
38
|
-
* @param target
|
39
|
-
* must belong to the given `repo
|
40
|
-
* git_tag. When a git_tag is being passed, it should be dereferencable
|
41
|
-
* to a git_commit which oid will be used as the target of the branch.
|
41
|
+
* @param target Commit to which this branch should point. This object
|
42
|
+
* must belong to the given `repo`.
|
42
43
|
*
|
43
44
|
* @param force Overwrite existing branch.
|
44
45
|
*
|
45
|
-
* @return 0 or an error code.
|
46
|
+
* @return 0, GIT_EINVALIDSPEC or an error code.
|
46
47
|
* A proper reference is written in the refs/heads namespace
|
47
48
|
* pointing to the provided target commit.
|
48
49
|
*/
|
49
50
|
GIT_EXTERN(int) git_branch_create(
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
git_reference **out,
|
52
|
+
git_repository *repo,
|
53
|
+
const char *branch_name,
|
54
|
+
const git_commit *target,
|
55
|
+
int force);
|
55
56
|
|
56
57
|
/**
|
57
58
|
* Delete an existing branch reference.
|
@@ -64,6 +65,11 @@ GIT_EXTERN(int) git_branch_create(
|
|
64
65
|
*/
|
65
66
|
GIT_EXTERN(int) git_branch_delete(git_reference *branch);
|
66
67
|
|
68
|
+
typedef int (*git_branch_foreach_cb)(
|
69
|
+
const char *branch_name,
|
70
|
+
git_branch_t branch_type,
|
71
|
+
void *payload);
|
72
|
+
|
67
73
|
/**
|
68
74
|
* Loop over all the branches and issue a callback for each one.
|
69
75
|
*
|
@@ -82,18 +88,17 @@ GIT_EXTERN(int) git_branch_delete(git_reference *branch);
|
|
82
88
|
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
|
83
89
|
*/
|
84
90
|
GIT_EXTERN(int) git_branch_foreach(
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
git_branch_t branch_type,
|
90
|
-
void *payload),
|
91
|
-
void *payload
|
92
|
-
);
|
91
|
+
git_repository *repo,
|
92
|
+
unsigned int list_flags,
|
93
|
+
git_branch_foreach_cb branch_cb,
|
94
|
+
void *payload);
|
93
95
|
|
94
96
|
/**
|
95
97
|
* Move/rename an existing local branch reference.
|
96
98
|
*
|
99
|
+
* The new branch name will be checked for validity.
|
100
|
+
* See `git_tag_create()` for rules about valid names.
|
101
|
+
*
|
97
102
|
* @param branch Current underlying reference of the branch.
|
98
103
|
*
|
99
104
|
* @param new_branch_name Target name of the branch once the move
|
@@ -101,19 +106,23 @@ GIT_EXTERN(int) git_branch_foreach(
|
|
101
106
|
*
|
102
107
|
* @param force Overwrite existing branch.
|
103
108
|
*
|
104
|
-
* @return 0 on success, or an error code.
|
109
|
+
* @return 0 on success, GIT_EINVALIDSPEC or an error code.
|
105
110
|
*/
|
106
111
|
GIT_EXTERN(int) git_branch_move(
|
107
|
-
|
108
|
-
|
109
|
-
|
112
|
+
git_reference **out,
|
113
|
+
git_reference *branch,
|
114
|
+
const char *new_branch_name,
|
115
|
+
int force);
|
110
116
|
|
111
117
|
/**
|
112
118
|
* Lookup a branch by its name in a repository.
|
113
119
|
*
|
114
120
|
* The generated reference must be freed by the user.
|
115
121
|
*
|
116
|
-
*
|
122
|
+
* The branch name will be checked for validity.
|
123
|
+
* See `git_tag_create()` for rules about valid names.
|
124
|
+
*
|
125
|
+
* @param out pointer to the looked-up branch reference
|
117
126
|
*
|
118
127
|
* @param repo the repository to look up the branch
|
119
128
|
*
|
@@ -124,19 +133,37 @@ GIT_EXTERN(int) git_branch_move(
|
|
124
133
|
* be valued with either GIT_BRANCH_LOCAL or GIT_BRANCH_REMOTE.
|
125
134
|
*
|
126
135
|
* @return 0 on success; GIT_ENOTFOUND when no matching branch
|
127
|
-
* exists, otherwise an error code.
|
136
|
+
* exists, GIT_EINVALIDSPEC, otherwise an error code.
|
128
137
|
*/
|
129
138
|
GIT_EXTERN(int) git_branch_lookup(
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
139
|
+
git_reference **out,
|
140
|
+
git_repository *repo,
|
141
|
+
const char *branch_name,
|
142
|
+
git_branch_t branch_type);
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Return the name of the given local or remote branch.
|
146
|
+
*
|
147
|
+
* The name of the branch matches the definition of the name
|
148
|
+
* for git_branch_lookup. That is, if the returned name is given
|
149
|
+
* to git_branch_lookup() then the reference is returned that
|
150
|
+
* was given to this function.
|
151
|
+
*
|
152
|
+
* @param out where the pointer of branch name is stored;
|
153
|
+
* this is valid as long as the ref is not freed.
|
154
|
+
* @param ref the reference ideally pointing to a branch
|
155
|
+
*
|
156
|
+
* @return 0 on success; otherwise an error code (e.g., if the
|
157
|
+
* ref is no local or remote branch).
|
158
|
+
*/
|
159
|
+
GIT_EXTERN(int) git_branch_name(const char **out,
|
160
|
+
git_reference *ref);
|
134
161
|
|
135
162
|
/**
|
136
163
|
* Return the reference supporting the remote tracking branch,
|
137
164
|
* given a local branch reference.
|
138
165
|
*
|
139
|
-
* @param
|
166
|
+
* @param out Pointer where to store the retrieved
|
140
167
|
* reference.
|
141
168
|
*
|
142
169
|
* @param branch Current underlying reference of the branch.
|
@@ -144,9 +171,45 @@ GIT_EXTERN(int) git_branch_lookup(
|
|
144
171
|
* @return 0 on success; GIT_ENOTFOUND when no remote tracking
|
145
172
|
* reference exists, otherwise an error code.
|
146
173
|
*/
|
147
|
-
GIT_EXTERN(int)
|
148
|
-
|
149
|
-
|
174
|
+
GIT_EXTERN(int) git_branch_upstream(
|
175
|
+
git_reference **out,
|
176
|
+
git_reference *branch);
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Set the upstream configuration for a given local branch
|
180
|
+
*
|
181
|
+
* @param branch the branch to configure
|
182
|
+
*
|
183
|
+
* @param upstream_name remote-tracking or local branch to set as
|
184
|
+
* upstream. Pass NULL to unset.
|
185
|
+
*
|
186
|
+
* @return 0 or an error code
|
187
|
+
*/
|
188
|
+
GIT_EXTERN(int) git_branch_set_upstream(git_reference *branch, const char *upstream_name);
|
189
|
+
|
190
|
+
/**
|
191
|
+
* Return the name of the reference supporting the remote tracking branch,
|
192
|
+
* given the name of a local branch reference.
|
193
|
+
*
|
194
|
+
* @param tracking_branch_name_out The user-allocated buffer which will be
|
195
|
+
* filled with the name of the reference. Pass NULL if you just want to
|
196
|
+
* get the needed size of the name of the reference as the output value.
|
197
|
+
*
|
198
|
+
* @param buffer_size Size of the `out` buffer in bytes.
|
199
|
+
*
|
200
|
+
* @param repo the repository where the branches live
|
201
|
+
*
|
202
|
+
* @param canonical_branch_name name of the local branch.
|
203
|
+
*
|
204
|
+
* @return number of characters in the reference name
|
205
|
+
* including the trailing NUL byte; GIT_ENOTFOUND when no remote tracking
|
206
|
+
* reference exists, otherwise an error code.
|
207
|
+
*/
|
208
|
+
GIT_EXTERN(int) git_branch_upstream_name(
|
209
|
+
char *tracking_branch_name_out,
|
210
|
+
size_t buffer_size,
|
211
|
+
git_repository *repo,
|
212
|
+
const char *canonical_branch_name);
|
150
213
|
|
151
214
|
/**
|
152
215
|
* Determine if the current local branch is pointed at by HEAD.
|
@@ -157,7 +220,32 @@ GIT_EXTERN(int) git_branch_tracking(
|
|
157
220
|
* error code otherwise.
|
158
221
|
*/
|
159
222
|
GIT_EXTERN(int) git_branch_is_head(
|
160
|
-
|
223
|
+
git_reference *branch);
|
224
|
+
|
225
|
+
/**
|
226
|
+
* Return the name of remote that the remote tracking branch belongs to.
|
227
|
+
*
|
228
|
+
* @param remote_name_out The user-allocated buffer which will be
|
229
|
+
* filled with the name of the remote. Pass NULL if you just want to
|
230
|
+
* get the needed size of the name of the remote as the output value.
|
231
|
+
*
|
232
|
+
* @param buffer_size Size of the `out` buffer in bytes.
|
233
|
+
*
|
234
|
+
* @param repo The repository where the branch lives.
|
235
|
+
*
|
236
|
+
* @param canonical_branch_name name of the remote tracking branch.
|
237
|
+
*
|
238
|
+
* @return Number of characters in the reference name
|
239
|
+
* including the trailing NUL byte; GIT_ENOTFOUND
|
240
|
+
* when no remote matching remote was gound,
|
241
|
+
* GIT_EAMBIGUOUS when the branch maps to several remotes,
|
242
|
+
* otherwise an error code.
|
243
|
+
*/
|
244
|
+
GIT_EXTERN(int) git_branch_remote_name(
|
245
|
+
char *remote_name_out,
|
246
|
+
size_t buffer_size,
|
247
|
+
git_repository *repo,
|
248
|
+
const char *canonical_branch_name);
|
161
249
|
|
162
250
|
/** @} */
|
163
251
|
GIT_END_DECL
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (C)
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
3
|
*
|
4
4
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
5
|
* a Linking Exception. For full terms see the included COPYING file.
|
@@ -9,8 +9,7 @@
|
|
9
9
|
|
10
10
|
#include "common.h"
|
11
11
|
#include "types.h"
|
12
|
-
#include "
|
13
|
-
#include "strarray.h"
|
12
|
+
#include "diff.h"
|
14
13
|
|
15
14
|
/**
|
16
15
|
* @file git2/checkout.h
|
@@ -24,85 +23,246 @@ GIT_BEGIN_DECL
|
|
24
23
|
/**
|
25
24
|
* Checkout behavior flags
|
26
25
|
*
|
27
|
-
*
|
28
|
-
*
|
26
|
+
* In libgit2, checkout is used to update the working directory and index
|
27
|
+
* to match a target tree. Unlike git checkout, it does not move the HEAD
|
28
|
+
* commit for you - use `git_repository_set_head` or the like to do that.
|
29
|
+
*
|
30
|
+
* Checkout looks at (up to) four things: the "target" tree you want to
|
31
|
+
* check out, the "baseline" tree of what was checked out previously, the
|
32
|
+
* working directory for actual files, and the index for staged changes.
|
33
|
+
*
|
34
|
+
* You give checkout one of four strategies for update:
|
35
|
+
*
|
36
|
+
* - `GIT_CHECKOUT_NONE` is a dry-run strategy that checks for conflicts,
|
37
|
+
* etc., but doesn't make any actual changes.
|
38
|
+
*
|
39
|
+
* - `GIT_CHECKOUT_FORCE` is at the opposite extreme, taking any action to
|
40
|
+
* make the working directory match the target (including potentially
|
41
|
+
* discarding modified files).
|
42
|
+
*
|
43
|
+
* In between those are `GIT_CHECKOUT_SAFE` and `GIT_CHECKOUT_SAFE_CREATE`
|
44
|
+
* both of which only make modifications that will not lose changes.
|
45
|
+
*
|
46
|
+
* | target == baseline | target != baseline |
|
47
|
+
* ---------------------|-----------------------|----------------------|
|
48
|
+
* workdir == baseline | no action | create, update, or |
|
49
|
+
* | | delete file |
|
50
|
+
* ---------------------|-----------------------|----------------------|
|
51
|
+
* workdir exists and | no action | conflict (notify |
|
52
|
+
* is != baseline | notify dirty MODIFIED | and cancel checkout) |
|
53
|
+
* ---------------------|-----------------------|----------------------|
|
54
|
+
* workdir missing, | create if SAFE_CREATE | create file |
|
55
|
+
* baseline present | notify dirty DELETED | |
|
56
|
+
* ---------------------|-----------------------|----------------------|
|
57
|
+
*
|
58
|
+
* The only difference between SAFE and SAFE_CREATE is that SAFE_CREATE
|
59
|
+
* will cause a file to be checked out if it is missing from the working
|
60
|
+
* directory even if it is not modified between the target and baseline.
|
61
|
+
*
|
62
|
+
*
|
63
|
+
* To emulate `git checkout`, use `GIT_CHECKOUT_SAFE` with a checkout
|
64
|
+
* notification callback (see below) that displays information about dirty
|
65
|
+
* files. The default behavior will cancel checkout on conflicts.
|
66
|
+
*
|
67
|
+
* To emulate `git checkout-index`, use `GIT_CHECKOUT_SAFE_CREATE` with a
|
68
|
+
* notification callback that cancels the operation if a dirty-but-existing
|
69
|
+
* file is found in the working directory. This core git command isn't
|
70
|
+
* quite "force" but is sensitive about some types of changes.
|
71
|
+
*
|
72
|
+
* To emulate `git checkout -f`, use `GIT_CHECKOUT_FORCE`.
|
73
|
+
*
|
74
|
+
* To emulate `git clone` use `GIT_CHECKOUT_SAFE_CREATE` in the options.
|
75
|
+
*
|
76
|
+
*
|
77
|
+
* There are some additional flags to modified the behavior of checkout:
|
78
|
+
*
|
79
|
+
* - GIT_CHECKOUT_ALLOW_CONFLICTS makes SAFE mode apply safe file updates
|
80
|
+
* even if there are conflicts (instead of cancelling the checkout).
|
81
|
+
*
|
82
|
+
* - GIT_CHECKOUT_REMOVE_UNTRACKED means remove untracked files (i.e. not
|
83
|
+
* in target, baseline, or index, and not ignored) from the working dir.
|
84
|
+
*
|
85
|
+
* - GIT_CHECKOUT_REMOVE_IGNORED means remove ignored files (that are also
|
86
|
+
* untracked) from the working directory as well.
|
87
|
+
*
|
88
|
+
* - GIT_CHECKOUT_UPDATE_ONLY means to only update the content of files that
|
89
|
+
* already exist. Files will not be created nor deleted. This just skips
|
90
|
+
* applying adds, deletes, and typechanges.
|
91
|
+
*
|
92
|
+
* - GIT_CHECKOUT_DONT_UPDATE_INDEX prevents checkout from writing the
|
93
|
+
* updated files' information to the index.
|
94
|
+
*
|
95
|
+
* - Normally, checkout will reload the index and git attributes from disk
|
96
|
+
* before any operations. GIT_CHECKOUT_NO_REFRESH prevents this reload.
|
97
|
+
*
|
98
|
+
* - Unmerged index entries are conflicts. GIT_CHECKOUT_SKIP_UNMERGED skips
|
99
|
+
* files with unmerged index entries instead. GIT_CHECKOUT_USE_OURS and
|
100
|
+
* GIT_CHECKOUT_USE_THEIRS to proceed with the checkout using either the
|
101
|
+
* stage 2 ("ours") or stage 3 ("theirs") version of files in the index.
|
29
102
|
*/
|
30
103
|
typedef enum {
|
31
|
-
|
32
|
-
|
104
|
+
GIT_CHECKOUT_NONE = 0, /** default is a dry run, no actual updates */
|
105
|
+
|
106
|
+
/** Allow safe updates that cannot overwrite uncommitted data */
|
107
|
+
GIT_CHECKOUT_SAFE = (1u << 0),
|
108
|
+
|
109
|
+
/** Allow safe updates plus creation of missing files */
|
110
|
+
GIT_CHECKOUT_SAFE_CREATE = (1u << 1),
|
111
|
+
|
112
|
+
/** Allow all updates to force working directory to look like index */
|
113
|
+
GIT_CHECKOUT_FORCE = (1u << 2),
|
114
|
+
|
115
|
+
|
116
|
+
/** Allow checkout to make safe updates even if conflicts are found */
|
117
|
+
GIT_CHECKOUT_ALLOW_CONFLICTS = (1u << 4),
|
118
|
+
|
119
|
+
/** Remove untracked files not in index (that are not ignored) */
|
120
|
+
GIT_CHECKOUT_REMOVE_UNTRACKED = (1u << 5),
|
121
|
+
|
122
|
+
/** Remove ignored files not in index */
|
123
|
+
GIT_CHECKOUT_REMOVE_IGNORED = (1u << 6),
|
33
124
|
|
34
|
-
/**
|
35
|
-
|
125
|
+
/** Only update existing files, don't create new ones */
|
126
|
+
GIT_CHECKOUT_UPDATE_ONLY = (1u << 7),
|
36
127
|
|
37
|
-
/**
|
38
|
-
|
128
|
+
/** Normally checkout updates index entries as it goes; this stops that */
|
129
|
+
GIT_CHECKOUT_DONT_UPDATE_INDEX = (1u << 8),
|
130
|
+
|
131
|
+
/** Don't refresh index/config/etc before doing checkout */
|
132
|
+
GIT_CHECKOUT_NO_REFRESH = (1u << 9),
|
133
|
+
|
134
|
+
/** Treat pathspec as simple list of exact match file paths */
|
135
|
+
GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH = (1u << 13),
|
136
|
+
|
137
|
+
/**
|
138
|
+
* THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED
|
139
|
+
*/
|
140
|
+
|
141
|
+
/** Allow checkout to skip unmerged files (NOT IMPLEMENTED) */
|
142
|
+
GIT_CHECKOUT_SKIP_UNMERGED = (1u << 10),
|
143
|
+
/** For unmerged files, checkout stage 2 from index (NOT IMPLEMENTED) */
|
144
|
+
GIT_CHECKOUT_USE_OURS = (1u << 11),
|
145
|
+
/** For unmerged files, checkout stage 3 from index (NOT IMPLEMENTED) */
|
146
|
+
GIT_CHECKOUT_USE_THEIRS = (1u << 12),
|
147
|
+
|
148
|
+
/** Recursively checkout submodules with same options (NOT IMPLEMENTED) */
|
149
|
+
GIT_CHECKOUT_UPDATE_SUBMODULES = (1u << 16),
|
150
|
+
/** Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED) */
|
151
|
+
GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = (1u << 17),
|
39
152
|
|
40
|
-
/** If an untracked file in found in the working dir, delete it. */
|
41
|
-
GIT_CHECKOUT_REMOVE_UNTRACKED = (1 << 3),
|
42
153
|
} git_checkout_strategy_t;
|
43
154
|
|
155
|
+
/**
|
156
|
+
* Checkout notification flags
|
157
|
+
*
|
158
|
+
* Checkout will invoke an options notification callback (`notify_cb`) for
|
159
|
+
* certain cases - you pick which ones via `notify_flags`:
|
160
|
+
*
|
161
|
+
* - GIT_CHECKOUT_NOTIFY_CONFLICT invokes checkout on conflicting paths.
|
162
|
+
*
|
163
|
+
* - GIT_CHECKOUT_NOTIFY_DIRTY notifies about "dirty" files, i.e. those that
|
164
|
+
* do not need an update but no longer match the baseline. Core git
|
165
|
+
* displays these files when checkout runs, but won't stop the checkout.
|
166
|
+
*
|
167
|
+
* - GIT_CHECKOUT_NOTIFY_UPDATED sends notification for any file changed.
|
168
|
+
*
|
169
|
+
* - GIT_CHECKOUT_NOTIFY_UNTRACKED notifies about untracked files.
|
170
|
+
*
|
171
|
+
* - GIT_CHECKOUT_NOTIFY_IGNORED notifies about ignored files.
|
172
|
+
*
|
173
|
+
* Returning a non-zero value from this callback will cancel the checkout.
|
174
|
+
* Notification callbacks are made prior to modifying any files on disk.
|
175
|
+
*/
|
176
|
+
typedef enum {
|
177
|
+
GIT_CHECKOUT_NOTIFY_NONE = 0,
|
178
|
+
GIT_CHECKOUT_NOTIFY_CONFLICT = (1u << 0),
|
179
|
+
GIT_CHECKOUT_NOTIFY_DIRTY = (1u << 1),
|
180
|
+
GIT_CHECKOUT_NOTIFY_UPDATED = (1u << 2),
|
181
|
+
GIT_CHECKOUT_NOTIFY_UNTRACKED = (1u << 3),
|
182
|
+
GIT_CHECKOUT_NOTIFY_IGNORED = (1u << 4),
|
183
|
+
} git_checkout_notify_t;
|
184
|
+
|
185
|
+
/** Checkout notification callback function */
|
186
|
+
typedef int (*git_checkout_notify_cb)(
|
187
|
+
git_checkout_notify_t why,
|
188
|
+
const char *path,
|
189
|
+
const git_diff_file *baseline,
|
190
|
+
const git_diff_file *target,
|
191
|
+
const git_diff_file *workdir,
|
192
|
+
void *payload);
|
193
|
+
|
194
|
+
/** Checkout progress notification function */
|
195
|
+
typedef void (*git_checkout_progress_cb)(
|
196
|
+
const char *path,
|
197
|
+
size_t completed_steps,
|
198
|
+
size_t total_steps,
|
199
|
+
void *payload);
|
200
|
+
|
44
201
|
/**
|
45
202
|
* Checkout options structure
|
46
203
|
*
|
47
|
-
*
|
204
|
+
* Zero out for defaults. Initialize with `GIT_CHECKOUT_OPTS_INIT` macro to
|
205
|
+
* correctly set the `version` field. E.g.
|
206
|
+
*
|
207
|
+
* git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
|
48
208
|
*/
|
49
209
|
typedef struct git_checkout_opts {
|
50
|
-
unsigned int
|
51
|
-
int disable_filters; /** don't apply filters like CRLF conversion */
|
52
|
-
int dir_mode; /** default is 0755 */
|
53
|
-
int file_mode; /** default is 0644 or 0755 as dictated by blob */
|
54
|
-
int file_open_flags; /** default is O_CREAT | O_TRUNC | O_WRONLY */
|
55
|
-
|
56
|
-
/** Optional callback to notify the consumer of files that
|
57
|
-
* haven't be checked out because a modified version of them
|
58
|
-
* exist in the working directory.
|
59
|
-
*
|
60
|
-
* When provided, this callback will be invoked when the flag
|
61
|
-
* GIT_CHECKOUT_OVERWRITE_MODIFIED isn't part of the checkout strategy.
|
62
|
-
*/
|
63
|
-
int (* skipped_notify_cb)(
|
64
|
-
const char *skipped_file,
|
65
|
-
const git_oid *blob_oid,
|
66
|
-
int file_mode,
|
67
|
-
void *payload);
|
210
|
+
unsigned int version;
|
68
211
|
|
212
|
+
unsigned int checkout_strategy; /** default will be a dry run */
|
213
|
+
|
214
|
+
int disable_filters; /** don't apply filters like CRLF conversion */
|
215
|
+
unsigned int dir_mode; /** default is 0755 */
|
216
|
+
unsigned int file_mode; /** default is 0644 or 0755 as dictated by blob */
|
217
|
+
int file_open_flags; /** default is O_CREAT | O_TRUNC | O_WRONLY */
|
218
|
+
|
219
|
+
unsigned int notify_flags; /** see `git_checkout_notify_t` above */
|
220
|
+
git_checkout_notify_cb notify_cb;
|
69
221
|
void *notify_payload;
|
70
222
|
|
71
|
-
|
72
|
-
|
223
|
+
/* Optional callback to notify the consumer of checkout progress. */
|
224
|
+
git_checkout_progress_cb progress_cb;
|
225
|
+
void *progress_payload;
|
226
|
+
|
227
|
+
/** When not zeroed out, array of fnmatch patterns specifying which
|
228
|
+
* paths should be taken into account, otherwise all files. Use
|
229
|
+
* GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH to treat as simple list.
|
73
230
|
*/
|
74
|
-
git_strarray paths;
|
231
|
+
git_strarray paths;
|
232
|
+
|
233
|
+
git_tree *baseline; /** expected content of workdir, defaults to HEAD */
|
75
234
|
} git_checkout_opts;
|
76
235
|
|
236
|
+
#define GIT_CHECKOUT_OPTS_VERSION 1
|
237
|
+
#define GIT_CHECKOUT_OPTS_INIT {GIT_CHECKOUT_OPTS_VERSION}
|
238
|
+
|
77
239
|
/**
|
78
|
-
* Updates files in the index and the working tree to match the content of
|
79
|
-
* commit pointed at by HEAD.
|
240
|
+
* Updates files in the index and the working tree to match the content of
|
241
|
+
* the commit pointed at by HEAD.
|
80
242
|
*
|
81
243
|
* @param repo repository to check out (must be non-bare)
|
82
244
|
* @param opts specifies checkout options (may be NULL)
|
83
|
-
* @param stats structure through which progress information is reported
|
84
245
|
* @return 0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing
|
85
246
|
* branch, GIT_ERROR otherwise (use giterr_last for information
|
86
247
|
* about the error)
|
87
248
|
*/
|
88
249
|
GIT_EXTERN(int) git_checkout_head(
|
89
250
|
git_repository *repo,
|
90
|
-
git_checkout_opts *opts
|
91
|
-
git_indexer_stats *stats);
|
251
|
+
git_checkout_opts *opts);
|
92
252
|
|
93
253
|
/**
|
94
254
|
* Updates files in the working tree to match the content of the index.
|
95
255
|
*
|
96
|
-
* @param repo repository to check out (must be non-bare)
|
256
|
+
* @param repo repository into which to check out (must be non-bare)
|
257
|
+
* @param index index to be checked out (or NULL to use repository index)
|
97
258
|
* @param opts specifies checkout options (may be NULL)
|
98
|
-
* @param stats structure through which progress information is reported
|
99
259
|
* @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
|
100
260
|
* about the error)
|
101
261
|
*/
|
102
262
|
GIT_EXTERN(int) git_checkout_index(
|
103
263
|
git_repository *repo,
|
104
|
-
|
105
|
-
|
264
|
+
git_index *index,
|
265
|
+
git_checkout_opts *opts);
|
106
266
|
|
107
267
|
/**
|
108
268
|
* Updates files in the index and working tree to match the content of the
|
@@ -112,15 +272,13 @@ GIT_EXTERN(int) git_checkout_index(
|
|
112
272
|
* @param treeish a commit, tag or tree which content will be used to update
|
113
273
|
* the working directory
|
114
274
|
* @param opts specifies checkout options (may be NULL)
|
115
|
-
* @param stats structure through which progress information is reported
|
116
275
|
* @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
|
117
276
|
* about the error)
|
118
277
|
*/
|
119
278
|
GIT_EXTERN(int) git_checkout_tree(
|
120
279
|
git_repository *repo,
|
121
|
-
git_object *treeish,
|
122
|
-
git_checkout_opts *opts
|
123
|
-
git_indexer_stats *stats);
|
280
|
+
const git_object *treeish,
|
281
|
+
git_checkout_opts *opts);
|
124
282
|
|
125
283
|
/** @} */
|
126
284
|
GIT_END_DECL
|