rugged 1.2.0 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +1 -1
- data/vendor/libgit2/cmake/FindLibSSH2.cmake +13 -0
- data/vendor/libgit2/include/git2/attr.h +7 -1
- data/vendor/libgit2/include/git2/blob.h +7 -1
- data/vendor/libgit2/include/git2/clone.h +1 -1
- data/vendor/libgit2/include/git2/common.h +29 -1
- data/vendor/libgit2/include/git2/deprecated.h +120 -0
- data/vendor/libgit2/include/git2/diff.h +3 -97
- data/vendor/libgit2/include/git2/email.h +127 -0
- data/vendor/libgit2/include/git2/errors.h +1 -0
- data/vendor/libgit2/include/git2/filter.h +7 -1
- data/vendor/libgit2/include/git2/notes.h +2 -2
- data/vendor/libgit2/include/git2/oidarray.h +5 -8
- data/vendor/libgit2/include/git2/remote.h +4 -4
- data/vendor/libgit2/include/git2/repository.h +12 -10
- data/vendor/libgit2/include/git2/stash.h +1 -1
- data/vendor/libgit2/include/git2/stdint.h +3 -3
- data/vendor/libgit2/include/git2/sys/email.h +45 -0
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +7 -0
- data/vendor/libgit2/src/attr.c +24 -9
- data/vendor/libgit2/src/attr_file.c +23 -15
- data/vendor/libgit2/src/attr_file.h +3 -3
- data/vendor/libgit2/src/blame.c +4 -4
- data/vendor/libgit2/src/blame_git.c +1 -1
- data/vendor/libgit2/src/blob.c +15 -9
- data/vendor/libgit2/src/buffer.c +16 -8
- data/vendor/libgit2/src/buffer.h +2 -1
- data/vendor/libgit2/src/cc-compat.h +1 -7
- data/vendor/libgit2/src/checkout.c +6 -7
- data/vendor/libgit2/src/clone.c +1 -1
- data/vendor/libgit2/src/commit_graph.c +1 -1
- data/vendor/libgit2/src/config.c +11 -7
- data/vendor/libgit2/src/config_file.c +2 -2
- data/vendor/libgit2/src/config_parse.c +1 -1
- data/vendor/libgit2/src/describe.c +1 -1
- data/vendor/libgit2/src/diff.c +41 -173
- data/vendor/libgit2/src/email.c +299 -0
- data/vendor/libgit2/src/email.h +25 -0
- data/vendor/libgit2/src/filter.c +7 -1
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +8 -8
- data/vendor/libgit2/src/ignore.c +2 -2
- data/vendor/libgit2/src/indexer.c +37 -3
- data/vendor/libgit2/src/libgit2.c +31 -0
- data/vendor/libgit2/src/merge.c +7 -4
- data/vendor/libgit2/src/notes.c +31 -31
- data/vendor/libgit2/src/oidarray.c +10 -1
- data/vendor/libgit2/src/path.c +214 -55
- data/vendor/libgit2/src/path.h +29 -9
- data/vendor/libgit2/src/pathspec.c +1 -1
- data/vendor/libgit2/src/refdb_fs.c +1 -1
- data/vendor/libgit2/src/refs.c +2 -2
- data/vendor/libgit2/src/refspec.c +1 -1
- data/vendor/libgit2/src/remote.c +12 -5
- data/vendor/libgit2/src/repository.c +233 -41
- data/vendor/libgit2/src/repository.h +5 -0
- data/vendor/libgit2/src/reset.c +1 -1
- data/vendor/libgit2/src/revparse.c +4 -4
- data/vendor/libgit2/src/stash.c +1 -1
- data/vendor/libgit2/src/streams/openssl_legacy.c +1 -1
- data/vendor/libgit2/src/streams/openssl_legacy.h +1 -1
- data/vendor/libgit2/src/threadstate.c +2 -1
- data/vendor/libgit2/src/trailer.c +1 -1
- data/vendor/libgit2/src/transports/ssh.c +4 -4
- data/vendor/libgit2/src/transports/winhttp.c +1 -1
- data/vendor/libgit2/src/util.c +1 -1
- data/vendor/libgit2/src/util.h +1 -1
- data/vendor/libgit2/src/win32/findfile.c +1 -1
- data/vendor/libgit2/src/win32/posix.h +6 -6
- data/vendor/libgit2/src/win32/posix_w32.c +9 -6
- metadata +11 -6
data/vendor/libgit2/src/path.h
CHANGED
@@ -85,7 +85,7 @@ extern int git_path_to_dir(git_buf *path);
|
|
85
85
|
/**
|
86
86
|
* Ensure string has a trailing '/' if there is space for it.
|
87
87
|
*/
|
88
|
-
extern void git_path_string_to_dir(char*
|
88
|
+
extern void git_path_string_to_dir(char *path, size_t size);
|
89
89
|
|
90
90
|
/**
|
91
91
|
* Taken from git.git; returns nonzero if the given path is "." or "..".
|
@@ -722,16 +722,36 @@ int git_path_normalize_slashes(git_buf *out, const char *path);
|
|
722
722
|
|
723
723
|
bool git_path_supports_symlinks(const char *dir);
|
724
724
|
|
725
|
+
typedef enum {
|
726
|
+
GIT_PATH_MOCK_OWNER_NONE = 0, /* do filesystem lookups as normal */
|
727
|
+
GIT_PATH_MOCK_OWNER_SYSTEM = 1,
|
728
|
+
GIT_PATH_MOCK_OWNER_CURRENT_USER = 2,
|
729
|
+
GIT_PATH_MOCK_OWNER_OTHER = 3
|
730
|
+
} git_path__mock_owner_t;
|
731
|
+
|
732
|
+
/**
|
733
|
+
* Sets the mock ownership for files; subsequent calls to
|
734
|
+
* `git_path_owner_is_*` functions will return this data until cleared
|
735
|
+
* with `GIT_PATH_MOCK_OWNER_NONE`.
|
736
|
+
*/
|
737
|
+
void git_path__set_owner(git_path__mock_owner_t owner);
|
738
|
+
|
725
739
|
/**
|
726
|
-
* Validate a system file's ownership
|
727
|
-
*
|
728
740
|
* Verify that the file in question is owned by an administrator or system
|
729
|
-
* account
|
730
|
-
|
731
|
-
*
|
732
|
-
|
733
|
-
|
741
|
+
* account.
|
742
|
+
*/
|
743
|
+
int git_path_owner_is_system(bool *out, const char *path);
|
744
|
+
|
745
|
+
/**
|
746
|
+
* Verify that the file in question is owned by the current user;
|
747
|
+
*/
|
748
|
+
|
749
|
+
int git_path_owner_is_current_user(bool *out, const char *path);
|
750
|
+
|
751
|
+
/**
|
752
|
+
* Verify that the file in question is owned by an administrator or system
|
753
|
+
* account _or_ the current user;
|
734
754
|
*/
|
735
|
-
int
|
755
|
+
int git_path_owner_is_system_or_current_user(bool *out, const char *path);
|
736
756
|
|
737
757
|
#endif
|
@@ -24,7 +24,7 @@ char *git_pathspec_prefix(const git_strarray *pathspec)
|
|
24
24
|
const char *scan;
|
25
25
|
|
26
26
|
if (!pathspec || !pathspec->count ||
|
27
|
-
git_buf_common_prefix(&prefix, pathspec) < 0)
|
27
|
+
git_buf_common_prefix(&prefix, pathspec->strings, pathspec->count) < 0)
|
28
28
|
return NULL;
|
29
29
|
|
30
30
|
/* diff prefix will only be leading non-wildcards */
|
data/vendor/libgit2/src/refs.c
CHANGED
@@ -249,7 +249,7 @@ int git_reference_dwim(git_reference **out, git_repository *repo, const char *re
|
|
249
249
|
git_reference *ref;
|
250
250
|
git_buf refnamebuf = GIT_BUF_INIT, name = GIT_BUF_INIT;
|
251
251
|
|
252
|
-
static const char*
|
252
|
+
static const char *formatters[] = {
|
253
253
|
"%s",
|
254
254
|
GIT_REFS_DIR "%s",
|
255
255
|
GIT_REFS_TAGS_DIR "%s",
|
@@ -1246,7 +1246,7 @@ int git_reference_is_note(const git_reference *ref)
|
|
1246
1246
|
return git_reference__is_note(ref->name);
|
1247
1247
|
}
|
1248
1248
|
|
1249
|
-
static int peel_error(int error, const git_reference *ref, const char*
|
1249
|
+
static int peel_error(int error, const git_reference *ref, const char *msg)
|
1250
1250
|
{
|
1251
1251
|
git_error_set(
|
1252
1252
|
GIT_ERROR_INVALID,
|
@@ -359,7 +359,7 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
|
|
359
359
|
git_remote_head key;
|
360
360
|
git_refspec *cur;
|
361
361
|
|
362
|
-
const char*
|
362
|
+
const char *formatters[] = {
|
363
363
|
GIT_REFS_DIR "%s",
|
364
364
|
GIT_REFS_TAGS_DIR "%s",
|
365
365
|
GIT_REFS_HEADS_DIR "%s",
|
data/vendor/libgit2/src/remote.c
CHANGED
@@ -677,7 +677,7 @@ int git_remote_set_instance_pushurl(git_remote *remote, const char *url)
|
|
677
677
|
return 0;
|
678
678
|
}
|
679
679
|
|
680
|
-
int git_remote_set_pushurl(git_repository *repo, const char *remote, const char*
|
680
|
+
int git_remote_set_pushurl(git_repository *repo, const char *remote, const char *url)
|
681
681
|
{
|
682
682
|
return set_url(repo, remote, CONFIG_PUSHURL_FMT, url);
|
683
683
|
}
|
@@ -884,15 +884,22 @@ static void url_config_trim(git_net_url *url)
|
|
884
884
|
|
885
885
|
static int http_proxy_config(char **out, git_remote *remote, git_net_url *url)
|
886
886
|
{
|
887
|
-
git_config *cfg;
|
887
|
+
git_config *cfg = NULL;
|
888
888
|
git_buf buf = GIT_BUF_INIT;
|
889
889
|
git_net_url lookup_url = GIT_NET_URL_INIT;
|
890
890
|
int error;
|
891
891
|
|
892
|
-
if ((error = git_net_url_dup(&lookup_url, url)) < 0
|
893
|
-
(error = git_repository_config__weakptr(&cfg, remote->repo)) < 0)
|
892
|
+
if ((error = git_net_url_dup(&lookup_url, url)) < 0)
|
894
893
|
goto done;
|
895
894
|
|
895
|
+
if (remote->repo) {
|
896
|
+
if ((error = git_repository_config(&cfg, remote->repo)) < 0)
|
897
|
+
goto done;
|
898
|
+
} else {
|
899
|
+
if ((error = git_config_open_default(&cfg)) < 0)
|
900
|
+
goto done;
|
901
|
+
}
|
902
|
+
|
896
903
|
/* remote.<name>.proxy config setting */
|
897
904
|
if (remote->name && remote->name[0]) {
|
898
905
|
git_buf_clear(&buf);
|
@@ -922,6 +929,7 @@ static int http_proxy_config(char **out, git_remote *remote, git_net_url *url)
|
|
922
929
|
error = lookup_config(out, cfg, "http.proxy");
|
923
930
|
|
924
931
|
done:
|
932
|
+
git_config_free(cfg);
|
925
933
|
git_buf_dispose(&buf);
|
926
934
|
git_net_url_dispose(&lookup_url);
|
927
935
|
return error;
|
@@ -971,7 +979,6 @@ int git_remote__http_proxy(char **out, git_remote *remote, git_net_url *url)
|
|
971
979
|
|
972
980
|
GIT_ASSERT_ARG(out);
|
973
981
|
GIT_ASSERT_ARG(remote);
|
974
|
-
GIT_ASSERT_ARG(remote->repo);
|
975
982
|
|
976
983
|
*out = NULL;
|
977
984
|
|
@@ -38,6 +38,7 @@
|
|
38
38
|
# include "win32/w32_util.h"
|
39
39
|
#endif
|
40
40
|
|
41
|
+
bool git_repository__validate_ownership = true;
|
41
42
|
bool git_repository__fsync_gitdir = false;
|
42
43
|
|
43
44
|
static const struct {
|
@@ -64,6 +65,7 @@ static const struct {
|
|
64
65
|
|
65
66
|
static int check_repositoryformatversion(int *version, git_config *config);
|
66
67
|
static int check_extensions(git_config *config, int version);
|
68
|
+
static int load_global_config(git_config **config);
|
67
69
|
|
68
70
|
#define GIT_COMMONDIR_FILE "commondir"
|
69
71
|
#define GIT_GITDIR_FILE "gitdir"
|
@@ -482,6 +484,63 @@ static int read_gitfile(git_buf *path_out, const char *file_path)
|
|
482
484
|
return error;
|
483
485
|
}
|
484
486
|
|
487
|
+
typedef struct {
|
488
|
+
const char *repo_path;
|
489
|
+
git_buf tmp;
|
490
|
+
bool is_safe;
|
491
|
+
} validate_ownership_data;
|
492
|
+
|
493
|
+
static int validate_ownership_cb(const git_config_entry *entry, void *payload)
|
494
|
+
{
|
495
|
+
validate_ownership_data *data = payload;
|
496
|
+
|
497
|
+
if (strcmp(entry->value, "") == 0)
|
498
|
+
data->is_safe = false;
|
499
|
+
|
500
|
+
if (git_path_prettify_dir(&data->tmp, entry->value, NULL) == 0 &&
|
501
|
+
strcmp(data->tmp.ptr, data->repo_path) == 0)
|
502
|
+
data->is_safe = true;
|
503
|
+
|
504
|
+
return 0;
|
505
|
+
}
|
506
|
+
|
507
|
+
static int validate_ownership(const char *repo_path)
|
508
|
+
{
|
509
|
+
git_config *config = NULL;
|
510
|
+
validate_ownership_data data = { repo_path, GIT_BUF_INIT, false };
|
511
|
+
bool is_safe;
|
512
|
+
int error;
|
513
|
+
|
514
|
+
if ((error = git_path_owner_is_current_user(&is_safe, repo_path)) < 0) {
|
515
|
+
if (error == GIT_ENOTFOUND)
|
516
|
+
error = 0;
|
517
|
+
|
518
|
+
goto done;
|
519
|
+
}
|
520
|
+
|
521
|
+
if (is_safe) {
|
522
|
+
error = 0;
|
523
|
+
goto done;
|
524
|
+
}
|
525
|
+
|
526
|
+
if (load_global_config(&config) == 0) {
|
527
|
+
error = git_config_get_multivar_foreach(config, "safe.directory", NULL, validate_ownership_cb, &data);
|
528
|
+
|
529
|
+
if (!error && data.is_safe)
|
530
|
+
goto done;
|
531
|
+
}
|
532
|
+
|
533
|
+
git_error_set(GIT_ERROR_CONFIG,
|
534
|
+
"repository path '%s' is not owned by current user",
|
535
|
+
repo_path);
|
536
|
+
error = GIT_EOWNER;
|
537
|
+
|
538
|
+
done:
|
539
|
+
git_config_free(config);
|
540
|
+
git_buf_dispose(&data.tmp);
|
541
|
+
return error;
|
542
|
+
}
|
543
|
+
|
485
544
|
static int find_repo(
|
486
545
|
git_buf *gitdir_path,
|
487
546
|
git_buf *workdir_path,
|
@@ -855,6 +914,7 @@ int git_repository_open_ext(
|
|
855
914
|
gitlink = GIT_BUF_INIT, commondir = GIT_BUF_INIT;
|
856
915
|
git_repository *repo = NULL;
|
857
916
|
git_config *config = NULL;
|
917
|
+
const char *validation_path;
|
858
918
|
int version = 0;
|
859
919
|
|
860
920
|
if (flags & GIT_REPOSITORY_OPEN_FROM_ENV)
|
@@ -903,16 +963,24 @@ int git_repository_open_ext(
|
|
903
963
|
if ((error = check_extensions(config, version)) < 0)
|
904
964
|
goto cleanup;
|
905
965
|
|
906
|
-
if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0)
|
966
|
+
if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0) {
|
907
967
|
repo->is_bare = 1;
|
908
|
-
else {
|
909
|
-
|
968
|
+
} else {
|
910
969
|
if (config &&
|
911
970
|
((error = load_config_data(repo, config)) < 0 ||
|
912
971
|
(error = load_workdir(repo, config, &workdir)) < 0))
|
913
972
|
goto cleanup;
|
914
973
|
}
|
915
974
|
|
975
|
+
/*
|
976
|
+
* Ensure that the git directory is owned by the current user.
|
977
|
+
*/
|
978
|
+
validation_path = repo->is_bare ? repo->gitdir : repo->workdir;
|
979
|
+
|
980
|
+
if (git_repository__validate_ownership &&
|
981
|
+
(error = validate_ownership(validation_path)) < 0)
|
982
|
+
goto cleanup;
|
983
|
+
|
916
984
|
cleanup:
|
917
985
|
git_buf_dispose(&gitdir);
|
918
986
|
git_buf_dispose(&workdir);
|
@@ -1427,15 +1495,60 @@ static int check_repositoryformatversion(int *version, git_config *config)
|
|
1427
1495
|
return 0;
|
1428
1496
|
}
|
1429
1497
|
|
1498
|
+
static const char *builtin_extensions[] = {
|
1499
|
+
"noop"
|
1500
|
+
};
|
1501
|
+
|
1502
|
+
static git_vector user_extensions = GIT_VECTOR_INIT;
|
1503
|
+
|
1430
1504
|
static int check_valid_extension(const git_config_entry *entry, void *payload)
|
1431
1505
|
{
|
1506
|
+
git_buf cfg = GIT_BUF_INIT;
|
1507
|
+
bool reject;
|
1508
|
+
const char *extension;
|
1509
|
+
size_t i;
|
1510
|
+
int error = 0;
|
1511
|
+
|
1432
1512
|
GIT_UNUSED(payload);
|
1433
1513
|
|
1434
|
-
|
1435
|
-
|
1514
|
+
git_vector_foreach (&user_extensions, i, extension) {
|
1515
|
+
git_buf_clear(&cfg);
|
1516
|
+
|
1517
|
+
/*
|
1518
|
+
* Users can specify that they don't want to support an
|
1519
|
+
* extension with a '!' prefix.
|
1520
|
+
*/
|
1521
|
+
if ((reject = (extension[0] == '!')) == true)
|
1522
|
+
extension = &extension[1];
|
1523
|
+
|
1524
|
+
if ((error = git_buf_printf(&cfg, "extensions.%s", extension)) < 0)
|
1525
|
+
goto done;
|
1526
|
+
|
1527
|
+
if (strcmp(entry->name, cfg.ptr) == 0) {
|
1528
|
+
if (reject)
|
1529
|
+
goto fail;
|
1530
|
+
|
1531
|
+
goto done;
|
1532
|
+
}
|
1533
|
+
}
|
1534
|
+
|
1535
|
+
for (i = 0; i < ARRAY_SIZE(builtin_extensions); i++) {
|
1536
|
+
extension = builtin_extensions[i];
|
1436
1537
|
|
1538
|
+
if ((error = git_buf_printf(&cfg, "extensions.%s", extension)) < 0)
|
1539
|
+
goto done;
|
1540
|
+
|
1541
|
+
if (strcmp(entry->name, cfg.ptr) == 0)
|
1542
|
+
goto done;
|
1543
|
+
}
|
1544
|
+
|
1545
|
+
fail:
|
1437
1546
|
git_error_set(GIT_ERROR_REPOSITORY, "unsupported extension name %s", entry->name);
|
1438
|
-
|
1547
|
+
error = -1;
|
1548
|
+
|
1549
|
+
done:
|
1550
|
+
git_buf_dispose(&cfg);
|
1551
|
+
return error;
|
1439
1552
|
}
|
1440
1553
|
|
1441
1554
|
static int check_extensions(git_config *config, int version)
|
@@ -1446,6 +1559,70 @@ static int check_extensions(git_config *config, int version)
|
|
1446
1559
|
return git_config_foreach_match(config, "^extensions\\.", check_valid_extension, NULL);
|
1447
1560
|
}
|
1448
1561
|
|
1562
|
+
int git_repository__extensions(char ***out, size_t *out_len)
|
1563
|
+
{
|
1564
|
+
git_vector extensions;
|
1565
|
+
const char *builtin, *user;
|
1566
|
+
char *extension;
|
1567
|
+
size_t i, j;
|
1568
|
+
|
1569
|
+
if (git_vector_init(&extensions, 8, NULL) < 0)
|
1570
|
+
return -1;
|
1571
|
+
|
1572
|
+
for (i = 0; i < ARRAY_SIZE(builtin_extensions); i++) {
|
1573
|
+
bool match = false;
|
1574
|
+
|
1575
|
+
builtin = builtin_extensions[i];
|
1576
|
+
|
1577
|
+
git_vector_foreach (&user_extensions, j, user) {
|
1578
|
+
if (user[0] == '!' && strcmp(builtin, &user[1]) == 0) {
|
1579
|
+
match = true;
|
1580
|
+
break;
|
1581
|
+
}
|
1582
|
+
}
|
1583
|
+
|
1584
|
+
if (match)
|
1585
|
+
continue;
|
1586
|
+
|
1587
|
+
if ((extension = git__strdup(builtin)) == NULL ||
|
1588
|
+
git_vector_insert(&extensions, extension) < 0)
|
1589
|
+
return -1;
|
1590
|
+
}
|
1591
|
+
|
1592
|
+
git_vector_foreach (&user_extensions, i, user) {
|
1593
|
+
if (user[0] == '!')
|
1594
|
+
continue;
|
1595
|
+
|
1596
|
+
if ((extension = git__strdup(user)) == NULL ||
|
1597
|
+
git_vector_insert(&extensions, extension) < 0)
|
1598
|
+
return -1;
|
1599
|
+
}
|
1600
|
+
|
1601
|
+
*out = (char **)git_vector_detach(out_len, NULL, &extensions);
|
1602
|
+
return 0;
|
1603
|
+
}
|
1604
|
+
|
1605
|
+
int git_repository__set_extensions(const char **extensions, size_t len)
|
1606
|
+
{
|
1607
|
+
char *extension;
|
1608
|
+
size_t i;
|
1609
|
+
|
1610
|
+
git_repository__free_extensions();
|
1611
|
+
|
1612
|
+
for (i = 0; i < len; i++) {
|
1613
|
+
if ((extension = git__strdup(extensions[i])) == NULL ||
|
1614
|
+
git_vector_insert(&user_extensions, extension) < 0)
|
1615
|
+
return -1;
|
1616
|
+
}
|
1617
|
+
|
1618
|
+
return 0;
|
1619
|
+
}
|
1620
|
+
|
1621
|
+
void git_repository__free_extensions(void)
|
1622
|
+
{
|
1623
|
+
git_vector_free_deep(&user_extensions);
|
1624
|
+
}
|
1625
|
+
|
1449
1626
|
int git_repository_create_head(const char *git_dir, const char *ref_name)
|
1450
1627
|
{
|
1451
1628
|
git_buf ref_path = GIT_BUF_INIT;
|
@@ -1500,13 +1677,40 @@ static bool is_filesystem_case_insensitive(const char *gitdir_path)
|
|
1500
1677
|
return is_insensitive;
|
1501
1678
|
}
|
1502
1679
|
|
1503
|
-
|
1680
|
+
/*
|
1681
|
+
* Return a configuration object with only the global and system
|
1682
|
+
* configurations; no repository-level configuration.
|
1683
|
+
*/
|
1684
|
+
static int load_global_config(git_config **config)
|
1504
1685
|
{
|
1505
|
-
git_config *config = NULL;
|
1506
1686
|
git_buf global_buf = GIT_BUF_INIT;
|
1507
1687
|
git_buf xdg_buf = GIT_BUF_INIT;
|
1508
1688
|
git_buf system_buf = GIT_BUF_INIT;
|
1509
1689
|
git_buf programdata_buf = GIT_BUF_INIT;
|
1690
|
+
int error;
|
1691
|
+
|
1692
|
+
git_config_find_global(&global_buf);
|
1693
|
+
git_config_find_xdg(&xdg_buf);
|
1694
|
+
git_config_find_system(&system_buf);
|
1695
|
+
git_config_find_programdata(&programdata_buf);
|
1696
|
+
|
1697
|
+
error = load_config(config, NULL,
|
1698
|
+
path_unless_empty(&global_buf),
|
1699
|
+
path_unless_empty(&xdg_buf),
|
1700
|
+
path_unless_empty(&system_buf),
|
1701
|
+
path_unless_empty(&programdata_buf));
|
1702
|
+
|
1703
|
+
git_buf_dispose(&global_buf);
|
1704
|
+
git_buf_dispose(&xdg_buf);
|
1705
|
+
git_buf_dispose(&system_buf);
|
1706
|
+
git_buf_dispose(&programdata_buf);
|
1707
|
+
|
1708
|
+
return error;
|
1709
|
+
}
|
1710
|
+
|
1711
|
+
static bool are_symlinks_supported(const char *wd_path)
|
1712
|
+
{
|
1713
|
+
git_config *config = NULL;
|
1510
1714
|
int symlinks = 0;
|
1511
1715
|
|
1512
1716
|
/*
|
@@ -1517,19 +1721,9 @@ static bool are_symlinks_supported(const char *wd_path)
|
|
1517
1721
|
* _not_ set, then we do not test or enable symlink support.
|
1518
1722
|
*/
|
1519
1723
|
#ifdef GIT_WIN32
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
git_config_find_programdata(&programdata_buf);
|
1524
|
-
|
1525
|
-
if (load_config(&config, NULL,
|
1526
|
-
path_unless_empty(&global_buf),
|
1527
|
-
path_unless_empty(&xdg_buf),
|
1528
|
-
path_unless_empty(&system_buf),
|
1529
|
-
path_unless_empty(&programdata_buf)) < 0)
|
1530
|
-
goto done;
|
1531
|
-
|
1532
|
-
if (git_config_get_bool(&symlinks, config, "core.symlinks") < 0 || !symlinks)
|
1724
|
+
if (load_global_config(&config) < 0 ||
|
1725
|
+
git_config_get_bool(&symlinks, config, "core.symlinks") < 0 ||
|
1726
|
+
!symlinks)
|
1533
1727
|
goto done;
|
1534
1728
|
#endif
|
1535
1729
|
|
@@ -1537,10 +1731,6 @@ static bool are_symlinks_supported(const char *wd_path)
|
|
1537
1731
|
goto done;
|
1538
1732
|
|
1539
1733
|
done:
|
1540
|
-
git_buf_dispose(&global_buf);
|
1541
|
-
git_buf_dispose(&xdg_buf);
|
1542
|
-
git_buf_dispose(&system_buf);
|
1543
|
-
git_buf_dispose(&programdata_buf);
|
1544
1734
|
git_config_free(config);
|
1545
1735
|
return symlinks != 0;
|
1546
1736
|
}
|
@@ -2731,34 +2921,36 @@ int git_repository_hashfile(
|
|
2731
2921
|
git_file fd = -1;
|
2732
2922
|
uint64_t len;
|
2733
2923
|
git_buf full_path = GIT_BUF_INIT;
|
2924
|
+
const char *workdir = git_repository_workdir(repo);
|
2734
2925
|
|
2735
2926
|
/* as_path can be NULL */
|
2736
2927
|
GIT_ASSERT_ARG(out);
|
2737
2928
|
GIT_ASSERT_ARG(path);
|
2738
2929
|
GIT_ASSERT_ARG(repo);
|
2739
2930
|
|
2740
|
-
|
2741
|
-
* apply filter rules defined in system and global files, but for
|
2742
|
-
* now that is not possible because git_filters_load() needs it.
|
2743
|
-
*/
|
2744
|
-
|
2745
|
-
if ((error = git_path_join_unrooted(
|
2746
|
-
&full_path, path, git_repository_workdir(repo), NULL)) < 0 ||
|
2931
|
+
if ((error = git_path_join_unrooted(&full_path, path, workdir, NULL)) < 0 ||
|
2747
2932
|
(error = git_path_validate_workdir_buf(repo, &full_path)) < 0)
|
2748
2933
|
return error;
|
2749
2934
|
|
2750
|
-
|
2751
|
-
|
2935
|
+
/*
|
2936
|
+
* NULL as_path means that we should derive it from the
|
2937
|
+
* given path.
|
2938
|
+
*/
|
2939
|
+
if (!as_path) {
|
2940
|
+
if (workdir && !git__prefixcmp(full_path.ptr, workdir))
|
2941
|
+
as_path = full_path.ptr + strlen(workdir);
|
2942
|
+
else
|
2943
|
+
as_path = "";
|
2944
|
+
}
|
2752
2945
|
|
2753
2946
|
/* passing empty string for "as_path" indicated --no-filters */
|
2754
2947
|
if (strlen(as_path) > 0) {
|
2755
2948
|
error = git_filter_list_load(
|
2756
2949
|
&fl, repo, NULL, as_path,
|
2757
2950
|
GIT_FILTER_TO_ODB, GIT_FILTER_DEFAULT);
|
2951
|
+
|
2758
2952
|
if (error < 0)
|
2759
2953
|
return error;
|
2760
|
-
} else {
|
2761
|
-
error = 0;
|
2762
2954
|
}
|
2763
2955
|
|
2764
2956
|
/* at this point, error is a count of the number of loaded filters */
|
@@ -2850,8 +3042,8 @@ cleanup:
|
|
2850
3042
|
}
|
2851
3043
|
|
2852
3044
|
int git_repository_set_head(
|
2853
|
-
git_repository*
|
2854
|
-
const char*
|
3045
|
+
git_repository *repo,
|
3046
|
+
const char *refname)
|
2855
3047
|
{
|
2856
3048
|
git_reference *ref = NULL, *current = NULL, *new_head = NULL;
|
2857
3049
|
git_buf log_message = GIT_BUF_INIT;
|
@@ -2900,8 +3092,8 @@ cleanup:
|
|
2900
3092
|
}
|
2901
3093
|
|
2902
3094
|
int git_repository_set_head_detached(
|
2903
|
-
git_repository*
|
2904
|
-
const git_oid*
|
3095
|
+
git_repository *repo,
|
3096
|
+
const git_oid *commitish)
|
2905
3097
|
{
|
2906
3098
|
return detach(repo, commitish, NULL);
|
2907
3099
|
}
|
@@ -2916,7 +3108,7 @@ int git_repository_set_head_detached_from_annotated(
|
|
2916
3108
|
return detach(repo, git_annotated_commit_id(commitish), commitish->description);
|
2917
3109
|
}
|
2918
3110
|
|
2919
|
-
int git_repository_detach_head(git_repository*
|
3111
|
+
int git_repository_detach_head(git_repository *repo)
|
2920
3112
|
{
|
2921
3113
|
git_reference *old_head = NULL, *new_head = NULL, *current = NULL;
|
2922
3114
|
git_object *object = NULL;
|
@@ -34,6 +34,7 @@
|
|
34
34
|
#define GIT_DIR_SHORTNAME "GIT~1"
|
35
35
|
|
36
36
|
extern bool git_repository__fsync_gitdir;
|
37
|
+
extern bool git_repository__validate_ownership;
|
37
38
|
|
38
39
|
/** Cvar cache identifiers */
|
39
40
|
typedef enum {
|
@@ -249,4 +250,8 @@ int git_repository_initialbranch(git_buf *out, git_repository *repo);
|
|
249
250
|
*/
|
250
251
|
int git_repository_workdir_path(git_buf *out, git_repository *repo, const char *path);
|
251
252
|
|
253
|
+
int git_repository__extensions(char ***out, size_t *out_len);
|
254
|
+
int git_repository__set_extensions(const char **extensions, size_t len);
|
255
|
+
void git_repository__free_extensions(void);
|
256
|
+
|
252
257
|
#endif
|
data/vendor/libgit2/src/reset.c
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
#include "git2.h"
|
16
16
|
|
17
|
-
static int maybe_sha_or_abbrev(git_object**
|
17
|
+
static int maybe_sha_or_abbrev(git_object **out, git_repository *repo, const char *spec, size_t speclen)
|
18
18
|
{
|
19
19
|
git_oid oid;
|
20
20
|
|
@@ -24,7 +24,7 @@ static int maybe_sha_or_abbrev(git_object** out, git_repository *repo, const cha
|
|
24
24
|
return git_object_lookup_prefix(out, repo, &oid, speclen, GIT_OBJECT_ANY);
|
25
25
|
}
|
26
26
|
|
27
|
-
static int maybe_sha(git_object**
|
27
|
+
static int maybe_sha(git_object **out, git_repository *repo, const char *spec)
|
28
28
|
{
|
29
29
|
size_t speclen = strlen(spec);
|
30
30
|
|
@@ -34,7 +34,7 @@ static int maybe_sha(git_object** out, git_repository *repo, const char *spec)
|
|
34
34
|
return maybe_sha_or_abbrev(out, repo, spec, speclen);
|
35
35
|
}
|
36
36
|
|
37
|
-
static int maybe_abbrev(git_object**
|
37
|
+
static int maybe_abbrev(git_object **out, git_repository *repo, const char *spec)
|
38
38
|
{
|
39
39
|
size_t speclen = strlen(spec);
|
40
40
|
|
@@ -310,7 +310,7 @@ cleanup:
|
|
310
310
|
return error;
|
311
311
|
}
|
312
312
|
|
313
|
-
static int handle_at_syntax(git_object **out, git_reference **ref, const char *spec, size_t identifier_len, git_repository*
|
313
|
+
static int handle_at_syntax(git_object **out, git_reference **ref, const char *spec, size_t identifier_len, git_repository *repo, const char *curly_braces_content)
|
314
314
|
{
|
315
315
|
bool is_numeric;
|
316
316
|
int parsed = 0, error = -1;
|
data/vendor/libgit2/src/stash.c
CHANGED
@@ -56,7 +56,7 @@ static int append_abbreviated_oid(git_buf *out, const git_oid *b_commit)
|
|
56
56
|
return git_buf_oom(out) ? -1 : 0;
|
57
57
|
}
|
58
58
|
|
59
|
-
static int append_commit_description(git_buf *out, git_commit*
|
59
|
+
static int append_commit_description(git_buf *out, git_commit *commit)
|
60
60
|
{
|
61
61
|
const char *summary = git_commit_summary(commit);
|
62
62
|
GIT_ERROR_CHECK_ALLOC(summary);
|
@@ -36,7 +36,7 @@ int OPENSSL_init_ssl__legacy(uint64_t opts, const void *settings)
|
|
36
36
|
return 0;
|
37
37
|
}
|
38
38
|
|
39
|
-
BIO_METHOD*
|
39
|
+
BIO_METHOD *BIO_meth_new__legacy(int type, const char *name)
|
40
40
|
{
|
41
41
|
BIO_METHOD *meth = git__calloc(1, sizeof(BIO_METHOD));
|
42
42
|
if (!meth) {
|
@@ -42,7 +42,7 @@
|
|
42
42
|
#if defined(GIT_OPENSSL_LEGACY) || defined(GIT_OPENSSL_DYNAMIC)
|
43
43
|
|
44
44
|
extern int OPENSSL_init_ssl__legacy(uint64_t opts, const void *settings);
|
45
|
-
extern BIO_METHOD*
|
45
|
+
extern BIO_METHOD *BIO_meth_new__legacy(int type, const char *name);
|
46
46
|
extern void BIO_meth_free__legacy(BIO_METHOD *biom);
|
47
47
|
extern int BIO_meth_set_write__legacy(BIO_METHOD *biom, int (*write) (BIO *, const char *, int));
|
48
48
|
extern int BIO_meth_set_read__legacy(BIO_METHOD *biom, int (*read) (BIO *, char *, int));
|
@@ -36,7 +36,8 @@ static void threadstate_dispose(git_threadstate *threadstate)
|
|
36
36
|
if (!threadstate)
|
37
37
|
return;
|
38
38
|
|
39
|
-
|
39
|
+
if (threadstate->error_t.message != git_buf__initbuf)
|
40
|
+
git__free(threadstate->error_t.message);
|
40
41
|
threadstate->error_t.message = NULL;
|
41
42
|
}
|
42
43
|
|
@@ -258,7 +258,7 @@ static size_t find_trailer_end(const char *buf, size_t len)
|
|
258
258
|
return len - ignore_non_trailer(buf, len);
|
259
259
|
}
|
260
260
|
|
261
|
-
static char *extract_trailer_block(const char *message, size_t*
|
261
|
+
static char *extract_trailer_block(const char *message, size_t *len)
|
262
262
|
{
|
263
263
|
size_t patch_start = find_patch_start(message);
|
264
264
|
size_t trailer_end = find_trailer_end(message, patch_start);
|
@@ -476,11 +476,11 @@ static int request_creds(git_credential **out, ssh_subtransport *t, const char *
|
|
476
476
|
}
|
477
477
|
|
478
478
|
static int _git_ssh_session_create(
|
479
|
-
LIBSSH2_SESSION**
|
479
|
+
LIBSSH2_SESSION **session,
|
480
480
|
git_stream *io)
|
481
481
|
{
|
482
482
|
int rc = 0;
|
483
|
-
LIBSSH2_SESSION*
|
483
|
+
LIBSSH2_SESSION *s;
|
484
484
|
git_socket_stream *socket = GIT_CONTAINER_OF(io, git_socket_stream, parent);
|
485
485
|
|
486
486
|
GIT_ASSERT_ARG(session);
|
@@ -521,8 +521,8 @@ static int _git_ssh_setup_conn(
|
|
521
521
|
size_t i;
|
522
522
|
ssh_stream *s;
|
523
523
|
git_credential *cred = NULL;
|
524
|
-
LIBSSH2_SESSION*
|
525
|
-
LIBSSH2_CHANNEL*
|
524
|
+
LIBSSH2_SESSION *session=NULL;
|
525
|
+
LIBSSH2_CHANNEL *channel=NULL;
|
526
526
|
|
527
527
|
t->current_stream = NULL;
|
528
528
|
|