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
@@ -12,16 +12,15 @@
|
|
12
12
|
#include "git2/odb.h"
|
13
13
|
#include "git2/repository.h"
|
14
14
|
#include "git2/object.h"
|
15
|
+
#include "git2/config.h"
|
15
16
|
|
16
|
-
#include "index.h"
|
17
17
|
#include "cache.h"
|
18
18
|
#include "refs.h"
|
19
19
|
#include "buffer.h"
|
20
|
-
#include "odb.h"
|
21
20
|
#include "object.h"
|
22
21
|
#include "attrcache.h"
|
23
22
|
#include "strmap.h"
|
24
|
-
#include "
|
23
|
+
#include "diff_driver.h"
|
25
24
|
|
26
25
|
#define DOT_GIT ".git"
|
27
26
|
#define GIT_DIR DOT_GIT "/"
|
@@ -31,7 +30,13 @@
|
|
31
30
|
/** Cvar cache identifiers */
|
32
31
|
typedef enum {
|
33
32
|
GIT_CVAR_AUTO_CRLF = 0, /* core.autocrlf */
|
34
|
-
GIT_CVAR_EOL,
|
33
|
+
GIT_CVAR_EOL, /* core.eol */
|
34
|
+
GIT_CVAR_SYMLINKS, /* core.symlinks */
|
35
|
+
GIT_CVAR_IGNORECASE, /* core.ignorecase */
|
36
|
+
GIT_CVAR_FILEMODE, /* core.filemode */
|
37
|
+
GIT_CVAR_IGNORESTAT, /* core.ignorestat */
|
38
|
+
GIT_CVAR_TRUSTCTIME, /* core.trustctime */
|
39
|
+
GIT_CVAR_ABBREV, /* core.abbrev */
|
35
40
|
GIT_CVAR_CACHE_MAX
|
36
41
|
} git_cvar_cached;
|
37
42
|
|
@@ -67,7 +72,21 @@ typedef enum {
|
|
67
72
|
#else
|
68
73
|
GIT_EOL_NATIVE = GIT_EOL_LF,
|
69
74
|
#endif
|
70
|
-
GIT_EOL_DEFAULT = GIT_EOL_NATIVE
|
75
|
+
GIT_EOL_DEFAULT = GIT_EOL_NATIVE,
|
76
|
+
|
77
|
+
/* core.symlinks: bool */
|
78
|
+
GIT_SYMLINKS_DEFAULT = GIT_CVAR_TRUE,
|
79
|
+
/* core.ignorecase */
|
80
|
+
GIT_IGNORECASE_DEFAULT = GIT_CVAR_FALSE,
|
81
|
+
/* core.filemode */
|
82
|
+
GIT_FILEMODE_DEFAULT = GIT_CVAR_TRUE,
|
83
|
+
/* core.ignorestat */
|
84
|
+
GIT_IGNORESTAT_DEFAULT = GIT_CVAR_FALSE,
|
85
|
+
/* core.trustctime */
|
86
|
+
GIT_TRUSTCTIME_DEFAULT = GIT_CVAR_TRUE,
|
87
|
+
/* core.abbrev */
|
88
|
+
GIT_ABBREV_DEFAULT = 7,
|
89
|
+
|
71
90
|
} git_cvar_value;
|
72
91
|
|
73
92
|
/* internal repository init flags */
|
@@ -87,9 +106,11 @@ struct git_repository {
|
|
87
106
|
git_cache objects;
|
88
107
|
git_attr_cache attrcache;
|
89
108
|
git_strmap *submodules;
|
109
|
+
git_diff_driver_registry *diff_drivers;
|
90
110
|
|
91
111
|
char *path_repository;
|
92
112
|
char *workdir;
|
113
|
+
char *namespace;
|
93
114
|
|
94
115
|
unsigned is_bare:1;
|
95
116
|
unsigned int lru_counter;
|
data/vendor/libgit2/src/reset.c
CHANGED
@@ -14,60 +14,6 @@
|
|
14
14
|
|
15
15
|
#include "git2.h"
|
16
16
|
|
17
|
-
static int disambiguate_refname(git_reference **out, git_repository *repo, const char *refname)
|
18
|
-
{
|
19
|
-
int error, i;
|
20
|
-
bool fallbackmode = true;
|
21
|
-
git_reference *ref;
|
22
|
-
git_buf refnamebuf = GIT_BUF_INIT, name = GIT_BUF_INIT;
|
23
|
-
|
24
|
-
static const char* formatters[] = {
|
25
|
-
"%s",
|
26
|
-
GIT_REFS_DIR "%s",
|
27
|
-
GIT_REFS_TAGS_DIR "%s",
|
28
|
-
GIT_REFS_HEADS_DIR "%s",
|
29
|
-
GIT_REFS_REMOTES_DIR "%s",
|
30
|
-
GIT_REFS_REMOTES_DIR "%s/" GIT_HEAD_FILE,
|
31
|
-
NULL
|
32
|
-
};
|
33
|
-
|
34
|
-
if (*refname)
|
35
|
-
git_buf_puts(&name, refname);
|
36
|
-
else {
|
37
|
-
git_buf_puts(&name, GIT_HEAD_FILE);
|
38
|
-
fallbackmode = false;
|
39
|
-
}
|
40
|
-
|
41
|
-
for (i = 0; formatters[i] && (fallbackmode || i == 0); i++) {
|
42
|
-
|
43
|
-
git_buf_clear(&refnamebuf);
|
44
|
-
|
45
|
-
if ((error = git_buf_printf(&refnamebuf, formatters[i], git_buf_cstr(&name))) < 0)
|
46
|
-
goto cleanup;
|
47
|
-
|
48
|
-
if (!git_reference_is_valid_name(git_buf_cstr(&refnamebuf))) {
|
49
|
-
error = GIT_EINVALIDSPEC;
|
50
|
-
continue;
|
51
|
-
}
|
52
|
-
|
53
|
-
error = git_reference_lookup_resolved(&ref, repo, git_buf_cstr(&refnamebuf), -1);
|
54
|
-
|
55
|
-
if (!error) {
|
56
|
-
*out = ref;
|
57
|
-
error = 0;
|
58
|
-
goto cleanup;
|
59
|
-
}
|
60
|
-
|
61
|
-
if (error != GIT_ENOTFOUND)
|
62
|
-
goto cleanup;
|
63
|
-
}
|
64
|
-
|
65
|
-
cleanup:
|
66
|
-
git_buf_free(&name);
|
67
|
-
git_buf_free(&refnamebuf);
|
68
|
-
return error;
|
69
|
-
}
|
70
|
-
|
71
17
|
static int maybe_sha_or_abbrev(git_object** out, git_repository *repo, const char *spec, size_t speclen)
|
72
18
|
{
|
73
19
|
git_oid oid;
|
@@ -138,36 +84,45 @@ static int maybe_describe(git_object**out, git_repository *repo, const char *spe
|
|
138
84
|
return maybe_abbrev(out, repo, substr+2);
|
139
85
|
}
|
140
86
|
|
141
|
-
static int revparse_lookup_object(
|
87
|
+
static int revparse_lookup_object(
|
88
|
+
git_object **object_out,
|
89
|
+
git_reference **reference_out,
|
90
|
+
git_repository *repo,
|
91
|
+
const char *spec)
|
142
92
|
{
|
143
93
|
int error;
|
144
94
|
git_reference *ref;
|
145
95
|
|
146
|
-
error = maybe_sha(
|
96
|
+
error = maybe_sha(object_out, repo, spec);
|
147
97
|
if (!error)
|
148
98
|
return 0;
|
149
99
|
|
150
100
|
if (error < 0 && error != GIT_ENOTFOUND)
|
151
101
|
return error;
|
152
102
|
|
153
|
-
error =
|
103
|
+
error = git_reference_dwim(&ref, repo, spec);
|
154
104
|
if (!error) {
|
155
|
-
|
156
|
-
|
105
|
+
|
106
|
+
error = git_object_lookup(
|
107
|
+
object_out, repo, git_reference_target(ref), GIT_OBJ_ANY);
|
108
|
+
|
109
|
+
if (!error)
|
110
|
+
*reference_out = ref;
|
111
|
+
|
157
112
|
return error;
|
158
113
|
}
|
159
114
|
|
160
115
|
if (error < 0 && error != GIT_ENOTFOUND)
|
161
116
|
return error;
|
162
117
|
|
163
|
-
error = maybe_abbrev(
|
118
|
+
error = maybe_abbrev(object_out, repo, spec);
|
164
119
|
if (!error)
|
165
120
|
return 0;
|
166
121
|
|
167
122
|
if (error < 0 && error != GIT_ENOTFOUND)
|
168
123
|
return error;
|
169
124
|
|
170
|
-
error = maybe_describe(
|
125
|
+
error = maybe_describe(object_out, repo, spec);
|
171
126
|
if (!error)
|
172
127
|
return 0;
|
173
128
|
|
@@ -235,7 +190,7 @@ static int retrieve_previously_checked_out_branch_or_revision(git_object **out,
|
|
235
190
|
|
236
191
|
git_buf_put(&buf, msg+regexmatches[1].rm_so, regexmatches[1].rm_eo - regexmatches[1].rm_so);
|
237
192
|
|
238
|
-
if ((error =
|
193
|
+
if ((error = git_reference_dwim(base_ref, repo, git_buf_cstr(&buf))) == 0)
|
239
194
|
goto cleanup;
|
240
195
|
|
241
196
|
if (error < 0 && error != GIT_ENOTFOUND)
|
@@ -316,7 +271,7 @@ static int retrieve_revobject_from_reflog(git_object **out, git_reference **base
|
|
316
271
|
int error = -1;
|
317
272
|
|
318
273
|
if (*base_ref == NULL) {
|
319
|
-
if ((error =
|
274
|
+
if ((error = git_reference_dwim(&ref, repo, identifier)) < 0)
|
320
275
|
return error;
|
321
276
|
} else {
|
322
277
|
ref = *base_ref;
|
@@ -344,7 +299,7 @@ static int retrieve_remote_tracking_reference(git_reference **base_ref, const ch
|
|
344
299
|
int error = -1;
|
345
300
|
|
346
301
|
if (*base_ref == NULL) {
|
347
|
-
if ((error =
|
302
|
+
if ((error = git_reference_dwim(&ref, repo, identifier)) < 0)
|
348
303
|
return error;
|
349
304
|
} else {
|
350
305
|
ref = *base_ref;
|
@@ -671,14 +626,8 @@ static int ensure_base_rev_loaded(git_object **object, git_reference **reference
|
|
671
626
|
if (*object != NULL)
|
672
627
|
return 0;
|
673
628
|
|
674
|
-
if (*reference != NULL)
|
675
|
-
|
676
|
-
return error;
|
677
|
-
|
678
|
-
git_reference_free(*reference);
|
679
|
-
*reference = NULL;
|
680
|
-
return 0;
|
681
|
-
}
|
629
|
+
if (*reference != NULL)
|
630
|
+
return object_from_reference(object, *reference);
|
682
631
|
|
683
632
|
if (!allow_empty_identifier && identifier_len == 0)
|
684
633
|
return GIT_EINVALIDSPEC;
|
@@ -686,7 +635,7 @@ static int ensure_base_rev_loaded(git_object **object, git_reference **reference
|
|
686
635
|
if (git_buf_put(&identifier, spec, identifier_len) < 0)
|
687
636
|
return -1;
|
688
637
|
|
689
|
-
error = revparse_lookup_object(object, repo, git_buf_cstr(&identifier));
|
638
|
+
error = revparse_lookup_object(object, reference, repo, git_buf_cstr(&identifier));
|
690
639
|
git_buf_free(&identifier);
|
691
640
|
|
692
641
|
return error;
|
@@ -722,7 +671,12 @@ static int ensure_left_hand_identifier_is_not_known_yet(git_object *object, git_
|
|
722
671
|
return GIT_EINVALIDSPEC;
|
723
672
|
}
|
724
673
|
|
725
|
-
int
|
674
|
+
int revparse__ext(
|
675
|
+
git_object **object_out,
|
676
|
+
git_reference **reference_out,
|
677
|
+
size_t *identifier_len_out,
|
678
|
+
git_repository *repo,
|
679
|
+
const char *spec)
|
726
680
|
{
|
727
681
|
size_t pos = 0, identifier_len = 0;
|
728
682
|
int error = -1, n;
|
@@ -731,9 +685,10 @@ int git_revparse_single(git_object **out, git_repository *repo, const char *spec
|
|
731
685
|
git_reference *reference = NULL;
|
732
686
|
git_object *base_rev = NULL;
|
733
687
|
|
734
|
-
assert(
|
688
|
+
assert(object_out && reference_out && repo && spec);
|
735
689
|
|
736
|
-
*
|
690
|
+
*object_out = NULL;
|
691
|
+
*reference_out = NULL;
|
737
692
|
|
738
693
|
while (spec[pos]) {
|
739
694
|
switch (spec[pos]) {
|
@@ -852,7 +807,9 @@ int git_revparse_single(git_object **out, git_repository *repo, const char *spec
|
|
852
807
|
if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, false)) < 0)
|
853
808
|
goto cleanup;
|
854
809
|
|
855
|
-
*
|
810
|
+
*object_out = base_rev;
|
811
|
+
*reference_out = reference;
|
812
|
+
*identifier_len_out = identifier_len;
|
856
813
|
error = 0;
|
857
814
|
|
858
815
|
cleanup:
|
@@ -862,12 +819,61 @@ cleanup:
|
|
862
819
|
"Failed to parse revision specifier - Invalid pattern '%s'", spec);
|
863
820
|
|
864
821
|
git_object_free(base_rev);
|
822
|
+
git_reference_free(reference);
|
865
823
|
}
|
866
|
-
|
824
|
+
|
867
825
|
git_buf_free(&buf);
|
868
826
|
return error;
|
869
827
|
}
|
870
828
|
|
829
|
+
int git_revparse_ext(
|
830
|
+
git_object **object_out,
|
831
|
+
git_reference **reference_out,
|
832
|
+
git_repository *repo,
|
833
|
+
const char *spec)
|
834
|
+
{
|
835
|
+
int error;
|
836
|
+
size_t identifier_len;
|
837
|
+
git_object *obj = NULL;
|
838
|
+
git_reference *ref = NULL;
|
839
|
+
|
840
|
+
if ((error = revparse__ext(&obj, &ref, &identifier_len, repo, spec)) < 0)
|
841
|
+
goto cleanup;
|
842
|
+
|
843
|
+
*object_out = obj;
|
844
|
+
*reference_out = ref;
|
845
|
+
GIT_UNUSED(identifier_len);
|
846
|
+
|
847
|
+
return 0;
|
848
|
+
|
849
|
+
cleanup:
|
850
|
+
git_object_free(obj);
|
851
|
+
git_reference_free(ref);
|
852
|
+
return error;
|
853
|
+
}
|
854
|
+
|
855
|
+
int git_revparse_single(git_object **out, git_repository *repo, const char *spec)
|
856
|
+
{
|
857
|
+
int error;
|
858
|
+
git_object *obj = NULL;
|
859
|
+
git_reference *ref = NULL;
|
860
|
+
|
861
|
+
*out = NULL;
|
862
|
+
|
863
|
+
if ((error = git_revparse_ext(&obj, &ref, repo, spec)) < 0)
|
864
|
+
goto cleanup;
|
865
|
+
|
866
|
+
git_reference_free(ref);
|
867
|
+
|
868
|
+
*out = obj;
|
869
|
+
|
870
|
+
return 0;
|
871
|
+
|
872
|
+
cleanup:
|
873
|
+
git_object_free(obj);
|
874
|
+
git_reference_free(ref);
|
875
|
+
return error;
|
876
|
+
}
|
871
877
|
|
872
878
|
int git_revparse(
|
873
879
|
git_revspec *revspec,
|
@@ -909,4 +915,3 @@ int git_revparse(
|
|
909
915
|
|
910
916
|
return error;
|
911
917
|
}
|
912
|
-
|
@@ -186,7 +186,7 @@ static int push_glob(git_revwalk *walk, const char *glob, int hide)
|
|
186
186
|
data.hide = hide;
|
187
187
|
|
188
188
|
if (git_reference_foreach_glob(
|
189
|
-
walk->repo, git_buf_cstr(&buf),
|
189
|
+
walk->repo, git_buf_cstr(&buf), push_glob_cb, &data) < 0)
|
190
190
|
goto on_error;
|
191
191
|
|
192
192
|
regfree(&preg);
|
@@ -9,6 +9,7 @@
|
|
9
9
|
#include "signature.h"
|
10
10
|
#include "repository.h"
|
11
11
|
#include "git2/common.h"
|
12
|
+
#include "posix.h"
|
12
13
|
|
13
14
|
void git_signature_free(git_signature *sig)
|
14
15
|
{
|
@@ -35,11 +36,11 @@ static bool contains_angle_brackets(const char *input)
|
|
35
36
|
|
36
37
|
static char *extract_trimmed(const char *ptr, size_t len)
|
37
38
|
{
|
38
|
-
while (len && ptr[0]
|
39
|
+
while (len && git__isspace(ptr[0])) {
|
39
40
|
ptr++; len--;
|
40
41
|
}
|
41
42
|
|
42
|
-
while (len && ptr[len - 1]
|
43
|
+
while (len && git__isspace(ptr[len - 1])) {
|
43
44
|
len--;
|
44
45
|
}
|
45
46
|
|
@@ -66,10 +67,12 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
|
|
66
67
|
p->name = extract_trimmed(name, strlen(name));
|
67
68
|
p->email = extract_trimmed(email, strlen(email));
|
68
69
|
|
69
|
-
if (p->name == NULL || p->email == NULL
|
70
|
-
|
70
|
+
if (p->name == NULL || p->email == NULL)
|
71
|
+
return -1; /* oom */
|
72
|
+
|
73
|
+
if (p->name[0] == '\0') {
|
71
74
|
git_signature_free(p);
|
72
|
-
return
|
75
|
+
return signature_error("Signature cannot have an empty name");
|
73
76
|
}
|
74
77
|
|
75
78
|
p->when.time = time;
|
@@ -81,9 +84,16 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
|
|
81
84
|
|
82
85
|
git_signature *git_signature_dup(const git_signature *sig)
|
83
86
|
{
|
84
|
-
git_signature *new;
|
85
|
-
|
87
|
+
git_signature *new = git__calloc(1, sizeof(git_signature));
|
88
|
+
|
89
|
+
if (new == NULL)
|
86
90
|
return NULL;
|
91
|
+
|
92
|
+
new->name = git__strdup(sig->name);
|
93
|
+
new->email = git__strdup(sig->email);
|
94
|
+
new->when.time = sig->when.time;
|
95
|
+
new->when.offset = sig->when.offset;
|
96
|
+
|
87
97
|
return new;
|
88
98
|
}
|
89
99
|
|
@@ -164,9 +174,11 @@ int git_signature__parse(git_signature *sig, const char **buffer_out,
|
|
164
174
|
|
165
175
|
tz_start = time_end + 1;
|
166
176
|
|
167
|
-
if ((tz_start[0] != '-' && tz_start[0] != '+') ||
|
168
|
-
git__strtol32(&offset, tz_start + 1, &tz_end, 10) < 0)
|
169
|
-
|
177
|
+
if ((tz_start[0] != '-' && tz_start[0] != '+') ||
|
178
|
+
git__strtol32(&offset, tz_start + 1, &tz_end, 10) < 0) {
|
179
|
+
//malformed timezone, just assume it's zero
|
180
|
+
offset = 0;
|
181
|
+
}
|
170
182
|
|
171
183
|
hours = offset / 100;
|
172
184
|
mins = offset % 100;
|
data/vendor/libgit2/src/stash.c
CHANGED
@@ -14,6 +14,7 @@
|
|
14
14
|
#include "git2/stash.h"
|
15
15
|
#include "git2/status.h"
|
16
16
|
#include "git2/checkout.h"
|
17
|
+
#include "git2/index.h"
|
17
18
|
#include "signature.h"
|
18
19
|
|
19
20
|
static int create_error(int error, const char *msg)
|
@@ -587,8 +588,10 @@ int git_stash_foreach(
|
|
587
588
|
const git_reflog_entry *entry;
|
588
589
|
|
589
590
|
error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE);
|
590
|
-
if (error == GIT_ENOTFOUND)
|
591
|
+
if (error == GIT_ENOTFOUND) {
|
592
|
+
giterr_clear();
|
591
593
|
return 0;
|
594
|
+
}
|
592
595
|
if (error < 0)
|
593
596
|
goto cleanup;
|
594
597
|
|
@@ -651,7 +654,7 @@ int git_stash_drop(
|
|
651
654
|
const git_reflog_entry *entry;
|
652
655
|
|
653
656
|
entry = git_reflog_entry_byindex(reflog, 0);
|
654
|
-
|
657
|
+
|
655
658
|
git_reference_free(stash);
|
656
659
|
error = git_reference_create(&stash, repo, GIT_REFS_STASH_FILE, &entry->oid_cur, 1);
|
657
660
|
}
|