rugged 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/rugged/rugged_commit.c +1 -1
- data/lib/rugged/commit.rb +16 -2
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +31 -69
- data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindGSSFramework.cmake → FindGSSFramework.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindPCRE.cmake → FindPCRE.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindPCRE2.cmake → FindPCRE2.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/PkgBuildConfig.cmake → PkgBuildConfig.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/SanitizeBool.cmake → SanitizeBool.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/SelectGSSAPI.cmake → SelectGSSAPI.cmake} +18 -26
- data/vendor/libgit2/cmake/{Modules/SelectHTTPSBackend.cmake → SelectHTTPSBackend.cmake} +25 -32
- data/vendor/libgit2/cmake/{Modules/SelectHashes.cmake → SelectHashes.cmake} +20 -28
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +6 -5
- data/vendor/libgit2/deps/ntlmclient/compat.h +8 -1
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +8 -11
- data/vendor/libgit2/deps/pcre/LICENCE +93 -0
- data/vendor/libgit2/deps/pcre/pcre.h +2 -2
- data/vendor/libgit2/deps/pcre/pcre_compile.c +29 -17
- data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +4 -4
- data/vendor/libgit2/deps/pcre/pcreposix.c +2 -3
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
- data/vendor/libgit2/deps/zlib/deflate.c +1 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
- data/vendor/libgit2/include/git2/blame.h +2 -0
- data/vendor/libgit2/include/git2/common.h +15 -3
- data/vendor/libgit2/include/git2/deprecated.h +42 -2
- data/vendor/libgit2/include/git2/errors.h +2 -1
- data/vendor/libgit2/include/git2/index.h +1 -2
- data/vendor/libgit2/include/git2/pack.h +1 -1
- data/vendor/libgit2/include/git2/strarray.h +6 -10
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/src/CMakeLists.txt +53 -41
- data/vendor/libgit2/src/apply.c +5 -1
- data/vendor/libgit2/src/assert_safe.h +58 -0
- data/vendor/libgit2/src/attr_file.c +8 -3
- data/vendor/libgit2/src/attrcache.c +2 -3
- data/vendor/libgit2/src/blame.c +2 -0
- data/vendor/libgit2/src/blame_git.c +6 -3
- data/vendor/libgit2/src/blob.c +2 -0
- data/vendor/libgit2/src/branch.c +19 -21
- data/vendor/libgit2/src/buffer.c +6 -3
- data/vendor/libgit2/src/cache.c +1 -22
- data/vendor/libgit2/src/checkout.c +49 -72
- data/vendor/libgit2/src/cherrypick.c +2 -0
- data/vendor/libgit2/src/clone.c +78 -18
- data/vendor/libgit2/src/common.h +1 -0
- data/vendor/libgit2/src/config.c +3 -7
- data/vendor/libgit2/src/config_entries.c +35 -27
- data/vendor/libgit2/src/config_parse.c +1 -1
- data/vendor/libgit2/src/config_snapshot.c +2 -1
- data/vendor/libgit2/src/describe.c +5 -1
- data/vendor/libgit2/src/diff.c +12 -11
- data/vendor/libgit2/src/diff_file.c +3 -1
- data/vendor/libgit2/src/diff_generate.c +10 -11
- data/vendor/libgit2/src/diff_parse.c +2 -3
- data/vendor/libgit2/src/diff_print.c +63 -60
- data/vendor/libgit2/src/diff_stats.c +12 -11
- data/vendor/libgit2/src/diff_tform.c +2 -3
- data/vendor/libgit2/src/errors.c +2 -0
- data/vendor/libgit2/src/fetch.c +2 -0
- data/vendor/libgit2/src/filter.c +3 -3
- data/vendor/libgit2/src/futils.c +3 -3
- data/vendor/libgit2/src/futils.h +3 -3
- data/vendor/libgit2/src/global.c +3 -1
- data/vendor/libgit2/src/idxmap.c +0 -22
- data/vendor/libgit2/src/index.c +12 -7
- data/vendor/libgit2/src/indexer.c +10 -4
- data/vendor/libgit2/src/iterator.c +4 -4
- data/vendor/libgit2/src/merge.c +13 -7
- data/vendor/libgit2/src/merge_file.c +4 -6
- data/vendor/libgit2/src/midx.c +418 -0
- data/vendor/libgit2/src/midx.h +83 -0
- data/vendor/libgit2/src/mwindow.c +124 -51
- data/vendor/libgit2/src/net.c +6 -1
- data/vendor/libgit2/src/object.c +2 -1
- data/vendor/libgit2/src/odb.c +9 -6
- data/vendor/libgit2/src/odb_loose.c +3 -3
- data/vendor/libgit2/src/odb_mempack.c +2 -0
- data/vendor/libgit2/src/oid.c +2 -0
- data/vendor/libgit2/src/pack-objects.c +29 -21
- data/vendor/libgit2/src/pack.c +47 -28
- data/vendor/libgit2/src/pack.h +19 -2
- data/vendor/libgit2/src/patch_generate.c +1 -3
- data/vendor/libgit2/src/patch_parse.c +4 -2
- data/vendor/libgit2/src/path.c +4 -4
- data/vendor/libgit2/src/pathspec.c +4 -3
- data/vendor/libgit2/src/pool.c +21 -15
- data/vendor/libgit2/src/pool.h +9 -1
- data/vendor/libgit2/src/proxy.c +2 -0
- data/vendor/libgit2/src/push.c +2 -0
- data/vendor/libgit2/src/rebase.c +2 -0
- data/vendor/libgit2/src/refdb.c +135 -0
- data/vendor/libgit2/src/refdb.h +69 -0
- data/vendor/libgit2/src/refdb_fs.c +19 -81
- data/vendor/libgit2/src/reflog.c +2 -6
- data/vendor/libgit2/src/refs.c +60 -188
- data/vendor/libgit2/src/refs.h +1 -19
- data/vendor/libgit2/src/regexp.c +2 -2
- data/vendor/libgit2/src/remote.c +32 -17
- data/vendor/libgit2/src/repository.c +168 -79
- data/vendor/libgit2/src/repository.h +10 -27
- data/vendor/libgit2/src/revert.c +2 -0
- data/vendor/libgit2/src/revparse.c +5 -4
- data/vendor/libgit2/src/revwalk.c +3 -5
- data/vendor/libgit2/src/settings.c +9 -0
- data/vendor/libgit2/src/sortedcache.c +2 -3
- data/vendor/libgit2/src/stash.c +2 -0
- data/vendor/libgit2/src/status.c +2 -0
- data/vendor/libgit2/src/strarray.c +63 -0
- data/vendor/libgit2/src/streams/openssl.c +12 -6
- data/vendor/libgit2/src/streams/registry.c +5 -3
- data/vendor/libgit2/src/submodule.c +6 -4
- data/vendor/libgit2/src/sysdir.c +4 -20
- data/vendor/libgit2/src/sysdir.h +0 -11
- data/vendor/libgit2/src/tag.c +2 -0
- data/vendor/libgit2/src/thread-utils.h +139 -21
- data/vendor/libgit2/src/transaction.c +2 -1
- data/vendor/libgit2/src/transports/credential.c +2 -0
- data/vendor/libgit2/src/transports/credential_helpers.c +2 -0
- data/vendor/libgit2/src/transports/httpclient.c +6 -8
- data/vendor/libgit2/src/transports/local.c +2 -2
- data/vendor/libgit2/src/transports/smart.c +2 -2
- data/vendor/libgit2/src/transports/winhttp.c +18 -7
- data/vendor/libgit2/src/unix/posix.h +13 -1
- data/vendor/libgit2/src/util.c +25 -58
- data/vendor/libgit2/src/util.h +2 -2
- data/vendor/libgit2/src/win32/git2.rc +18 -3
- data/vendor/libgit2/src/win32/path_w32.c +2 -2
- data/vendor/libgit2/src/worktree.c +4 -0
- metadata +27 -25
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
- data/vendor/libgit2/src/refdb_fs.h +0 -19
@@ -62,16 +62,18 @@ static const struct {
|
|
62
62
|
{ GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "worktrees", true }
|
63
63
|
};
|
64
64
|
|
65
|
-
static int check_repositoryformatversion(git_config *config);
|
65
|
+
static int check_repositoryformatversion(int *version, git_config *config);
|
66
|
+
static int check_extensions(git_config *config, int version);
|
66
67
|
|
67
68
|
#define GIT_COMMONDIR_FILE "commondir"
|
68
69
|
#define GIT_GITDIR_FILE "gitdir"
|
69
70
|
|
70
71
|
#define GIT_FILE_CONTENT_PREFIX "gitdir:"
|
71
72
|
|
72
|
-
#define
|
73
|
+
#define GIT_BRANCH_DEFAULT "master"
|
73
74
|
|
74
75
|
#define GIT_REPO_VERSION 0
|
76
|
+
#define GIT_REPO_MAX_VERSION 1
|
75
77
|
|
76
78
|
git_buf git_repository__reserved_names_win32[] = {
|
77
79
|
{ DOT_GIT, 0, CONST_STRLEN(DOT_GIT) },
|
@@ -813,6 +815,7 @@ int git_repository_open_ext(
|
|
813
815
|
gitlink = GIT_BUF_INIT, commondir = GIT_BUF_INIT;
|
814
816
|
git_repository *repo = NULL;
|
815
817
|
git_config *config = NULL;
|
818
|
+
int version = 0;
|
816
819
|
|
817
820
|
if (flags & GIT_REPOSITORY_OPEN_FROM_ENV)
|
818
821
|
return _git_repository_open_ext_from_env(repo_ptr, start_path);
|
@@ -854,7 +857,10 @@ int git_repository_open_ext(
|
|
854
857
|
if (error < 0 && error != GIT_ENOTFOUND)
|
855
858
|
goto cleanup;
|
856
859
|
|
857
|
-
if (config && (error = check_repositoryformatversion(config)) < 0)
|
860
|
+
if (config && (error = check_repositoryformatversion(&version, config)) < 0)
|
861
|
+
goto cleanup;
|
862
|
+
|
863
|
+
if ((error = check_extensions(config, version)) < 0)
|
858
864
|
goto cleanup;
|
859
865
|
|
860
866
|
if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0)
|
@@ -1350,11 +1356,11 @@ bool git_repository__reserved_names(
|
|
1350
1356
|
}
|
1351
1357
|
#endif
|
1352
1358
|
|
1353
|
-
static int check_repositoryformatversion(git_config *config)
|
1359
|
+
static int check_repositoryformatversion(int *version, git_config *config)
|
1354
1360
|
{
|
1355
|
-
int
|
1361
|
+
int error;
|
1356
1362
|
|
1357
|
-
error = git_config_get_int32(
|
1363
|
+
error = git_config_get_int32(version, config, "core.repositoryformatversion");
|
1358
1364
|
/* git ignores this if the config variable isn't there */
|
1359
1365
|
if (error == GIT_ENOTFOUND)
|
1360
1366
|
return 0;
|
@@ -1362,16 +1368,35 @@ static int check_repositoryformatversion(git_config *config)
|
|
1362
1368
|
if (error < 0)
|
1363
1369
|
return -1;
|
1364
1370
|
|
1365
|
-
if (
|
1371
|
+
if (GIT_REPO_MAX_VERSION < *version) {
|
1366
1372
|
git_error_set(GIT_ERROR_REPOSITORY,
|
1367
|
-
"unsupported repository version %d
|
1368
|
-
version,
|
1373
|
+
"unsupported repository version %d; only versions up to %d are supported",
|
1374
|
+
*version, GIT_REPO_MAX_VERSION);
|
1369
1375
|
return -1;
|
1370
1376
|
}
|
1371
1377
|
|
1372
1378
|
return 0;
|
1373
1379
|
}
|
1374
1380
|
|
1381
|
+
static int check_valid_extension(const git_config_entry *entry, void *payload)
|
1382
|
+
{
|
1383
|
+
GIT_UNUSED(payload);
|
1384
|
+
|
1385
|
+
if (!strcmp(entry->name, "extensions.noop"))
|
1386
|
+
return 0;
|
1387
|
+
|
1388
|
+
git_error_set(GIT_ERROR_REPOSITORY, "unsupported extension name %s", entry->name);
|
1389
|
+
return -1;
|
1390
|
+
}
|
1391
|
+
|
1392
|
+
static int check_extensions(git_config *config, int version)
|
1393
|
+
{
|
1394
|
+
if (version < 1)
|
1395
|
+
return 0;
|
1396
|
+
|
1397
|
+
return git_config_foreach_match(config, "^extensions\\.", check_valid_extension, NULL);
|
1398
|
+
}
|
1399
|
+
|
1375
1400
|
int git_repository_create_head(const char *git_dir, const char *ref_name)
|
1376
1401
|
{
|
1377
1402
|
git_buf ref_path = GIT_BUF_INIT;
|
@@ -1383,9 +1408,6 @@ int git_repository_create_head(const char *git_dir, const char *ref_name)
|
|
1383
1408
|
(error = git_filebuf_open(&ref, ref_path.ptr, 0, GIT_REFS_FILE_MODE)) < 0)
|
1384
1409
|
goto out;
|
1385
1410
|
|
1386
|
-
if (!ref_name)
|
1387
|
-
ref_name = GIT_BRANCH_MASTER;
|
1388
|
-
|
1389
1411
|
if (git__prefixcmp(ref_name, GIT_REFS_DIR) == 0)
|
1390
1412
|
fmt = "ref: %s\n";
|
1391
1413
|
else
|
@@ -1583,11 +1605,15 @@ static int repo_init_config(
|
|
1583
1605
|
git_config *config = NULL;
|
1584
1606
|
bool is_bare = ((flags & GIT_REPOSITORY_INIT_BARE) != 0);
|
1585
1607
|
bool is_reinit = ((flags & GIT_REPOSITORY_INIT__IS_REINIT) != 0);
|
1608
|
+
int version = 0;
|
1586
1609
|
|
1587
1610
|
if ((error = repo_local_config(&config, &cfg_path, NULL, repo_dir)) < 0)
|
1588
1611
|
goto cleanup;
|
1589
1612
|
|
1590
|
-
if (is_reinit && (error = check_repositoryformatversion(config)) < 0)
|
1613
|
+
if (is_reinit && (error = check_repositoryformatversion(&version, config)) < 0)
|
1614
|
+
goto cleanup;
|
1615
|
+
|
1616
|
+
if ((error = check_extensions(config, version)) < 0)
|
1591
1617
|
goto cleanup;
|
1592
1618
|
|
1593
1619
|
#define SET_REPO_CONFIG(TYPE, NAME, VAL) do { \
|
@@ -2032,6 +2058,43 @@ static int repo_init_directories(
|
|
2032
2058
|
return error;
|
2033
2059
|
}
|
2034
2060
|
|
2061
|
+
static int repo_init_head(const char *repo_dir, const char *given)
|
2062
|
+
{
|
2063
|
+
git_config *cfg = NULL;
|
2064
|
+
git_buf head_path = GIT_BUF_INIT, cfg_branch = GIT_BUF_INIT;
|
2065
|
+
const char *initial_head = NULL;
|
2066
|
+
int error;
|
2067
|
+
|
2068
|
+
if ((error = git_buf_joinpath(&head_path, repo_dir, GIT_HEAD_FILE)) < 0)
|
2069
|
+
goto out;
|
2070
|
+
|
2071
|
+
/*
|
2072
|
+
* A template may have set a HEAD; use that unless it's been
|
2073
|
+
* overridden by the caller's given initial head setting.
|
2074
|
+
*/
|
2075
|
+
if (git_path_exists(head_path.ptr) && !given)
|
2076
|
+
goto out;
|
2077
|
+
|
2078
|
+
if (given) {
|
2079
|
+
initial_head = given;
|
2080
|
+
} else if ((error = git_config_open_default(&cfg)) >= 0 &&
|
2081
|
+
(error = git_config_get_string_buf(&cfg_branch, cfg, "init.defaultbranch")) >= 0) {
|
2082
|
+
initial_head = cfg_branch.ptr;
|
2083
|
+
}
|
2084
|
+
|
2085
|
+
if (!initial_head)
|
2086
|
+
initial_head = GIT_BRANCH_DEFAULT;
|
2087
|
+
|
2088
|
+
error = git_repository_create_head(repo_dir, initial_head);
|
2089
|
+
|
2090
|
+
out:
|
2091
|
+
git_config_free(cfg);
|
2092
|
+
git_buf_dispose(&head_path);
|
2093
|
+
git_buf_dispose(&cfg_branch);
|
2094
|
+
|
2095
|
+
return error;
|
2096
|
+
}
|
2097
|
+
|
2035
2098
|
static int repo_init_create_origin(git_repository *repo, const char *url)
|
2036
2099
|
{
|
2037
2100
|
int error;
|
@@ -2062,7 +2125,7 @@ int git_repository_init_ext(
|
|
2062
2125
|
git_repository_init_options *opts)
|
2063
2126
|
{
|
2064
2127
|
git_buf repo_path = GIT_BUF_INIT, wd_path = GIT_BUF_INIT,
|
2065
|
-
common_path = GIT_BUF_INIT
|
2128
|
+
common_path = GIT_BUF_INIT;
|
2066
2129
|
const char *wd;
|
2067
2130
|
bool is_valid;
|
2068
2131
|
int error;
|
@@ -2096,16 +2159,7 @@ int git_repository_init_ext(
|
|
2096
2159
|
} else {
|
2097
2160
|
if ((error = repo_init_structure(repo_path.ptr, wd, opts)) < 0 ||
|
2098
2161
|
(error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode)) < 0 ||
|
2099
|
-
(error =
|
2100
|
-
goto out;
|
2101
|
-
|
2102
|
-
/*
|
2103
|
-
* Only set the new HEAD if the file does not exist already via
|
2104
|
-
* a template or if the caller has explicitly supplied an
|
2105
|
-
* initial HEAD value.
|
2106
|
-
*/
|
2107
|
-
if ((!git_path_exists(head_path.ptr) || opts->initial_head) &&
|
2108
|
-
(error = git_repository_create_head(repo_path.ptr, opts->initial_head)) < 0)
|
2162
|
+
(error = repo_init_head(repo_path.ptr, opts->initial_head)) < 0)
|
2109
2163
|
goto out;
|
2110
2164
|
}
|
2111
2165
|
|
@@ -2117,7 +2171,6 @@ int git_repository_init_ext(
|
|
2117
2171
|
goto out;
|
2118
2172
|
|
2119
2173
|
out:
|
2120
|
-
git_buf_dispose(&head_path);
|
2121
2174
|
git_buf_dispose(&common_path);
|
2122
2175
|
git_buf_dispose(&repo_path);
|
2123
2176
|
git_buf_dispose(&wd_path);
|
@@ -2148,12 +2201,6 @@ int git_repository_head_detached(git_repository *repo)
|
|
2148
2201
|
return exists;
|
2149
2202
|
}
|
2150
2203
|
|
2151
|
-
static int get_worktree_file_path(git_buf *out, git_repository *repo, const char *worktree, const char *file)
|
2152
|
-
{
|
2153
|
-
git_buf_clear(out);
|
2154
|
-
return git_buf_printf(out, "%s/worktrees/%s/%s", repo->commondir, worktree, file);
|
2155
|
-
}
|
2156
|
-
|
2157
2204
|
int git_repository_head_detached_for_worktree(git_repository *repo, const char *name)
|
2158
2205
|
{
|
2159
2206
|
git_reference *ref = NULL;
|
@@ -2194,7 +2241,8 @@ int git_repository_head(git_reference **head_out, git_repository *repo)
|
|
2194
2241
|
|
2195
2242
|
int git_repository_head_for_worktree(git_reference **out, git_repository *repo, const char *name)
|
2196
2243
|
{
|
2197
|
-
|
2244
|
+
git_repository *worktree_repo = NULL;
|
2245
|
+
git_worktree *worktree = NULL;
|
2198
2246
|
git_reference *head = NULL;
|
2199
2247
|
int error;
|
2200
2248
|
|
@@ -2202,65 +2250,68 @@ int git_repository_head_for_worktree(git_reference **out, git_repository *repo,
|
|
2202
2250
|
|
2203
2251
|
*out = NULL;
|
2204
2252
|
|
2205
|
-
if ((error =
|
2206
|
-
(error =
|
2253
|
+
if ((error = git_worktree_lookup(&worktree, repo, name)) < 0 ||
|
2254
|
+
(error = git_repository_open_from_worktree(&worktree_repo, worktree)) < 0 ||
|
2255
|
+
(error = git_reference_lookup(&head, worktree_repo, GIT_HEAD_FILE)) < 0)
|
2207
2256
|
goto out;
|
2208
2257
|
|
2209
2258
|
if (git_reference_type(head) != GIT_REFERENCE_DIRECT) {
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
head =
|
2259
|
+
if ((error = git_reference_lookup_resolved(out, worktree_repo, git_reference_symbolic_target(head), -1)) < 0)
|
2260
|
+
goto out;
|
2261
|
+
} else {
|
2262
|
+
*out = head;
|
2263
|
+
head = NULL;
|
2215
2264
|
}
|
2216
2265
|
|
2217
|
-
*out = head;
|
2218
|
-
|
2219
2266
|
out:
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
git_buf_dispose(&path);
|
2224
|
-
|
2267
|
+
git_reference_free(head);
|
2268
|
+
git_worktree_free(worktree);
|
2269
|
+
git_repository_free(worktree_repo);
|
2225
2270
|
return error;
|
2226
2271
|
}
|
2227
2272
|
|
2228
|
-
int
|
2229
|
-
|
2230
|
-
|
2273
|
+
int git_repository_foreach_worktree(git_repository *repo,
|
2274
|
+
git_repository_foreach_worktree_cb cb,
|
2275
|
+
void *payload)
|
2231
2276
|
{
|
2232
|
-
git_strarray worktrees =
|
2233
|
-
|
2234
|
-
|
2277
|
+
git_strarray worktrees = {0};
|
2278
|
+
git_repository *worktree_repo = NULL;
|
2279
|
+
git_worktree *worktree = NULL;
|
2280
|
+
int error;
|
2235
2281
|
size_t i;
|
2236
2282
|
|
2283
|
+
if ((error = git_repository_open(&worktree_repo, repo->commondir)) < 0 ||
|
2284
|
+
(error = cb(worktree_repo, payload) != 0))
|
2285
|
+
goto out;
|
2237
2286
|
|
2238
|
-
|
2239
|
-
|
2240
|
-
if ((error = git_buf_joinpath(&path, repo->commondir, GIT_HEAD_FILE)) < 0 ||
|
2241
|
-
(error = cb(repo, path.ptr, payload) != 0))
|
2242
|
-
goto out;
|
2243
|
-
}
|
2287
|
+
git_repository_free(worktree_repo);
|
2288
|
+
worktree_repo = NULL;
|
2244
2289
|
|
2245
|
-
if (
|
2246
|
-
|
2247
|
-
error = 0;
|
2248
|
-
goto out;
|
2249
|
-
}
|
2290
|
+
if ((error = git_worktree_list(&worktrees, repo)) < 0)
|
2291
|
+
goto out;
|
2250
2292
|
|
2251
|
-
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2293
|
+
for (i = 0; i < worktrees.count; i++) {
|
2294
|
+
git_repository_free(worktree_repo);
|
2295
|
+
worktree_repo = NULL;
|
2296
|
+
git_worktree_free(worktree);
|
2297
|
+
worktree = NULL;
|
2255
2298
|
|
2256
|
-
|
2299
|
+
if ((error = git_worktree_lookup(&worktree, repo, worktrees.strings[i]) < 0) ||
|
2300
|
+
(error = git_repository_open_from_worktree(&worktree_repo, worktree)) < 0) {
|
2301
|
+
if (error != GIT_ENOTFOUND)
|
2257
2302
|
goto out;
|
2303
|
+
error = 0;
|
2304
|
+
continue;
|
2258
2305
|
}
|
2306
|
+
|
2307
|
+
if ((error = cb(worktree_repo, payload)) != 0)
|
2308
|
+
goto out;
|
2259
2309
|
}
|
2260
2310
|
|
2261
2311
|
out:
|
2262
|
-
|
2263
|
-
|
2312
|
+
git_strarray_dispose(&worktrees);
|
2313
|
+
git_repository_free(worktree_repo);
|
2314
|
+
git_worktree_free(worktree);
|
2264
2315
|
return error;
|
2265
2316
|
}
|
2266
2317
|
|
@@ -2303,23 +2354,59 @@ static int repo_contains_no_reference(git_repository *repo)
|
|
2303
2354
|
return error;
|
2304
2355
|
}
|
2305
2356
|
|
2357
|
+
int git_repository_initialbranch(git_buf *out, git_repository *repo)
|
2358
|
+
{
|
2359
|
+
git_config *config;
|
2360
|
+
git_config_entry *entry = NULL;
|
2361
|
+
const char *branch;
|
2362
|
+
int error;
|
2363
|
+
|
2364
|
+
if ((error = git_repository_config__weakptr(&config, repo)) < 0)
|
2365
|
+
return error;
|
2366
|
+
|
2367
|
+
if ((error = git_config_get_entry(&entry, config, "init.defaultbranch")) == 0) {
|
2368
|
+
branch = entry->value;
|
2369
|
+
}
|
2370
|
+
else if (error == GIT_ENOTFOUND) {
|
2371
|
+
branch = GIT_BRANCH_DEFAULT;
|
2372
|
+
}
|
2373
|
+
else {
|
2374
|
+
goto done;
|
2375
|
+
}
|
2376
|
+
|
2377
|
+
if ((error = git_buf_puts(out, GIT_REFS_HEADS_DIR)) < 0 ||
|
2378
|
+
(error = git_buf_puts(out, branch)) < 0)
|
2379
|
+
goto done;
|
2380
|
+
|
2381
|
+
if (!git_reference_is_valid_name(out->ptr)) {
|
2382
|
+
git_error_set(GIT_ERROR_INVALID, "the value of init.defaultBranch is not a valid reference name");
|
2383
|
+
error = -1;
|
2384
|
+
}
|
2385
|
+
|
2386
|
+
done:
|
2387
|
+
git_config_entry_free(entry);
|
2388
|
+
return error;
|
2389
|
+
}
|
2390
|
+
|
2306
2391
|
int git_repository_is_empty(git_repository *repo)
|
2307
2392
|
{
|
2308
2393
|
git_reference *head = NULL;
|
2309
|
-
|
2394
|
+
git_buf initialbranch = GIT_BUF_INIT;
|
2395
|
+
int result = 0;
|
2310
2396
|
|
2311
|
-
if (git_reference_lookup(&head, repo, GIT_HEAD_FILE) < 0
|
2312
|
-
|
2397
|
+
if ((result = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0 ||
|
2398
|
+
(result = git_repository_initialbranch(&initialbranch, repo)) < 0)
|
2399
|
+
goto done;
|
2313
2400
|
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
GIT_REFS_HEADS_DIR "master") == 0) &&
|
2318
|
-
repo_contains_no_reference(repo);
|
2401
|
+
result = (git_reference_type(head) == GIT_REFERENCE_SYMBOLIC &&
|
2402
|
+
strcmp(git_reference_symbolic_target(head), initialbranch.ptr) == 0 &&
|
2403
|
+
repo_contains_no_reference(repo));
|
2319
2404
|
|
2405
|
+
done:
|
2320
2406
|
git_reference_free(head);
|
2407
|
+
git_buf_dispose(&initialbranch);
|
2321
2408
|
|
2322
|
-
return
|
2409
|
+
return result;
|
2323
2410
|
}
|
2324
2411
|
|
2325
2412
|
static const char *resolved_parent_path(const git_repository *repo, git_repository_item_t item, git_repository_item_t fallback)
|
@@ -2899,11 +2986,13 @@ int git_repository_init_options_init(
|
|
2899
2986
|
return 0;
|
2900
2987
|
}
|
2901
2988
|
|
2989
|
+
#ifndef GIT_DEPRECATE_HARD
|
2902
2990
|
int git_repository_init_init_options(
|
2903
2991
|
git_repository_init_options *opts, unsigned int version)
|
2904
2992
|
{
|
2905
2993
|
return git_repository_init_options_init(opts, version);
|
2906
2994
|
}
|
2995
|
+
#endif
|
2907
2996
|
|
2908
2997
|
int git_repository_ident(const char **name, const char **email, const git_repository *repo)
|
2909
2998
|
{
|
@@ -166,34 +166,11 @@ GIT_INLINE(git_attr_cache *) git_repository_attr_cache(git_repository *repo)
|
|
166
166
|
int git_repository_head_tree(git_tree **tree, git_repository *repo);
|
167
167
|
int git_repository_create_head(const char *git_dir, const char *ref_name);
|
168
168
|
|
169
|
-
|
170
|
-
* Called for each HEAD.
|
171
|
-
*
|
172
|
-
* Can return either 0, causing the iteration over HEADs to
|
173
|
-
* continue, or a non-0 value causing the iteration to abort. The
|
174
|
-
* return value is passed back to the caller of
|
175
|
-
* `git_repository_foreach_head`
|
176
|
-
*/
|
177
|
-
typedef int (*git_repository_foreach_head_cb)(git_repository *repo, const char *path, void *payload);
|
178
|
-
|
179
|
-
enum {
|
180
|
-
/* Skip enumeration of the main repository HEAD */
|
181
|
-
GIT_REPOSITORY_FOREACH_HEAD_SKIP_REPO = (1u << 0),
|
182
|
-
/* Skip enumeration of worktree HEADs */
|
183
|
-
GIT_REPOSITORY_FOREACH_HEAD_SKIP_WORKTREES = (1u << 1),
|
184
|
-
};
|
169
|
+
typedef int (*git_repository_foreach_worktree_cb)(git_repository *, void *);
|
185
170
|
|
186
|
-
|
187
|
-
|
188
|
-
*
|
189
|
-
* This function will be called for the repository HEAD and for
|
190
|
-
* all HEADS of linked worktrees. For each HEAD, the callback is
|
191
|
-
* executed with the given payload. The return value equals the
|
192
|
-
* return value of the last executed callback function.
|
193
|
-
*/
|
194
|
-
int git_repository_foreach_head(git_repository *repo,
|
195
|
-
git_repository_foreach_head_cb cb,
|
196
|
-
int flags, void *payload);
|
171
|
+
int git_repository_foreach_worktree(git_repository *repo,
|
172
|
+
git_repository_foreach_worktree_cb cb,
|
173
|
+
void *payload);
|
197
174
|
|
198
175
|
/*
|
199
176
|
* Weak pointers to repository internals.
|
@@ -255,4 +232,10 @@ extern size_t git_repository__reserved_names_posix_len;
|
|
255
232
|
bool git_repository__reserved_names(
|
256
233
|
git_buf **out, size_t *outlen, git_repository *repo, bool include_ntfs);
|
257
234
|
|
235
|
+
/*
|
236
|
+
* The default branch for the repository; the `init.defaultBranch`
|
237
|
+
* configuration option, if set, or `master` if it is not.
|
238
|
+
*/
|
239
|
+
int git_repository_initialbranch(git_buf *out, git_repository *repo);
|
240
|
+
|
258
241
|
#endif
|