rugged 0.18.0.gh.de28323 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -4
- data/Rakefile +1 -1
- data/ext/rugged/extconf.rb +10 -0
- data/ext/rugged/rugged.c +153 -86
- data/ext/rugged/rugged.h +44 -33
- data/ext/rugged/rugged_blob.c +288 -60
- data/ext/rugged/rugged_branch.c +82 -57
- data/ext/rugged/rugged_commit.c +83 -86
- data/ext/rugged/rugged_config.c +68 -68
- data/ext/rugged/rugged_diff.c +509 -0
- data/ext/rugged/rugged_diff_delta.c +94 -0
- data/ext/rugged/rugged_diff_hunk.c +100 -0
- data/ext/rugged/rugged_diff_line.c +79 -0
- data/ext/rugged/rugged_diff_patch.c +169 -0
- data/ext/rugged/rugged_index.c +539 -8
- data/ext/rugged/rugged_note.c +74 -80
- data/ext/rugged/rugged_object.c +63 -8
- data/ext/rugged/rugged_reference.c +231 -145
- data/ext/rugged/rugged_remote.c +509 -53
- data/ext/rugged/rugged_repo.c +572 -236
- data/ext/rugged/rugged_revwalk.c +59 -36
- data/ext/rugged/rugged_settings.c +7 -9
- data/ext/rugged/rugged_signature.c +7 -11
- data/ext/rugged/rugged_tag.c +93 -39
- data/ext/rugged/rugged_tree.c +321 -58
- data/lib/rugged.rb +1 -0
- data/lib/rugged/commit.rb +16 -1
- data/lib/rugged/console.rb +9 -0
- data/lib/rugged/diff.rb +19 -0
- data/lib/rugged/diff/delta.rb +54 -0
- data/lib/rugged/diff/hunk.rb +23 -0
- data/lib/rugged/diff/line.rb +29 -0
- data/lib/rugged/diff/patch.rb +28 -0
- data/lib/rugged/repository.rb +36 -39
- data/lib/rugged/version.rb +1 -1
- data/test/blob_test.rb +308 -1
- data/test/branch_test.rb +7 -0
- data/test/commit_test.rb +7 -10
- data/test/coverage/cover.rb +9 -1
- data/test/diff_test.rb +777 -0
- data/test/fixtures/archive.tar.gz +0 -0
- data/test/fixtures/attr/attr0 +1 -0
- data/test/fixtures/attr/attr1 +29 -0
- data/test/fixtures/attr/attr2 +21 -0
- data/test/fixtures/attr/attr3 +4 -0
- data/test/fixtures/attr/binfile +1 -0
- data/test/fixtures/attr/dir/file +0 -0
- data/test/fixtures/attr/file +1 -0
- data/test/fixtures/attr/gitattributes +29 -0
- data/test/fixtures/attr/gitignore +2 -0
- data/test/fixtures/attr/ign +1 -0
- data/test/fixtures/attr/macro_bad +1 -0
- data/test/fixtures/attr/macro_test +1 -0
- data/test/fixtures/attr/root_test1 +1 -0
- data/test/fixtures/attr/root_test2 +6 -0
- data/test/fixtures/attr/root_test3 +19 -0
- data/test/fixtures/attr/root_test4.txt +14 -0
- data/test/fixtures/attr/sub/abc +37 -0
- data/test/fixtures/attr/sub/dir/file +0 -0
- data/test/fixtures/attr/sub/file +1 -0
- data/test/fixtures/attr/sub/ign/file +1 -0
- data/test/fixtures/attr/sub/ign/sub/file +1 -0
- data/test/fixtures/attr/sub/sub/dir +0 -0
- data/test/fixtures/attr/sub/sub/file +1 -0
- data/test/fixtures/attr/sub/sub/subsub.txt +1 -0
- data/test/fixtures/attr/sub/subdir_test1 +2 -0
- data/test/fixtures/attr/sub/subdir_test2.txt +1 -0
- data/test/fixtures/diff/another.txt +38 -0
- data/test/fixtures/diff/readme.txt +36 -0
- data/test/fixtures/mergedrepo/conflicts-one.txt +5 -0
- data/test/fixtures/mergedrepo/conflicts-two.txt +5 -0
- data/test/fixtures/mergedrepo/one.txt +10 -0
- data/test/fixtures/mergedrepo/two.txt +12 -0
- data/test/fixtures/status/current_file +1 -0
- data/test/fixtures/status/ignored_file +1 -0
- data/test/fixtures/status/modified_file +2 -0
- data/test/fixtures/status/new_file +1 -0
- data/test/fixtures/status/staged_changes +2 -0
- data/test/fixtures/status/staged_changes_modified_file +3 -0
- data/test/fixtures/status/staged_delete_modified_file +1 -0
- data/test/fixtures/status/staged_new_file +1 -0
- data/test/fixtures/status/staged_new_file_modified_file +2 -0
- data/test/fixtures/status/subdir.txt +2 -0
- data/test/fixtures/status/subdir/current_file +1 -0
- data/test/fixtures/status/subdir/modified_file +2 -0
- data/test/fixtures/status/subdir/new_file +1 -0
- data/test/fixtures/status//350/277/231 +1 -0
- data/test/fixtures/testrepo.git/config +5 -0
- data/test/fixtures/testrepo.git/objects/77/71329dfa3002caf8c61a0ceb62a31d09023f37 +0 -0
- data/test/fixtures/text_file.md +464 -0
- data/test/fixtures/unsymlinked.git/HEAD +1 -0
- data/test/fixtures/unsymlinked.git/config +6 -0
- data/test/fixtures/unsymlinked.git/description +1 -0
- data/test/fixtures/unsymlinked.git/info/exclude +2 -0
- data/test/fixtures/unsymlinked.git/objects/08/8b64704e0d6b8bd061dea879418cb5442a3fbf +0 -0
- data/test/fixtures/unsymlinked.git/objects/13/a5e939bca25940c069fd2169d993dba328e30b +0 -0
- data/test/fixtures/unsymlinked.git/objects/19/bf568e59e3a0b363cafb4106226e62d4a4c41c +0 -0
- data/test/fixtures/unsymlinked.git/objects/58/1fadd35b4cf320d102a152f918729011604773 +0 -0
- data/test/fixtures/unsymlinked.git/objects/5c/87b6791e8b13da658a14d1ef7e09b5dc3bac8c +0 -0
- data/test/fixtures/unsymlinked.git/objects/6f/e5f5398af85fb3de8a6aba0339b6d3bfa26a27 +0 -0
- data/test/fixtures/unsymlinked.git/objects/7f/ccd75616ec188b8f1b23d67506a334cc34a49d +0 -0
- data/test/fixtures/unsymlinked.git/objects/80/6999882bf91d24241e4077906b9017605eb1f3 +0 -0
- data/test/fixtures/unsymlinked.git/objects/83/7d176303c5005505ec1e4a30231c40930c0230 +0 -0
- data/test/fixtures/unsymlinked.git/objects/a8/595ccca04f40818ae0155c8f9c77a230e597b6 +2 -0
- data/test/fixtures/unsymlinked.git/objects/cf/8f1cf5cce859c438d6cc067284cb5e161206e7 +0 -0
- data/test/fixtures/unsymlinked.git/objects/d5/278d05c8607ec420bfee4cf219fbc0eeebfd6a +0 -0
- data/test/fixtures/unsymlinked.git/objects/f4/e16fb76536591a41454194058d048d8e4dd2e9 +0 -0
- data/test/fixtures/unsymlinked.git/objects/f9/e65619d93fdf2673882e0a261c5e93b1a84006 +0 -0
- data/test/fixtures/unsymlinked.git/refs/heads/exe-file +1 -0
- data/test/fixtures/unsymlinked.git/refs/heads/master +1 -0
- data/test/fixtures/unsymlinked.git/refs/heads/reg-file +1 -0
- data/test/index_test.rb +120 -0
- data/test/reference_test.rb +38 -3
- data/test/remote_test.rb +224 -3
- data/test/repo_reset_test.rb +2 -0
- data/test/repo_test.rb +147 -10
- data/test/test_helper.rb +5 -2
- data/vendor/libgit2/include/git2/attr.h +3 -3
- data/vendor/libgit2/include/git2/blob.h +11 -17
- data/vendor/libgit2/include/git2/branch.h +3 -2
- data/vendor/libgit2/include/git2/checkout.h +7 -0
- data/vendor/libgit2/include/git2/clone.h +3 -0
- data/vendor/libgit2/include/git2/commit.h +61 -66
- data/vendor/libgit2/include/git2/common.h +73 -42
- data/vendor/libgit2/include/git2/config.h +57 -71
- data/vendor/libgit2/include/git2/cred_helpers.h +2 -2
- data/vendor/libgit2/include/git2/diff.h +179 -30
- data/vendor/libgit2/include/git2/errors.h +3 -3
- data/vendor/libgit2/include/git2/index.h +225 -146
- data/vendor/libgit2/include/git2/indexer.h +2 -22
- data/vendor/libgit2/include/git2/inttypes.h +9 -9
- data/vendor/libgit2/include/git2/merge.h +123 -5
- data/vendor/libgit2/include/git2/odb.h +59 -38
- data/vendor/libgit2/include/git2/odb_backend.h +45 -104
- data/vendor/libgit2/include/git2/oid.h +30 -19
- data/vendor/libgit2/include/git2/pack.h +21 -3
- data/vendor/libgit2/include/git2/refdb.h +0 -35
- data/vendor/libgit2/include/git2/refs.h +93 -31
- data/vendor/libgit2/include/git2/refspec.h +17 -0
- data/vendor/libgit2/include/git2/remote.h +60 -20
- data/vendor/libgit2/include/git2/repository.h +48 -70
- data/vendor/libgit2/include/git2/reset.h +3 -3
- data/vendor/libgit2/include/git2/revparse.h +22 -0
- data/vendor/libgit2/include/git2/stash.h +1 -1
- data/vendor/libgit2/include/git2/status.h +131 -56
- data/vendor/libgit2/include/git2/strarray.h +2 -2
- data/vendor/libgit2/include/git2/submodule.h +16 -16
- data/vendor/libgit2/include/git2/sys/commit.h +46 -0
- data/vendor/libgit2/include/git2/sys/config.h +71 -0
- data/vendor/libgit2/include/git2/sys/index.h +179 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +86 -0
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +158 -0
- data/vendor/libgit2/include/git2/sys/refs.h +38 -0
- data/vendor/libgit2/include/git2/sys/repository.h +106 -0
- data/vendor/libgit2/include/git2/tag.h +44 -18
- data/vendor/libgit2/include/git2/trace.h +1 -2
- data/vendor/libgit2/include/git2/transport.h +74 -0
- data/vendor/libgit2/include/git2/tree.h +12 -22
- data/vendor/libgit2/include/git2/types.h +33 -0
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/array.h +66 -0
- data/vendor/libgit2/src/attr.c +26 -13
- data/vendor/libgit2/src/attr_file.c +3 -2
- data/vendor/libgit2/src/attr_file.h +3 -3
- data/vendor/libgit2/src/attrcache.h +4 -4
- data/vendor/libgit2/src/blob.c +13 -9
- data/vendor/libgit2/src/blob.h +2 -2
- data/vendor/libgit2/src/branch.c +67 -49
- data/vendor/libgit2/src/cache.c +224 -54
- data/vendor/libgit2/src/cache.h +33 -20
- data/vendor/libgit2/src/checkout.c +145 -85
- data/vendor/libgit2/src/clone.c +62 -50
- data/vendor/libgit2/src/commit.c +74 -40
- data/vendor/libgit2/src/commit.h +2 -3
- data/vendor/libgit2/src/commit_list.c +14 -8
- data/vendor/libgit2/src/config.c +119 -36
- data/vendor/libgit2/src/config.h +3 -0
- data/vendor/libgit2/src/config_cache.c +24 -7
- data/vendor/libgit2/src/config_file.c +9 -6
- data/vendor/libgit2/src/crlf.c +4 -2
- data/vendor/libgit2/src/date.c +3 -3
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/diff.c +681 -303
- data/vendor/libgit2/src/diff.h +34 -2
- data/vendor/libgit2/src/diff_driver.c +405 -0
- data/vendor/libgit2/src/diff_driver.h +49 -0
- data/vendor/libgit2/src/diff_file.c +447 -0
- data/vendor/libgit2/src/diff_file.h +58 -0
- data/vendor/libgit2/src/diff_patch.c +995 -0
- data/vendor/libgit2/src/diff_patch.h +46 -0
- data/vendor/libgit2/src/diff_print.c +430 -0
- data/vendor/libgit2/src/diff_tform.c +464 -203
- data/vendor/libgit2/src/diff_xdiff.c +166 -0
- data/vendor/libgit2/src/diff_xdiff.h +28 -0
- data/vendor/libgit2/src/fetch.c +11 -4
- data/vendor/libgit2/src/fileops.c +85 -61
- data/vendor/libgit2/src/fileops.h +4 -0
- data/vendor/libgit2/src/global.c +10 -2
- data/vendor/libgit2/src/global.h +0 -8
- data/vendor/libgit2/src/hash/hash_generic.h +3 -3
- data/vendor/libgit2/src/hash/hash_win32.h +4 -4
- data/vendor/libgit2/src/hashsig.c +0 -1
- data/vendor/libgit2/src/ignore.c +68 -28
- data/vendor/libgit2/src/ignore.h +10 -1
- data/vendor/libgit2/src/index.c +666 -84
- data/vendor/libgit2/src/index.h +6 -0
- data/vendor/libgit2/src/indexer.c +10 -28
- data/vendor/libgit2/src/iterator.c +427 -283
- data/vendor/libgit2/src/iterator.h +58 -4
- data/vendor/libgit2/src/merge.c +1892 -32
- data/vendor/libgit2/src/merge.h +132 -5
- data/vendor/libgit2/src/merge_file.c +174 -0
- data/vendor/libgit2/src/merge_file.h +71 -0
- data/vendor/libgit2/src/mwindow.c +1 -1
- data/vendor/libgit2/src/notes.c +45 -48
- data/vendor/libgit2/src/object.c +89 -127
- data/vendor/libgit2/src/object.h +0 -1
- data/vendor/libgit2/src/object_api.c +129 -0
- data/vendor/libgit2/src/odb.c +156 -59
- data/vendor/libgit2/src/odb.h +5 -2
- data/vendor/libgit2/src/odb_loose.c +31 -17
- data/vendor/libgit2/src/odb_pack.c +39 -43
- data/vendor/libgit2/src/oid.c +62 -27
- data/vendor/libgit2/src/oid.h +33 -0
- data/vendor/libgit2/src/oidmap.h +4 -6
- data/vendor/libgit2/src/pack-objects.c +54 -22
- data/vendor/libgit2/src/pack.c +98 -56
- data/vendor/libgit2/src/pack.h +3 -1
- data/vendor/libgit2/src/pathspec.c +26 -1
- data/vendor/libgit2/src/pathspec.h +14 -0
- data/vendor/libgit2/src/pool.c +5 -0
- data/vendor/libgit2/src/posix.c +2 -2
- data/vendor/libgit2/src/posix.h +3 -0
- data/vendor/libgit2/src/push.c +13 -10
- data/vendor/libgit2/src/refdb.c +82 -62
- data/vendor/libgit2/src/refdb.h +16 -16
- data/vendor/libgit2/src/refdb_fs.c +386 -133
- data/vendor/libgit2/src/reflog.c +3 -1
- data/vendor/libgit2/src/refs.c +247 -221
- data/vendor/libgit2/src/refs.h +2 -1
- data/vendor/libgit2/src/refspec.c +18 -1
- data/vendor/libgit2/src/refspec.h +3 -1
- data/vendor/libgit2/src/remote.c +434 -253
- data/vendor/libgit2/src/remote.h +5 -3
- data/vendor/libgit2/src/repository.c +197 -111
- data/vendor/libgit2/src/repository.h +26 -5
- data/vendor/libgit2/src/reset.c +1 -1
- data/vendor/libgit2/src/revparse.c +84 -79
- data/vendor/libgit2/src/revwalk.c +1 -1
- data/vendor/libgit2/src/signature.c +22 -10
- data/vendor/libgit2/src/stash.c +5 -2
- data/vendor/libgit2/src/status.c +311 -107
- data/vendor/libgit2/src/status.h +23 -0
- data/vendor/libgit2/src/submodule.c +21 -13
- data/vendor/libgit2/src/tag.c +42 -31
- data/vendor/libgit2/src/tag.h +2 -3
- data/vendor/libgit2/src/thread-utils.h +105 -3
- data/vendor/libgit2/src/trace.c +1 -2
- data/vendor/libgit2/src/trace.h +3 -3
- data/vendor/libgit2/src/transport.c +18 -6
- data/vendor/libgit2/src/transports/cred.c +103 -1
- data/vendor/libgit2/src/transports/local.c +19 -9
- data/vendor/libgit2/src/transports/smart_protocol.c +32 -12
- data/vendor/libgit2/src/transports/ssh.c +519 -0
- data/vendor/libgit2/src/transports/winhttp.c +3 -1
- data/vendor/libgit2/src/tree.c +26 -28
- data/vendor/libgit2/src/tree.h +3 -3
- data/vendor/libgit2/src/unix/posix.h +2 -0
- data/vendor/libgit2/src/util.c +43 -6
- data/vendor/libgit2/src/util.h +40 -12
- data/vendor/libgit2/src/vector.c +3 -5
- data/vendor/libgit2/src/vector.h +9 -0
- data/vendor/libgit2/src/win32/dir.c +1 -1
- data/vendor/libgit2/src/win32/error.c +2 -0
- data/vendor/libgit2/src/win32/findfile.c +3 -6
- data/vendor/libgit2/src/win32/posix_w32.c +85 -59
- data/vendor/libgit2/src/win32/pthread.c +16 -8
- data/vendor/libgit2/src/win32/pthread.h +7 -4
- metadata +407 -306
- data/test/coverage/HEAD.json +0 -1
- data/vendor/libgit2/include/git2/refdb_backend.h +0 -109
- data/vendor/libgit2/src/diff_output.c +0 -1819
- data/vendor/libgit2/src/diff_output.h +0 -93
@@ -18,7 +18,7 @@
|
|
18
18
|
GIT_BEGIN_DECL
|
19
19
|
|
20
20
|
/** Generic return codes */
|
21
|
-
enum {
|
21
|
+
typedef enum {
|
22
22
|
GIT_OK = 0,
|
23
23
|
GIT_ERROR = -1,
|
24
24
|
GIT_ENOTFOUND = -3,
|
@@ -35,7 +35,7 @@ enum {
|
|
35
35
|
|
36
36
|
GIT_PASSTHROUGH = -30,
|
37
37
|
GIT_ITEROVER = -31,
|
38
|
-
};
|
38
|
+
} git_error_code;
|
39
39
|
|
40
40
|
typedef struct {
|
41
41
|
char *message;
|
@@ -100,7 +100,7 @@ GIT_EXTERN(void) giterr_clear(void);
|
|
100
100
|
*
|
101
101
|
* @param error_class One of the `git_error_t` enum above describing the
|
102
102
|
* general subsystem that is responsible for the error.
|
103
|
-
* @param
|
103
|
+
* @param string The formatted error message to keep
|
104
104
|
*/
|
105
105
|
GIT_EXTERN(void) giterr_set_str(int error_class, const char *string);
|
106
106
|
|
@@ -11,6 +11,7 @@
|
|
11
11
|
#include "indexer.h"
|
12
12
|
#include "types.h"
|
13
13
|
#include "oid.h"
|
14
|
+
#include "strarray.h"
|
14
15
|
|
15
16
|
/**
|
16
17
|
* @file git2/index.h
|
@@ -21,50 +22,29 @@
|
|
21
22
|
*/
|
22
23
|
GIT_BEGIN_DECL
|
23
24
|
|
24
|
-
|
25
|
-
#define GIT_IDXENTRY_STAGEMASK (0x3000)
|
26
|
-
#define GIT_IDXENTRY_EXTENDED (0x4000)
|
27
|
-
#define GIT_IDXENTRY_VALID (0x8000)
|
28
|
-
#define GIT_IDXENTRY_STAGESHIFT 12
|
29
|
-
|
30
|
-
/*
|
31
|
-
* Flags are divided into two parts: in-memory flags and
|
32
|
-
* on-disk ones. Flags in GIT_IDXENTRY_EXTENDED_FLAGS
|
33
|
-
* will get saved on-disk.
|
34
|
-
*
|
35
|
-
* In-memory only flags:
|
36
|
-
*/
|
37
|
-
#define GIT_IDXENTRY_UPDATE (1 << 0)
|
38
|
-
#define GIT_IDXENTRY_REMOVE (1 << 1)
|
39
|
-
#define GIT_IDXENTRY_UPTODATE (1 << 2)
|
40
|
-
#define GIT_IDXENTRY_ADDED (1 << 3)
|
41
|
-
|
42
|
-
#define GIT_IDXENTRY_HASHED (1 << 4)
|
43
|
-
#define GIT_IDXENTRY_UNHASHED (1 << 5)
|
44
|
-
#define GIT_IDXENTRY_WT_REMOVE (1 << 6) /* remove in work directory */
|
45
|
-
#define GIT_IDXENTRY_CONFLICTED (1 << 7)
|
46
|
-
|
47
|
-
#define GIT_IDXENTRY_UNPACKED (1 << 8)
|
48
|
-
#define GIT_IDXENTRY_NEW_SKIP_WORKTREE (1 << 9)
|
49
|
-
|
50
|
-
/*
|
51
|
-
* Extended on-disk flags:
|
52
|
-
*/
|
53
|
-
#define GIT_IDXENTRY_INTENT_TO_ADD (1 << 13)
|
54
|
-
#define GIT_IDXENTRY_SKIP_WORKTREE (1 << 14)
|
55
|
-
/* GIT_IDXENTRY_EXTENDED2 is for future extension */
|
56
|
-
#define GIT_IDXENTRY_EXTENDED2 (1 << 15)
|
57
|
-
|
58
|
-
#define GIT_IDXENTRY_EXTENDED_FLAGS (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE)
|
59
|
-
|
60
|
-
/** Time used in a git index entry */
|
25
|
+
/** Time structure used in a git index entry */
|
61
26
|
typedef struct {
|
62
27
|
git_time_t seconds;
|
63
28
|
/* nsec should not be stored as time_t compatible */
|
64
29
|
unsigned int nanoseconds;
|
65
30
|
} git_index_time;
|
66
31
|
|
67
|
-
/**
|
32
|
+
/**
|
33
|
+
* In-memory representation of a file entry in the index.
|
34
|
+
*
|
35
|
+
* This is a public structure that represents a file entry in the index.
|
36
|
+
* The meaning of the fields corresponds to core Git's documentation (in
|
37
|
+
* "Documentation/technical/index-format.txt").
|
38
|
+
*
|
39
|
+
* The `flags` field consists of a number of bit fields which can be
|
40
|
+
* accessed via the first set of `GIT_IDXENTRY_...` bitmasks below. These
|
41
|
+
* flags are all read from and persisted to disk.
|
42
|
+
*
|
43
|
+
* The `flags_extended` field also has a number of bit fields which can be
|
44
|
+
* accessed via the later `GIT_IDXENTRY_...` bitmasks below. Some of
|
45
|
+
* these flags are read from and written to disk, but some are set aside
|
46
|
+
* for in-memory only reference.
|
47
|
+
*/
|
68
48
|
typedef struct git_index_entry {
|
69
49
|
git_index_time ctime;
|
70
50
|
git_index_time mtime;
|
@@ -84,20 +64,79 @@ typedef struct git_index_entry {
|
|
84
64
|
char *path;
|
85
65
|
} git_index_entry;
|
86
66
|
|
87
|
-
/**
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
67
|
+
/**
|
68
|
+
* Bitmasks for on-disk fields of `git_index_entry`'s `flags`
|
69
|
+
*
|
70
|
+
* These bitmasks match the four fields in the `git_index_entry` `flags`
|
71
|
+
* value both in memory and on disk. You can use them to interpret the
|
72
|
+
* data in the `flags`.
|
73
|
+
*/
|
74
|
+
#define GIT_IDXENTRY_NAMEMASK (0x0fff)
|
75
|
+
#define GIT_IDXENTRY_STAGEMASK (0x3000)
|
76
|
+
#define GIT_IDXENTRY_EXTENDED (0x4000)
|
77
|
+
#define GIT_IDXENTRY_VALID (0x8000)
|
78
|
+
#define GIT_IDXENTRY_STAGESHIFT 12
|
79
|
+
|
80
|
+
#define GIT_IDXENTRY_STAGE(E) (((E)->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT)
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Bitmasks for on-disk fields of `git_index_entry`'s `flags_extended`
|
84
|
+
*
|
85
|
+
* In memory, the `flags_extended` fields are divided into two parts: the
|
86
|
+
* fields that are read from and written to disk, and other fields that
|
87
|
+
* in-memory only and used by libgit2. Only the flags in
|
88
|
+
* `GIT_IDXENTRY_EXTENDED_FLAGS` will get saved on-disk.
|
89
|
+
*
|
90
|
+
* These bitmasks match the three fields in the `git_index_entry`
|
91
|
+
* `flags_extended` value that belong on disk. You can use them to
|
92
|
+
* interpret the data in the `flags_extended`.
|
93
|
+
*/
|
94
|
+
#define GIT_IDXENTRY_INTENT_TO_ADD (1 << 13)
|
95
|
+
#define GIT_IDXENTRY_SKIP_WORKTREE (1 << 14)
|
96
|
+
/* GIT_IDXENTRY_EXTENDED2 is reserved for future extension */
|
97
|
+
#define GIT_IDXENTRY_EXTENDED2 (1 << 15)
|
98
|
+
|
99
|
+
#define GIT_IDXENTRY_EXTENDED_FLAGS (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE)
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Bitmasks for in-memory only fields of `git_index_entry`'s `flags_extended`
|
103
|
+
*
|
104
|
+
* These bitmasks match the other fields in the `git_index_entry`
|
105
|
+
* `flags_extended` value that are only used in-memory by libgit2. You
|
106
|
+
* can use them to interpret the data in the `flags_extended`.
|
107
|
+
*/
|
108
|
+
#define GIT_IDXENTRY_UPDATE (1 << 0)
|
109
|
+
#define GIT_IDXENTRY_REMOVE (1 << 1)
|
110
|
+
#define GIT_IDXENTRY_UPTODATE (1 << 2)
|
111
|
+
#define GIT_IDXENTRY_ADDED (1 << 3)
|
112
|
+
|
113
|
+
#define GIT_IDXENTRY_HASHED (1 << 4)
|
114
|
+
#define GIT_IDXENTRY_UNHASHED (1 << 5)
|
115
|
+
#define GIT_IDXENTRY_WT_REMOVE (1 << 6) /* remove in work directory */
|
116
|
+
#define GIT_IDXENTRY_CONFLICTED (1 << 7)
|
117
|
+
|
118
|
+
#define GIT_IDXENTRY_UNPACKED (1 << 8)
|
119
|
+
#define GIT_IDXENTRY_NEW_SKIP_WORKTREE (1 << 9)
|
93
120
|
|
94
121
|
/** Capabilities of system that affect index actions. */
|
95
|
-
enum {
|
122
|
+
typedef enum {
|
96
123
|
GIT_INDEXCAP_IGNORE_CASE = 1,
|
97
124
|
GIT_INDEXCAP_NO_FILEMODE = 2,
|
98
125
|
GIT_INDEXCAP_NO_SYMLINKS = 4,
|
99
126
|
GIT_INDEXCAP_FROM_OWNER = ~0u
|
100
|
-
};
|
127
|
+
} git_indexcap_t;
|
128
|
+
|
129
|
+
/** Callback for APIs that add/remove/update files matching pathspec */
|
130
|
+
typedef int (*git_index_matched_path_cb)(
|
131
|
+
const char *path, const char *matched_pathspec, void *payload);
|
132
|
+
|
133
|
+
/** Flags for APIs that add files matching pathspec */
|
134
|
+
typedef enum {
|
135
|
+
GIT_INDEX_ADD_DEFAULT = 0,
|
136
|
+
GIT_INDEX_ADD_FORCE = (1u << 0),
|
137
|
+
GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH = (1u << 1),
|
138
|
+
GIT_INDEX_ADD_CHECK_PATHSPEC = (1u << 2),
|
139
|
+
} git_index_add_option_t;
|
101
140
|
|
102
141
|
/** @name Index File Functions
|
103
142
|
*
|
@@ -272,11 +311,9 @@ GIT_EXTERN(void) git_index_clear(git_index *index);
|
|
272
311
|
/**
|
273
312
|
* Get a pointer to one of the entries in the index
|
274
313
|
*
|
275
|
-
* The
|
276
|
-
*
|
277
|
-
*
|
278
|
-
*
|
279
|
-
* The entry should not be freed by the caller.
|
314
|
+
* The entry is not modifiable and should not be freed. Because the
|
315
|
+
* `git_index_entry` struct is a publicly defined struct, you should
|
316
|
+
* be able to make your own permanent copy of the data if necessary.
|
280
317
|
*
|
281
318
|
* @param index an existing index object
|
282
319
|
* @param n the position of the entry
|
@@ -288,11 +325,9 @@ GIT_EXTERN(const git_index_entry *) git_index_get_byindex(
|
|
288
325
|
/**
|
289
326
|
* Get a pointer to one of the entries in the index
|
290
327
|
*
|
291
|
-
* The
|
292
|
-
*
|
293
|
-
*
|
294
|
-
*
|
295
|
-
* The entry should not be freed by the caller.
|
328
|
+
* The entry is not modifiable and should not be freed. Because the
|
329
|
+
* `git_index_entry` struct is a publicly defined struct, you should
|
330
|
+
* be able to make your own permanent copy of the data if necessary.
|
296
331
|
*
|
297
332
|
* @param index an existing index object
|
298
333
|
* @param path path to search
|
@@ -342,8 +377,7 @@ GIT_EXTERN(int) git_index_add(git_index *index, const git_index_entry *source_en
|
|
342
377
|
/**
|
343
378
|
* Return the stage number from a git index entry
|
344
379
|
*
|
345
|
-
* This entry is calculated from the entry's flag
|
346
|
-
* attribute like this:
|
380
|
+
* This entry is calculated from the entry's flag attribute like this:
|
347
381
|
*
|
348
382
|
* (entry->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT
|
349
383
|
*
|
@@ -399,6 +433,108 @@ GIT_EXTERN(int) git_index_add_bypath(git_index *index, const char *path);
|
|
399
433
|
*/
|
400
434
|
GIT_EXTERN(int) git_index_remove_bypath(git_index *index, const char *path);
|
401
435
|
|
436
|
+
/**
|
437
|
+
* Add or update index entries matching files in the working directory.
|
438
|
+
*
|
439
|
+
* This method will fail in bare index instances.
|
440
|
+
*
|
441
|
+
* The `pathspec` is a list of file names or shell glob patterns that will
|
442
|
+
* matched against files in the repository's working directory. Each file
|
443
|
+
* that matches will be added to the index (either updating an existing
|
444
|
+
* entry or adding a new entry). You can disable glob expansion and force
|
445
|
+
* exact matching with the `GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH` flag.
|
446
|
+
*
|
447
|
+
* Files that are ignored will be skipped (unlike `git_index_add_bypath`).
|
448
|
+
* If a file is already tracked in the index, then it *will* be updated
|
449
|
+
* even if it is ignored. Pass the `GIT_INDEX_ADD_FORCE` flag to
|
450
|
+
* skip the checking of ignore rules.
|
451
|
+
*
|
452
|
+
* To emulate `git add -A` and generate an error if the pathspec contains
|
453
|
+
* the exact path of an ignored file (when not using FORCE), add the
|
454
|
+
* `GIT_INDEX_ADD_CHECK_PATHSPEC` flag. This checks that each entry
|
455
|
+
* in the `pathspec` that is an exact match to a filename on disk is
|
456
|
+
* either not ignored or already in the index. If this check fails, the
|
457
|
+
* function will return GIT_EINVALIDSPEC.
|
458
|
+
*
|
459
|
+
* To emulate `git add -A` with the "dry-run" option, just use a callback
|
460
|
+
* function that always returns a positive value. See below for details.
|
461
|
+
*
|
462
|
+
* If any files are currently the result of a merge conflict, those files
|
463
|
+
* will no longer be marked as conflicting. The data about the conflicts
|
464
|
+
* will be moved to the "resolve undo" (REUC) section.
|
465
|
+
*
|
466
|
+
* If you provide a callback function, it will be invoked on each matching
|
467
|
+
* item in the working directory immediately *before* it is added to /
|
468
|
+
* updated in the index. Returning zero will add the item to the index,
|
469
|
+
* greater than zero will skip the item, and less than zero will abort the
|
470
|
+
* scan and cause GIT_EUSER to be returned.
|
471
|
+
*
|
472
|
+
* @param index an existing index object
|
473
|
+
* @param pathspec array of path patterns
|
474
|
+
* @param flags combination of git_index_add_option_t flags
|
475
|
+
* @param callback notification callback for each added/updated path (also
|
476
|
+
* gets index of matching pathspec entry); can be NULL;
|
477
|
+
* return 0 to add, >0 to skip, <0 to abort scan.
|
478
|
+
* @param payload payload passed through to callback function
|
479
|
+
* @return 0 or an error code
|
480
|
+
*/
|
481
|
+
GIT_EXTERN(int) git_index_add_all(
|
482
|
+
git_index *index,
|
483
|
+
const git_strarray *pathspec,
|
484
|
+
unsigned int flags,
|
485
|
+
git_index_matched_path_cb callback,
|
486
|
+
void *payload);
|
487
|
+
|
488
|
+
/**
|
489
|
+
* Remove all matching index entries.
|
490
|
+
*
|
491
|
+
* If you provide a callback function, it will be invoked on each matching
|
492
|
+
* item in the index immediately *before* it is removed. Return 0 to
|
493
|
+
* remove the item, > 0 to skip the item, and < 0 to abort the scan.
|
494
|
+
*
|
495
|
+
* @param index An existing index object
|
496
|
+
* @param pathspec array of path patterns
|
497
|
+
* @param callback notification callback for each removed path (also
|
498
|
+
* gets index of matching pathspec entry); can be NULL;
|
499
|
+
* return 0 to add, >0 to skip, <0 to abort scan.
|
500
|
+
* @param payload payload passed through to callback function
|
501
|
+
* @return 0 or an error code
|
502
|
+
*/
|
503
|
+
GIT_EXTERN(int) git_index_remove_all(
|
504
|
+
git_index *index,
|
505
|
+
const git_strarray *pathspec,
|
506
|
+
git_index_matched_path_cb callback,
|
507
|
+
void *payload);
|
508
|
+
|
509
|
+
/**
|
510
|
+
* Update all index entries to match the working directory
|
511
|
+
*
|
512
|
+
* This method will fail in bare index instances.
|
513
|
+
*
|
514
|
+
* This scans the existing index entries and synchronizes them with the
|
515
|
+
* working directory, deleting them if the corresponding working directory
|
516
|
+
* file no longer exists otherwise updating the information (including
|
517
|
+
* adding the latest version of file to the ODB if needed).
|
518
|
+
*
|
519
|
+
* If you provide a callback function, it will be invoked on each matching
|
520
|
+
* item in the index immediately *before* it is updated (either refreshed
|
521
|
+
* or removed depending on working directory state). Return 0 to proceed
|
522
|
+
* with updating the item, > 0 to skip the item, and < 0 to abort the scan.
|
523
|
+
*
|
524
|
+
* @param index An existing index object
|
525
|
+
* @param pathspec array of path patterns
|
526
|
+
* @param callback notification callback for each updated path (also
|
527
|
+
* gets index of matching pathspec entry); can be NULL;
|
528
|
+
* return 0 to add, >0 to skip, <0 to abort scan.
|
529
|
+
* @param payload payload passed through to callback function
|
530
|
+
* @return 0 or an error code
|
531
|
+
*/
|
532
|
+
GIT_EXTERN(int) git_index_update_all(
|
533
|
+
git_index *index,
|
534
|
+
const git_strarray *pathspec,
|
535
|
+
git_index_matched_path_cb callback,
|
536
|
+
void *payload);
|
537
|
+
|
402
538
|
/**
|
403
539
|
* Find the first position of any entries which point to given
|
404
540
|
* path in the Git index.
|
@@ -434,7 +570,7 @@ GIT_EXTERN(int) git_index_find(size_t *at_pos, git_index *index, const char *pat
|
|
434
570
|
* @return 0 or an error code
|
435
571
|
*/
|
436
572
|
GIT_EXTERN(int) git_index_conflict_add(
|
437
|
-
|
573
|
+
git_index *index,
|
438
574
|
const git_index_entry *ancestor_entry,
|
439
575
|
const git_index_entry *our_entry,
|
440
576
|
const git_index_entry *their_entry);
|
@@ -442,9 +578,9 @@ GIT_EXTERN(int) git_index_conflict_add(
|
|
442
578
|
/**
|
443
579
|
* Get the index entries that represent a conflict of a single file.
|
444
580
|
*
|
445
|
-
* The
|
446
|
-
*
|
447
|
-
*
|
581
|
+
* The entries are not modifiable and should not be freed. Because the
|
582
|
+
* `git_index_entry` struct is a publicly defined struct, you should
|
583
|
+
* be able to make your own permanent copy of the data if necessary.
|
448
584
|
*
|
449
585
|
* @param ancestor_out Pointer to store the ancestor entry
|
450
586
|
* @param our_out Pointer to store the our entry
|
@@ -452,7 +588,12 @@ GIT_EXTERN(int) git_index_conflict_add(
|
|
452
588
|
* @param index an existing index object
|
453
589
|
* @param path path to search
|
454
590
|
*/
|
455
|
-
GIT_EXTERN(int) git_index_conflict_get(
|
591
|
+
GIT_EXTERN(int) git_index_conflict_get(
|
592
|
+
const git_index_entry **ancestor_out,
|
593
|
+
const git_index_entry **our_out,
|
594
|
+
const git_index_entry **their_out,
|
595
|
+
git_index *index,
|
596
|
+
const char *path);
|
456
597
|
|
457
598
|
/**
|
458
599
|
* Removes the index entries that represent a conflict of a single file.
|
@@ -476,101 +617,39 @@ GIT_EXTERN(void) git_index_conflict_cleanup(git_index *index);
|
|
476
617
|
*/
|
477
618
|
GIT_EXTERN(int) git_index_has_conflicts(const git_index *index);
|
478
619
|
|
479
|
-
/**@}*/
|
480
|
-
|
481
|
-
/** @name Resolve Undo (REUC) index entry manipulation.
|
482
|
-
*
|
483
|
-
* These functions work on the Resolve Undo index extension and contains
|
484
|
-
* data about the original files that led to a merge conflict.
|
485
|
-
*/
|
486
|
-
/**@{*/
|
487
|
-
|
488
620
|
/**
|
489
|
-
*
|
621
|
+
* Create an iterator for the conflicts in the index. You may not modify the
|
622
|
+
* index while iterating, the results are undefined.
|
490
623
|
*
|
491
|
-
* @param index an existing index object
|
492
|
-
* @return integer of count of current resolve undo entries
|
493
|
-
*/
|
494
|
-
GIT_EXTERN(unsigned int) git_index_reuc_entrycount(git_index *index);
|
495
|
-
|
496
|
-
/**
|
497
|
-
* Finds the resolve undo entry that points to the given path in the Git
|
498
|
-
* index.
|
499
|
-
*
|
500
|
-
* @param at_pos the address to which the position of the reuc entry is written (optional)
|
501
|
-
* @param index an existing index object
|
502
|
-
* @param path path to search
|
503
|
-
* @return 0 if found, < 0 otherwise (GIT_ENOTFOUND)
|
504
|
-
*/
|
505
|
-
GIT_EXTERN(int) git_index_reuc_find(size_t *at_pos, git_index *index, const char *path);
|
506
|
-
|
507
|
-
/**
|
508
|
-
* Get a resolve undo entry from the index.
|
509
|
-
*
|
510
|
-
* The returned entry is read-only and should not be modified
|
511
|
-
* or freed by the caller.
|
512
|
-
*
|
513
|
-
* @param index an existing index object
|
514
|
-
* @param path path to search
|
515
|
-
* @return the resolve undo entry; NULL if not found
|
516
|
-
*/
|
517
|
-
GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_bypath(git_index *index, const char *path);
|
518
|
-
|
519
|
-
/**
|
520
|
-
* Get a resolve undo entry from the index.
|
521
|
-
*
|
522
|
-
* The returned entry is read-only and should not be modified
|
523
|
-
* or freed by the caller.
|
524
|
-
*
|
525
|
-
* @param index an existing index object
|
526
|
-
* @param n the position of the entry
|
527
|
-
* @return a pointer to the resolve undo entry; NULL if out of bounds
|
528
|
-
*/
|
529
|
-
GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_byindex(git_index *index, size_t n);
|
530
|
-
|
531
|
-
/**
|
532
|
-
* Adds a resolve undo entry for a file based on the given parameters.
|
533
|
-
*
|
534
|
-
* The resolve undo entry contains the OIDs of files that were involved
|
535
|
-
* in a merge conflict after the conflict has been resolved. This allows
|
536
|
-
* conflicts to be re-resolved later.
|
537
|
-
*
|
538
|
-
* If there exists a resolve undo entry for the given path in the index,
|
539
|
-
* it will be removed.
|
540
|
-
*
|
541
|
-
* This method will fail in bare index instances.
|
542
|
-
*
|
543
|
-
* @param index an existing index object
|
544
|
-
* @param path filename to add
|
545
|
-
* @param ancestor_mode mode of the ancestor file
|
546
|
-
* @param ancestor_id oid of the ancestor file
|
547
|
-
* @param our_mode mode of our file
|
548
|
-
* @param our_id oid of our file
|
549
|
-
* @param their_mode mode of their file
|
550
|
-
* @param their_id oid of their file
|
551
624
|
* @return 0 or an error code
|
552
625
|
*/
|
553
|
-
GIT_EXTERN(int)
|
554
|
-
|
555
|
-
|
556
|
-
int their_mode, git_oid *their_id);
|
626
|
+
GIT_EXTERN(int) git_index_conflict_iterator_new(
|
627
|
+
git_index_conflict_iterator **iterator_out,
|
628
|
+
git_index *index);
|
557
629
|
|
558
630
|
/**
|
559
|
-
*
|
631
|
+
* Returns the current conflict (ancestor, ours and theirs entry) and
|
632
|
+
* advance the iterator internally to the next value.
|
560
633
|
*
|
561
|
-
* @param
|
562
|
-
* @param
|
563
|
-
* @
|
634
|
+
* @param ancestor_out Pointer to store the ancestor side of the conflict
|
635
|
+
* @param our_out Pointer to store our side of the conflict
|
636
|
+
* @param their_out Pointer to store their side of the conflict
|
637
|
+
* @return 0 (no error), GIT_ITEROVER (iteration is done) or an error code
|
638
|
+
* (negative value)
|
564
639
|
*/
|
565
|
-
GIT_EXTERN(int)
|
640
|
+
GIT_EXTERN(int) git_index_conflict_next(
|
641
|
+
const git_index_entry **ancestor_out,
|
642
|
+
const git_index_entry **our_out,
|
643
|
+
const git_index_entry **their_out,
|
644
|
+
git_index_conflict_iterator *iterator);
|
566
645
|
|
567
646
|
/**
|
568
|
-
*
|
647
|
+
* Frees a `git_index_conflict_iterator`.
|
569
648
|
*
|
570
|
-
* @param
|
571
|
-
* @return 0 or an error code
|
649
|
+
* @param iterator pointer to the iterator
|
572
650
|
*/
|
573
|
-
GIT_EXTERN(void)
|
651
|
+
GIT_EXTERN(void) git_index_conflict_iterator_free(
|
652
|
+
git_index_conflict_iterator *iterator);
|
574
653
|
|
575
654
|
/**@}*/
|
576
655
|
|