268 Commits
v1.0 ... master

Author SHA1 Message Date
Hugo Locurcio
b26312f1c1 Bump to version 3.2.1 2025-09-17 16:51:12 +02:00
Rémi Verschelde
d427b556e2 Merge pull request #305 from akien-mga/libssh2-cmake-4.0
CI: Fix build on macOS 15 runner with CMake 4.0 and Xcode 16.4
2025-09-17 12:57:31 +02:00
Rémi Verschelde
77fdf78793 CI: Fix build on macOS 15 runner with CMake 4.0 and Xcode 16.4
- Enforce min CMake version targeted for libssh2
- Downgrade Xcode to 16.2 as that's the last version before upgrading to LLVM 19
  which seems to break building libgit2's bundled zlib
2025-09-17 12:42:53 +02:00
Rémi Verschelde
1a851f221b Merge pull request #292 from Calinou/add-issue-templates
Add issue templates
2025-09-17 11:08:48 +02:00
Nikita
182f2f7146 Update OpenSSL to 3.1.2 (#298) 2025-07-25 17:30:51 +02:00
Hugo Locurcio
27c1152cb0 Add issue templates
These issue templates are inspired by the ones from godot-vscode-plugin.
2025-06-03 19:01:26 +02:00
Rémi Verschelde
b51e8ee42a Merge pull request #290 from Faless/fix/disable_zlib_detection
ssh2: Disable zlib detection
2025-05-31 00:58:30 +02:00
Fabio Alessandrelli
94db3a7c36 ssh2: Disable zlib detection
This seems to only be used with the OpenSSL backend (which we plan to
drop).

libgit2 already use builtin ZLIB, I'm not even sure we if it would be
used in libssh2 (we only use libssh2 to provide git ssh access, and git
already compress objects.
2025-05-31 00:43:58 +02:00
Rémi Verschelde
179e3ddb00 Merge pull request #289 from akien-mga/misc-fixes
Misc fixes and cleanup
2025-05-28 23:03:10 +02:00
Rémi Verschelde
2a4c781e86 Misc fixes and cleanup
- Remove the `demo` project which isn't really useful.
  * Instead the `addons` subfolder is made top-level and that's where stuff gets written.
- Update the README following recent PRs (#191, #199) as OpenSSL is now compiled from source for all platforms.
  * Also remove obsolete `build_openssl_universal_macos.sh` script.
- Remove the bogus `plugin.cfg` which isn't necessary, and was confusing users who tried to enable it.
  * Fixes #267.
- Bump min SCons version to 3.1.2 and Python to 3.6.
- Bump `compatibility_minimum` to `4.2.0` following #196.
- Remove some code in `godot-git-plugin/SCsub` that seems redundant with `godot-cpp` config.
- Remove unnecessary `.exp` and `.lib` files in Windows artifact, rename its folder to `windows`.
- Remove `export-ignore`s in `.gitattributes`, they're incomplete and not actually doing anything usable.
- Fix artifacts URL handling in `release.sh`, make it executable.
- CI: Update clang-format check to version 18.
2025-05-28 22:52:21 +02:00
Rémi Verschelde
fd85a8ef39 Merge pull request #288 from akien-mga/ci-cleanup
CI: Don't install openssl for macOS + misc cleanup
2025-05-27 17:29:49 +02:00
Rémi Verschelde
f322436f66 CI: Don't install openssl for macOS + misc cleanup 2025-05-27 17:18:41 +02:00
Rémi Verschelde
78d6464745 Merge pull request #286 from Faless/build/force_msvc_lto
Force LTO on windows MSVC as libgit2 requires it
2025-05-27 15:38:05 +02:00
Rémi Verschelde
91bb644dd4 Merge pull request #287 from Faless/build/fix_macos_deployment_target
Force macOS deployment target for OpenSSL when specified
2025-05-27 14:17:09 +02:00
Rémi Verschelde
1e346f89fa Merge pull request #285 from Faless/build/fix_libgit_tool
Properly specify the `STATIC_CRT` libgit2 flag
2025-05-27 14:01:19 +02:00
Fabio Alessandrelli
9a43d562c0 Force macOS deployment target for OpenSSL when specified 2025-05-27 12:24:54 +02:00
Fabio Alessandrelli
f6f2db53a9 Force LTO on windows MSVC
This silences the linker complaining that libgit uses LTO but we are not
linking with it.
2025-05-27 12:20:59 +02:00
Fabio Alessandrelli
c7c7822191 Properly specify the STATIC_CRT libgit2 flag
libgit2 CMake configuration uses a custom flag `STATIC_CRT` and not the
new CMake policy CMP0091.

When forcing the CMake policy (as we do in our cmake tool), we need to
also set the custom `STATIC_CRT` to avoid compiler warning about the /MD
and /MT flag being overridden.
2025-05-27 11:53:22 +02:00
Rémi Verschelde
392b3d6697 Merge pull request #283 from akien-mga/ci-windows-fail-on-error
CI: Ensure Windows job fails on error
2025-05-27 10:38:58 +02:00
Rémi Verschelde
51dcc3c455 CI: Ensure Windows job fails on error
Default `pwsh` is apparently not properly configured to fail fast,
but `powershell` is, whatever is the difference.

Minor tweaks to CI setup.
2025-05-27 10:27:17 +02:00
Rémi Verschelde
4fdf03d471 Merge pull request #284 from Faless/fix/win_build
Fix Windows MSVC build
2025-05-27 09:36:25 +02:00
Fabio Alessandrelli
1442ac5f0b Fix Windows MSVC build
Update the CMake tool so it respects the use_static_cpp godot-cpp option
compiling with the proper CRT.

Fix inclusion of secur32 in git2 tool.
2025-05-27 01:24:04 +02:00
Rémi Verschelde
3ab9d035e7 Merge pull request #199 from Faless/build/openssl_and_cmake
Use OpenSSL on windows too, build libgit2, ssh2 with cmake.
2025-05-26 18:02:46 +02:00
Fabio Alessandrelli
0d0c30784d Use OpenSSL on windows too, build libgit2, ssh2 with cmake.
And update the libraries.
2025-05-26 17:17:29 +02:00
Rémi Verschelde
ef24a3673d Merge pull request #191 from Faless/build/openssl
[SCons] Build OpenSSL from source.
2025-05-26 17:02:24 +02:00
Fabio Alessandrelli
955ec02503 [SCons] Build OpenSSL from source by default
Remove prebuilt static libraries for macOS.

Can optionally still use external (static) libraries by supplying the
`openssl_external_*` parameters to scons.
2025-05-26 16:57:27 +02:00
Rémi Verschelde
b8d79c3fc9 Merge pull request #246 from dsnopek/godot-cpp-41-branch
Update godot-cpp to `godot-4.2-stable`
2025-05-26 16:14:24 +02:00
David Snopek
900e95db82 Update godot-cpp to the latest on the 4.2 branch 2025-05-26 09:02:51 -05:00
Rémi Verschelde
9544fb84ec Merge pull request #272 from dsnopek/update-ci-versions
Update various out-dated versions in CI
2025-05-25 15:41:03 +02:00
David Snopek
edcfc47af0 Update various out-dated versions in CI
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2025-05-25 15:29:15 +02:00
Joel Croteau
e86106b8c2 Stop progress_cb from generating spurious warnings (#243)
`progress_cb` is used to give progress updates on pushes and pulls. There is
no reason for it to pollute the logs by logging its updates as warnings.
Changed these to plain print statements.
2024-07-07 05:15:37 +02:00
Hugo Locurcio
f6002fab42 Bump to version 3.1.1 (#231) 2024-04-08 18:29:04 +02:00
markeel
d6582fa939 Use UTF-8 conversion when dealing with Git repository data (#229)
This fixes issues with non-ASCII characters not displaying correctly
throughout the editor.
2024-04-08 17:46:50 +02:00
Hugo Locurcio
259ae989f4 Merge pull request #195 from Faless/ci/cache
[CI] Add scons cache.
2024-02-02 17:11:02 +01:00
Twarit Waikar
2f160a2b79 Merge pull request #189 from fries1234/fix-comparison-bug
fix a comparision bug with renamed git statuses
2023-10-03 20:09:42 +05:30
Hugo Locurcio
55b09bf0f7 Merge pull request #198 from jokoho48/gd4_1 2023-09-22 21:47:26 +02:00
Jonas Hoffmann
ae2f2d3826 Add Godot 4.1 Support
- Update godot-cpp
- Fix Entry Point that changed within Godot 4.1
- Add compatibility_minimum to gdextension required for 4.1 support
- Bump version in plugin.cfg
- Upgrade demo project to 4.1
2023-07-12 22:12:15 +02:00
Fabio Alessandrelli
3ab28b1d33 [CI] Add scons cache. 2023-06-24 18:39:14 +02:00
Twarit Waikar
3fc541feb8 Merge pull request #173 from markeel/master
Address issue #172, to use public key path if present in preference to using password.
2023-05-25 12:58:09 +05:30
markeel
04602dc5dc Merge pull request #1 from markeel/workflow-error
Update build.yml
2023-05-24 14:14:41 -07:00
markeel
bb5da70aa4 Update build.yml
Fix ubuntu version to match godot-cpp
2023-05-24 13:30:47 -07:00
Fries
4cb6ec0edd fix a comparision bug with renamed git statuses
there is a bug where if you have a entry->status with GIT_STATUS_INDEX_RENAMED but with another flag like GIT_STATUS_INDEX_MODIFIED, godot-git-plugin will crash as it cant find the proper map for 2 flags. so i changed it to do a logical and so it can execute the proper renamed logic.
2023-05-18 23:28:08 -07:00
mendrak
34850841fc Updated to remove extra line and pass clang format check 2023-03-26 20:44:58 -07:00
mendrak
74342b298e Address issue #172, to use public key path if present in preference
to using password.
2023-03-25 09:36:43 -07:00
Rémi Verschelde
3c50df7af0 Merge pull request #165 from godotengine/update-4.0-stable
Update extension API to Godot 4.0-stable
2023-03-01 15:58:22 +01:00
Rémi Verschelde
65a643c8d8 Update extension API to Godot 4.0-stable 2023-03-01 15:36:13 +01:00
Twarit Waikar
6a4b23a2c0 Merge pull request #149 from ianling/ian/update-libssh2 2023-02-26 17:01:17 +05:30
Rémi Verschelde
63d72ffc21 Merge pull request #161 from godotengine/update-4.0-rc4
Update extension API to Godot 4.0-rc4
2023-02-23 23:04:30 +01:00
Rémi Verschelde
6a6f7d1810 Update extension API to Godot 4.0-rc4
Remove `ci/` directory, everything is included in godot-cpp.
2023-02-23 18:57:58 +01:00
Ian Ling
f22b2e6bf5 Update libssh2 to HEAD of master 2023-01-04 17:04:45 -08:00
Twarit Waikar
820c623912 Happy new year! 2023-01-02 13:56:26 +05:30
Twarit Waikar
1aea2dd13f Merge pull request #142 from twaritwaikar/release-3.0b1 2022-12-24 01:25:12 +05:30
Twarit Waikar
982cee2d85 Update OpenSSL 1.1.1 minor version 2022-12-24 01:23:42 +05:30
Twarit Waikar
5f100fb6e4 Fix macos plugin binary path in git_plugin.gdextension 2022-12-24 00:51:45 +05:30
Twarit Waikar
b7d0cfda02 Update THIRDPARTY.md and plugin.cfg to use newer values 2022-12-23 23:50:38 +05:30
Twarit Waikar
9ccf7e98a3 Update ci/ extension APIs from Gdoot 4.0-beta10 2022-12-23 23:34:44 +05:30
Twarit Waikar
fb772f3623 Merge pull request #139 from twaritwaikar/change-repo-found-logs
Change print logs when repo is found
2022-12-23 10:20:10 +05:30
Twarit Waikar
8fcf6e434d Change print logs when repo is found 2022-12-23 02:06:49 +05:30
Twarit Waikar
67b0cdf976 Merge pull request #136 from twaritwaikar/set-macos-minimum-version 2022-12-21 17:52:06 +05:30
Twarit Waikar
ccac80bb0e Add min macOS version flags for master
Frontports https://github.com/godotengine/godot-git-plugin/pull/121/files
2022-12-21 16:37:35 +05:30
Twarit Waikar
dc88f7a585 Merge pull request #135 from twaritwaikar/link-ssl-static
Fixes https://github.com/godotengine/godot-git-plugin/issues/127
2022-12-21 02:48:07 +05:30
Twarit Waikar
0e8de32587 Force static linkage for libssl.a and libcrypt.a 2022-12-21 02:22:50 +05:30
Twarit Waikar
35443ecfaa Merge pull request #133 from twaritwaikar/fix-api-difference-compile-errors 2022-12-21 00:47:54 +05:30
Twarit Waikar
a1b0c41c72 Merge pull request #1 from twaritwaikar/add-repo-discovery
Fixes https://github.com/godotengine/godot-git-plugin/issues/76
2022-12-20 21:46:15 +05:30
Twarit Waikar
893bcd922b Fix CI build artifact names to reflect underlying archs 2022-12-20 21:41:59 +05:30
Twarit Waikar
1cdc05e9e0 Add repo discovery so higher repos can be opened automatically 2022-12-20 21:03:20 +05:30
Twarit Waikar
91344c5e68 Fix API mismatch compile errors + Use Godot 4 utilities
Also clarifies the new build instructions
2022-12-20 20:22:14 +05:30
Twarit Waikar
20cb08003e Merge pull request #132 from Faless/spike/beta7 2022-12-20 17:43:13 +05:30
Fabio Alessandrelli
df5b0139d9 Update to Godot 4.0 beta9.
Simplify build system.
2022-12-19 22:56:56 +01:00
Twarit Waikar
084c7fcfe2 Merge pull request #114 from ChronicallySerious/gdextension-port 2022-08-31 23:58:26 +05:30
Twarit Waikar
9acff81056 Update godot-cpp commit link in THIRDPARTY.md 2022-08-31 23:05:00 +05:30
Twarit Waikar
a2ecf96e04 Update extension_api.ci.json after TypedArray changes upstream 2022-08-26 21:12:55 +05:30
Twarit Waikar
34a785dc72 Fix leftover osx -> macos renames 2022-08-13 21:49:53 +05:30
Twarit Waikar
6e94df54df Update extension_api.ci.json 2022-08-10 03:59:05 +05:30
Twarit Waikar
424cc61657 Rename osx to macos 2022-08-10 03:43:40 +05:30
Twarit Waikar
51b068f043 Update godot-cpp to 8ba1c059da5e97428d40612dd0afc2be4079b5c6 2022-08-10 03:39:50 +05:30
Twarit Waikar
b603dcadaa Intermediate 2022-08-10 03:38:51 +05:30
Twarit Waikar
acece95267 Update godot-cpp to upstream 2022-08-10 03:38:51 +05:30
Twarit Waikar
2296d3e393 Set plugin version to 3 2022-08-10 03:38:50 +05:30
Twarit Waikar
ff40154485 Use std::memcpy instead of memcpy 2022-08-10 03:38:50 +05:30
Twarit Waikar
93c175cd1d Fix bin analysis commands in CI 2022-08-10 03:38:50 +05:30
Twarit Waikar
f029aa555c Fix Linux build error - memcpy not found 2022-08-10 03:38:50 +05:30
Twarit Waikar
0029af37eb Fix custom api file name in build.yaml 2022-08-10 03:38:50 +05:30
Twarit Waikar
521341e7bf Port demo files to Godot 4.0 2022-08-10 03:38:48 +05:30
Twarit Waikar
d0c59416d1 Port from GDNative to GDExtension for Godot 4.x 2022-08-10 03:38:07 +05:30
Twarit Waikar
4b5bf09fd0 Add logo to README.md 2022-08-08 03:01:44 +05:30
Twarit Waikar
8b930f1218 Add logo files 2022-08-08 02:59:54 +05:30
Twarit Waikar
6c53f46d8f Merge pull request #107 from ChronicallySerious/remove-get-commit-date 2022-04-09 20:36:23 +05:30
ChronicallySerious
616c26c2c9 Remove get_commit_date() and replace with Godot's new Time singleton 2022-02-24 04:08:54 +05:30
Twarit Waikar
2e3afd8379 Fix minor typo in README.md#bleeding-edge 2022-01-16 01:35:50 +05:30
ChronicallySerious
18e18fe3f8 Add release.sh script for creating new releases 2022-01-16 01:01:55 +05:30
Twarit Waikar
27a10c7029 Remove extraneous files in macOS build artifact 2022-01-16 00:04:38 +05:30
Twarit Waikar
7a08c914fe Merge pull request #101 from ChronicallySerious/fix-unstage-when-no-initial-commit 2022-01-15 18:12:16 +05:30
ChronicallySerious
acc0901a66 Fix error when unstaging file with no HEAD commit #100
This also fixes an issue with diffing staged files when there is
no previous HEAD commit
2022-01-15 17:57:44 +05:30
Twarit Waikar
97db5d73e6 Update plugin.cfg to v2.0 2022-01-10 21:13:21 +05:30
Twarit Waikar
ad9a38716b Update license text to mention 2022
Happy new year!
2022-01-10 21:01:00 +05:30
Twarit Waikar
ceb66815c9 Merge pull request #84 from ChronicallySerious/update-vcs-new 2022-01-10 20:30:39 +05:30
ChronicallySerious
a63ee9d415 Do not leave space for first branch in list when list is empty 2021-12-01 20:23:45 +05:30
ChronicallySerious
43b189a8ee Merge branch 'master' into update-vcs-new 2021-12-01 02:48:43 +05:30
ChronicallySerious
c48f2efadc Fix undefined libcrypto symbols on Linux builds 2021-12-01 02:02:01 +05:30
Twarit Waikar
3abcf57b6a Fix typo in README.md
`featured` -> `features`
2021-11-29 12:31:05 +05:30
Twarit Waikar
2d938a85a3 Merge pull request #93 from VinegarLove/patch-1 2021-11-29 12:13:26 +05:30
Twarit Waikar
2c7f341285 Trigger clang-format workflow on PRs too 2021-11-29 12:12:04 +05:30
VinegarLove
9cefa91f58 linux build script updated for other shells
fixed the way the CORES variable assignment  to be compliant with other shells other than bash
2021-11-28 23:38:54 +01:00
Twarit Waikar
af8149ffa9 Add branch and remote deletion backend hooks 2021-10-16 05:30:45 +05:30
Twarit Waikar
2463cc8c7e Add 3rd party license attributions 2021-10-14 22:34:43 +05:30
Twarit Waikar
4620542c13 Refactor libgit2 error macro to make it less convoluted 2021-10-14 21:51:57 +05:30
Twarit Waikar
78caec5a51 Respect username extracted from URL in credential callback 2021-10-14 04:22:37 +05:30
Twarit Waikar
0b09051fc3 Add universal OpenSSL library builds 2021-10-14 01:46:31 +05:30
Twarit Waikar
3e955b9022 Build universal OpenSSL fat library 2021-10-13 20:01:42 +05:30
Twarit Waikar
abeb17532b Pick the correct .a libs for macOS OpenSSL 2021-10-13 03:18:13 +05:30
Twarit Waikar
2095757996 Force static libssl.a and libcrypto.a linkage on macOS 2021-10-13 02:51:17 +05:30
Twarit Waikar
b914319c20 Clang-format fixes 2021-10-13 01:38:11 +05:30
Twarit Waikar
a6772e0d3f Change macOS builds to use OpenSSL purely as a static lib 2021-10-13 01:25:11 +05:30
Twarit Waikar
4119ad2c74 Add universal builds back to CI + link to OpenSSL dylib, not .a 2021-10-13 00:18:26 +05:30
Twarit Waikar
76dfd5a143 Fix minor typo making macos CI step fail 2021-10-12 22:39:08 +05:30
Twarit Waikar
8d21ddc183 Add links flags for linking to ssl on macOS + python cleanup 2021-10-12 22:20:33 +05:30
Twarit Waikar
14100de179 Only build x64 mac builds instead of universal 2021-10-12 21:59:52 +05:30
Twarit Waikar
140dd2675a Add arm64 specific flags to libssh2 build 2021-10-12 21:02:45 +05:30
Twarit Waikar
0d7f68c6c6 Add openssl paths explicitly to libssh2 mac build 2021-10-12 20:07:50 +05:30
Twarit Waikar
770cb4ca72 Make clang the only compiler useable on macOS 2021-10-12 03:44:17 +05:30
Twarit Waikar
5cd4ac47fd Let macOS use the same libssh2 settings as linux 2021-10-12 03:19:20 +05:30
Twarit Waikar
84fa17720c Support macOS universal thirdparty library builds 2021-10-12 02:59:32 +05:30
Twarit Waikar
b0b3eba3ee Enable PIC for mac and linux 2021-10-12 02:30:56 +05:30
Twarit Waikar
a21e028cde Compile ssh2 on linux properly (with link error) 2021-10-12 02:16:44 +05:30
Twarit Waikar
03d8f02c3d Testing CI builds for linux and mac 2021-10-12 00:50:26 +05:30
Twarit Waikar
0967424cb0 Add libssh2 to SCons build 2021-10-11 23:05:52 +05:30
Twarit Waikar
f73f6fb4b5 Issue godot-cpp builds in CI 2021-10-11 02:53:21 +05:30
Twarit Waikar
2c12788337 Update CI builds to recursively clone 2021-10-11 02:47:02 +05:30
Twarit Waikar
fe69fa2de7 Merge branch 'master' into update-vcs-new 2021-10-11 02:43:52 +05:30
Twarit Waikar
41b76d18a7 Add bleeding edge build instructions 2021-10-11 02:41:46 +05:30
Twarit Waikar
6c3aaad5fb Port the build process to use SCons entirely 2021-10-11 02:33:25 +05:30
Twarit Waikar
753ffce0c8 Add support for sending SSH credentials for auth
SSH support is however incomplete as of now because SSH support is
currently in getting turned OFF in libgit2 as we do not link to libssh2
yet
2021-10-10 07:29:07 +05:30
Twarit Waikar
055c9c387a Fix commit dates being off + update using cleaner VCS API 2021-10-10 03:00:18 +05:30
Twarit Waikar
569dc7df0c Workaround commit offset truncation through GDNative 2021-10-09 09:07:26 +05:30
Twarit Waikar
a9756150eb Add remote creation/listing backend 2021-10-09 04:42:40 +05:30
Twarit Waikar
e6eb3aaddf Add branch creation function 2021-10-08 05:01:00 +05:30
Twarit Waikar
5aa5343d53 Fix remote callback string output out of bounds mem read
Also changes the diff format to the Git default, from diff3
2021-10-08 00:08:24 +05:30
Twarit Waikar
ac32fcc708 Add force push implementation 2021-10-07 04:26:42 +05:30
Twarit Waikar
15c3bd0ad8 Change initial commit failure to a popup error 2021-10-07 02:49:11 +05:30
Twarit Waikar
d9d92f816b Don't find upstreams when pulling branches 2021-10-07 01:58:02 +05:30
Twarit Waikar
eea6826d5e Add missing error check on git upstream check during push 2021-10-07 01:19:32 +05:30
Twarit Waikar
3190180025 Remove and ignore bin files in demo/ 2021-10-07 01:17:46 +05:30
Twarit Waikar
521c70b7f9 Generate PDB file if running debug version on Windows 2021-10-07 01:14:23 +05:30
Twarit Waikar
417084afde Fix crash during push operations due to div by 0 + fix pushspecs 2021-10-07 01:13:23 +05:30
Twarit Waikar
3ccbc17d6e Stop push operations from crashing the second time onwards 2021-10-06 23:28:32 +05:30
Twarit Waikar
c3ba5b237c Fix mem leaks with C++ unique ptr deleters over libgit2 2021-10-06 02:29:56 +05:30
Twarit Waikar
6cd5a35ed2 Improve error msgs 2021-10-04 04:19:21 +05:30
Twarit Waikar
9ffee64156 Fix untracked files not showing their diffs 2021-10-04 02:23:21 +05:30
Twarit Waikar
df3b519cfc Push worked! 2021-10-04 01:27:20 +05:30
Twarit Waikar
4a37c872ac Pull worked! 2021-10-04 01:23:20 +05:30
Twarit Waikar
ee2a7607fa Intermediate commit 1 2021-10-04 01:13:47 +05:30
Twarit Waikar
b34311b10e Merge branch 'master' into update-vcs-new 2021-10-02 22:20:44 +05:30
Twarit Waikar
89d5532b1b Add bleeding edge build instructions 2021-10-02 20:29:42 +05:30
Twarit Waikar
c952c57bd9 Update clang-format.yml 2021-10-02 05:29:07 +05:30
Twarit Waikar
09ec512ea7 Fix version tag in plugin.cfg to use "v" prefix 2021-10-02 04:59:05 +05:30
Twarit Waikar
f90cbe3b0a Merge pull request #80 from ChronicallySerious/addons-dir
Shift plugin binaries and build process to use addons/ directory
2021-10-02 04:50:39 +05:30
Twarit Waikar
24a0a14ef3 Add plugin build binaries to demo 2021-10-02 04:43:20 +05:30
Twarit Waikar
4f914d15ac Shift plugin binaries and build process to use addons/ directory 2021-10-02 04:21:39 +05:30
Twarit Waikar
ea15d7a5f1 Merge pull request #79 from ChronicallySerious/add-artifact-upload-ci
Add build artifact uploads in Github Actions
2021-10-02 02:29:40 +05:30
Twarit Waikar
7aa4d02193 Merge branch 'master' into add-artifact-upload-ci 2021-10-02 01:52:03 +05:30
Twarit Waikar
957e633c2a Merge pull request #78 from ChronicallySerious/add-clang-format-ci
Add clang-format Github Action
2021-10-02 01:50:06 +05:30
Twarit Waikar
243b03aa33 Add build artifact uploads in Github Actions 2021-10-02 01:49:30 +05:30
Twarit Waikar
a480cf4b16 Add clang-format Github Action 2021-10-02 01:25:42 +05:30
Twarit Waikar
16fa788ee8 Merge branch 'master' into vcs-new 2021-09-28 12:40:33 +05:30
Twarit Waikar
e9f0844485 Merge pull request #60 from bruvzg/macos_m1
Add macOS ARM64 (Apple Silicon) support.
2021-09-28 11:28:32 +05:30
bruvzg
094424ce50 Add macOS ARM64 (Apple Silicon) support. 2021-09-28 08:28:37 +03:00
janglee123
9c0b7ee0ec Updated API 2021-07-21 00:09:16 +05:30
Twarit Waikar
4b054772ef Fix shutdown crash due to remote not being found 2021-07-17 18:16:14 +05:30
janglee
9d837bde6a Updated libgit2 build options 2021-06-13 11:42:20 +05:30
janglee
bcdff66014 Added new error popup and improved error messages 2021-06-12 22:31:05 +05:30
Twarit
ff2177c071 Add Windows build library requirements + minor build fixes 2021-06-12 22:31:05 +05:30
janglee
1780549b7b Replaced old Dictonary/Arrays structure with new
Also fixed many typos
2021-06-12 22:31:05 +05:30
janglee
91c50d8f68 Added hooks for line change gutters for script editor 2021-06-12 22:31:05 +05:30
janglee
595d679ca1 Added hooks for the new diff view 2021-06-12 22:31:05 +05:30
janglee
ec20d82eca Added hooks for new commit dock 2021-06-12 22:31:04 +05:30
Twarit Waikar
d598850795 Merge pull request #69 from Calinou/readme-add-apple-silicon-notice
Document that building for Apple Silicon isn't supported yet
2021-05-09 14:39:07 +05:30
Hugo Locurcio
68e48e47c9 Document that building for Apple Silicon isn't supported yet 2021-05-09 11:04:44 +02:00
Twarit Waikar
9ed3b5128d Merge pull request #65 from ChronicallySerious/add-godot-version-readme
Add comment in README on nature of master targeting upcoming Godot
2021-04-19 23:56:12 +05:30
Twarit Waikar
abe4799600 Add comment in README on nature of master targeting upcoming Godot 2021-04-19 23:51:33 +05:30
Twarit Waikar
82ba804255 Merge pull request #64 from ChronicallySerious/small-appveyor-test 2021-04-19 22:13:24 +05:30
Twarit Waikar
58a5f956c0 Check if Appveyor build statuses are gone 2021-04-19 21:47:16 +05:30
Twarit Waikar
707937da12 Minor readme change 2021-04-19 21:34:30 +05:30
Twarit Waikar
95e7b29088 Merge pull request #63 from ChronicallySerious/add-ci-badge
Add CI badge to README
2021-04-19 21:20:54 +05:30
Twarit Waikar
2d2bbb0704 Add C/C++ CI badge to README 2021-04-19 19:20:42 +05:30
Twarit Waikar
4f1604d4f1 Merge pull request #62 from ChronicallySerious/build-workflow 2021-04-19 19:13:23 +05:30
Twarit Waikar
34bdbcdc50 Remove Travis CI and AppVeyor configs 2021-04-19 19:11:48 +05:30
Twarit Waikar
d6f3bdbab6 Load msvc developer cmd for windows CI 2021-04-19 18:38:19 +05:30
Twarit Waikar
57cd5cc068 Enforce C++17 in some left out build configs on mac 2021-04-19 18:11:31 +05:30
Twarit Waikar
0c6017066f Change godot_headers to godot-headers in include path 2021-04-19 17:02:00 +05:30
Twarit Waikar
0afdf18596 Speed up godot-cpp build by multithreaded build 2021-04-19 16:55:25 +05:30
Twarit Waikar
a41e4040d0 Update godot-cpp submodule url and update to latest commit 2021-04-19 16:41:38 +05:30
Twarit Waikar
6ec481671b Add SCons install to CI build scripts 2021-04-19 16:15:40 +05:30
Twarit Waikar
9da28eed5a Treat CMakeCache.txt not found while deletion as non-error 2021-04-19 15:00:42 +05:30
Twarit Waikar
24931cf07a Add C/C++ CI build workflows 2021-04-19 14:55:54 +05:30
Twarit Waikar
c70f971e5f Merge pull request #52 from IronicallySerious/mac-port 2020-12-09 20:38:58 +05:30
IronicallySerious
33ac9dfbb6 Add Mac build instructions to README.md 2020-12-09 19:09:40 +05:30
IronicallySerious
12ed472049 Port build scripts to Mac 2020-12-09 18:13:47 +05:30
Twarit Waikar
7cea3fa0a9 Fix build_libs.bat making x11 dir on windows build 2020-09-06 06:56:47 +05:30
Twarit Waikar
7fc5e1e959 Change godot support line in readme 2020-09-06 06:54:51 +05:30
Twarit Waikar
7cc8269aeb Fix platform specific quirks affecting build scripts and CI (#48) 2020-09-06 06:47:54 +05:30
Twarit Waikar
879c2b5d8f Search for libgit2.a during build instead of picking 2020-09-06 04:22:57 +05:30
Twarit Waikar
7861721319 Revert adding ssl to linux build whichadded redundant lib 2020-09-06 03:54:34 +05:30
Twarit Waikar
60408127a8 Improve README + include ssl in linux build 2020-09-06 03:48:58 +05:30
Twarit Waikar
97d82d2ac8 Fix random crashing in init (backport from v2)
Remove generated build items/project files
Also build libgit2 in release mode if building in release
2020-09-06 03:13:46 +05:30
serious
bd7ac76035 Add PIC flag to libgit2 linux build 2020-09-06 01:07:47 +05:30
Twarit Waikar
b5d56d48ce Merge pull request #31 from godotengine/libgit2-bump-fix 2020-09-05 15:36:08 +05:30
Twarit Waikar
185ac3ec77 Update CMakeLists.txt 2020-05-17 18:51:41 +05:30
Twarit Waikar
6d98ee28b5 Add missing PIC flag in while building libgit2 2020-05-17 18:42:52 +05:30
Twarit Waikar
7363752513 Merge branch 'master' into libgit2-bump-fix 2020-05-17 18:28:14 +05:30
Twarit Waikar
b840327919 Merge pull request #35 from akien-mga/appveyor-fix-vs2019 2020-05-17 18:27:30 +05:30
Twarit Waikar
c869346ad1 Turn off MSBuild mode in AppVeyor 2020-05-17 17:25:55 +05:30
Twarit Waikar
6ca655d092 Do let Appveyor look for scons outside of repo dir 2020-05-17 17:05:37 +05:30
Twarit Waikar
3f2679c81d Fix AppVeyor using wrong location for scons.bat 2020-05-17 16:48:51 +05:30
Rémi Verschelde
0b60d64ccf AppVeyor: Fix godot-cpp build with scons-local
Also fix path to vcvars64 for VS 2019 and use SCons 3.1.2.
2020-05-14 22:14:10 +02:00
Twarit Waikar
8fce7ad07c Disable AppVeyor builds for now
Will enable again when we configure AppVeyor properly
2020-05-14 17:44:44 +05:30
Twarit
93f6e49d7e Apply same build options for linux static libgit2 build 2020-05-13 23:07:49 +05:30
Twarit
2a16b3d168 Log libgit2 bump in VERSIONS 2020-05-13 22:43:31 +05:30
Twarit
a3ad451bdd Bump Libgit2 to v1.0 2020-05-13 21:51:22 +05:30
Twarit Waikar
bb9c7a7105 Bump AppVeyor vm to VS 2019 2020-04-17 19:45:27 +05:30
Twarit Waikar
5ced3f6eaf Switch to lowercase build type name in appveyor 2020-04-10 20:09:29 +05:30
Twarit
13c8905f72 Fix minor spell error: intialize -> initialize 2020-04-10 16:07:46 +05:30
Twarit Waikar
04cab3e227 Merge pull request #27 from godotengine/fix-link-error
Fix link errors due to not linking Advapi
2020-04-09 17:26:42 +05:30
Twarit
62247870dc Fix link errors in #26 2020-04-09 17:25:22 +05:30
Twarit
b1ac091571 Properly add PIC for all libgit2 builds 2020-03-30 19:25:06 +05:30
Twarit
aa3d85d970 Force -fPIC in libgit2 2020-03-30 17:13:47 +05:30
Twarit
b484d1eb3b Minor fix to not look deeper in dir to find libgit2.a 2020-03-30 16:56:27 +05:30
Twarit
923818997d Set Libgit2 to build into a static lib and use bundled zlib by default 2020-03-30 14:02:54 +05:30
Twarit
933fb7b7d0 Add AppVeyor build script 2020-03-30 14:02:23 +05:30
Twarit
cdbcbf8710 Remove MacOS and Windows CI, keep Linux only 2020-03-30 13:49:58 +05:30
Twarit
da42fb3896 Revert to using forward slash in CI script 2020-03-30 13:45:36 +05:30
Twarit
d915d53e31 Convert forward slashes to backslashes in .travis.yml 2020-03-30 13:42:55 +05:30
Twarit
0388ca39d5 Fix missing semicolon in travis file + use C++17 in CI build 2020-03-30 13:34:35 +05:30
Twarit
db05e54d00 Fix missing compiler and some C++ errors 2020-03-30 13:30:27 +05:30
Twarit
07876bff06 Use dev console in windows CI build 2020-03-30 13:20:40 +05:30
Twarit
827dabced8 Switch back to generating bindings in CI 2020-03-30 12:57:51 +05:30
Twarit
7bdda124aa Select OS in CI build 2020-03-30 12:49:32 +05:30
Twarit
5ddb2d44e5 Remove artifacts left over from copied .travis.yml 2020-03-30 12:42:34 +05:30
Twarit
7e57104764 Add macos CI + clean build script 2020-03-30 12:24:42 +05:30
Twarit
b44a9c29a9 Add Windows build to CI 2020-03-30 12:11:21 +05:30
Twarit
17dc47e151 Fix ambiguous conversion in git_api.cpp 2020-03-30 02:01:43 +05:30
Twarit
19627c4063 Use latest GCC in build 2020-03-30 01:40:10 +05:30
Twarit
f1feb86c42 Limit Travis to only Linux builds 2020-03-30 01:38:35 +05:30
Twarit
271fc3e996 Remove CI compilaion warnings/errors 2020-03-30 01:20:47 +05:30
Twarit
20e1148d39 Acquire scons before running SCons 2020-03-30 01:07:13 +05:30
Twarit
80fa3f185f Fix incorrect build scrit invokation in Travis 2020-03-30 01:04:19 +05:30
Twarit
3fc9aa263c Add Travis back in 2020-03-30 01:00:04 +05:30
Twarit
6ab8845dd2 Make build_libs.sh executable 2020-03-30 00:53:19 +05:30
Twarit
3364a0ef16 Automate compiling libgit2 2020-03-30 00:38:40 +05:30
Twarit
cc512c0a17 Shift gitsubmodule to godot-cpp root 2020-03-29 23:37:11 +05:30
Twarit
f0a5bf16d9 Removed submodule IronicallySerious/godot-cpp 2020-03-29 23:04:39 +05:30
Twarit
02d3df348f Update to godot-cpp from 3.2stable 2020-03-29 22:59:02 +05:30
Twarit Waikar
4908788e24 Replace link to GSoC progress report by Wiki link 2020-02-15 01:49:35 +05:30
Twarit
6dbac88d8f Fix crash on missing user.email and user.name in gitconfig 2020-02-15 01:28:40 +05:30
Twarit Waikar
bed4e799d6 Remove Travis CI (explanantion)
The godot-cpp build needs to refer to godot engine binary to extract the latest 3.2 GDNative API. Since godot-cpp has not been updated for 3.2, using any kind of CI will be a lot more effort than just setting up a build script
2020-02-14 22:53:20 +05:30
Twarit
ba4a907f89 Make build shell scripts executable 2020-02-14 22:48:37 +05:30
Twarit Waikar
f1e8e0ac1d Fix OS mismatch on debug and release jobs 2020-02-14 22:44:53 +05:30
Twarit Waikar
990ccfd0bc Add Travis CI build conf 2020-02-14 22:39:44 +05:30
Twarit Waikar
7dec368991 Add MIT license 2020-02-05 17:44:19 +05:30
Twarit Waikar
23af5c9f50 Merge pull request #14 from follower/patch-1
Add brief installation instructions
2020-02-05 13:38:15 +05:30
follower
c71c5c15be Add brief installation instructions
Primarily so people realise building from source isn't required for Windows/Linux.
2020-02-05 15:06:29 +13:00
Twarit
c2485c1346 Remove plugin .so binary 2020-02-03 22:37:07 +05:30
Twarit
c72509109b Gitignore plugin binaries 2020-02-03 22:35:55 +05:30
Twarit
ee3c9c9746 Add new windows binaries 2020-02-03 22:30:38 +05:30
Twarit Waikar
0bf806c508 Delete main.yml 2020-02-03 21:36:42 +05:30
Twarit
5b2d8d48c3 Add release build script 2020-02-03 21:23:40 +05:30
Twarit Waikar
a1d32d04bb Fix command concat for windows cmd in build action 2020-02-03 21:18:10 +05:30
Twarit Waikar
066e951e2f Add Linux and Windows build action 2020-02-03 21:11:19 +05:30
10261 changed files with 2600 additions and 358281 deletions

2
.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

59
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@@ -0,0 +1,59 @@
name: Bug report
description: Report a bug in Godot Git Plugin
labels:
- bug
body:
- type: markdown
attributes:
value: |
- Write a descriptive issue title above.
- Search [open](https://github.com/godotengine/godot-git-plugin/issues) and [closed](https://github.com/godotengine/godot-git-plugin/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported.
- Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/stable/about/release_policy.html).
- This repository only contains the Git integration. Issues pertaining to the Godot editor itself or the general version control UI should be reported on the [main Godot repository](https://github.com/godotengine/godot/issues).
- type: input
attributes:
label: Godot version
description: >
Specify the Git commit hash if using a development or non-official build.
If you use a custom build, please test if your issue is reproducible in official builds too.
placeholder: 4.4.1.stable, 4.5.dev4 (209a446e3)
validations:
required: true
- type: input
attributes:
label: Godot Git Plugin version
description: >
Specify the Git commit hash if using a development or non-official build.
If you use a custom build, please test if your issue is reproducible in official builds too.
placeholder: "3.2.1"
validations:
required: true
- type: input
attributes:
label: System information
description: |
Specify the OS version, and when relevant hardware information.
placeholder: Windows 10
validations:
required: true
- type: textarea
attributes:
label: Issue description
description: |
Describe your issue briefly. What doesn't work, and how do you expect it to work instead?
You can include images or videos with drag and drop, and format code blocks or logs with <code>```</code> tags.
validations:
required: true
- type: textarea
attributes:
label: Steps to reproduce
description: |
List of steps or sample code that reproduces the issue. Having reproducible issues is a prerequisite for contributors to be able to solve them.
validations:
required: true

6
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,6 @@
blank_issues_enabled: false
contact_links:
- name: Godot community channels
url: https://godotengine.org/community
about: Please ask for technical support on one of the other community channels, not here.

View File

@@ -0,0 +1,59 @@
name: Feature request
description: Request a new feature to be added or improved in Godot Git Plugin
labels:
- enhancement
body:
- type: markdown
attributes:
value: |
- Write a descriptive issue title above.
- Search [open](https://github.com/godotengine/godot-git-plugin/issues) and [closed](https://github.com/godotengine/godot-git-plugin/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported.
- Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/stable/about/release_policy.html).
- This repository only contains the Git integration. Issues pertaining to the Godot editor itself or the general version control UI should be reported on the [main Godot repository](https://github.com/godotengine/godot/issues).
- type: input
attributes:
label: Godot version
description: >
Specify the Git commit hash if using a development or non-official build.
If you use a custom build, please test if your issue is reproducible in official builds too.
placeholder: 4.4.1.stable, 4.5.dev4 (209a446e3)
validations:
required: true
- type: input
attributes:
label: Godot Git Plugin version
description: >
Specify the Git commit hash if using a development or non-official build.
If you use a custom build, please test if your issue is reproducible in official builds too.
placeholder: "3.2.1"
validations:
required: true
- type: input
attributes:
label: System information
description: |
Specify the OS version, and when relevant hardware information.
placeholder: Windows 10
validations:
required: true
- type: textarea
attributes:
label: Problem statement
description: |
Describe the problem or limitation you're currently facing with the Godot Git Plugin.
validations:
required: true
- type: textarea
attributes:
label: Proposed solution
description: |
Describe your proposed solution and how it resolves the problem or limitation mentioned above.
You can include images or videos with drag and drop, and format code blocks or logs with <code>```</code> tags.
validations:
required: true

98
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,98 @@
name: C/C++ CI
on: [push, pull_request]
env:
# Only used for the cache key. Increment version to force clean build.
GODOT_BASE_BRANCH: master
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/
jobs:
linux-x64:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Godot build cache
uses: ./godot-cpp/.github/actions/godot-cache
with:
cache-name: linux-x86_64
continue-on-error: true
- name: Build for Linux editor x86_64
run: |
pip3 install scons
scons platform=linux arch=x86_64 target=editor generate_bindings=yes
ldd addons/godot-git-plugin/linux/*.so
- name: Prepare artifact
run: |
mkdir out
mv addons out/
- uses: actions/upload-artifact@v4
with:
name: libgit_plugin.linux.x86_64.editor.so-${{ github.sha }}
if-no-files-found: error
path: |
out/
windows-x64:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Godot build cache
uses: ./godot-cpp/.github/actions/godot-cache
with:
cache-name: windows-x86_64
- uses: ilammy/msvc-dev-cmd@v1 # For dumpbin.
- uses: ilammy/setup-nasm@v1
- name: Build for Windows editor x86_64
shell: powershell
run: |
pip3 install scons
scons platform=windows arch=x86_64 target=editor generate_bindings=yes
dumpbin /dependents .\addons\godot-git-plugin\windows\*.dll
- name: Prepare artifact
shell: bash
run: |
# Not needed to use the plugin.
rm -f addons/godot-git-plugin/windows/*.{exp,lib}
mkdir out
mv addons out/
- uses: actions/upload-artifact@v4
with:
name: libgit_plugin.windows.x86_64.editor.dll-${{ github.sha }}
if-no-files-found: error
path: |
out/
macos-universal:
runs-on: macos-15
steps:
- name: Setup Xcode 16.2 (16.3+ incompatible with libgit2's zlib)
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '16.2'
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Godot build cache
uses: ./godot-cpp/.github/actions/godot-cache
with:
cache-name: macos-universal
- name: Build for macOS editor universal
run: |
pip install scons
scons platform=macos arch=universal target=editor generate_bindings=yes macos_deployment_target=10.13
otool -L addons/godot-git-plugin/macos/*.dylib
- name: Prepare artifact
run: |
mkdir out
mv addons out/
- uses: actions/upload-artifact@v4
with:
name: libgit_plugin.macos.universal.editor.dylib-${{ github.sha }}
if-no-files-found: error
path: |
out/

15
.github/workflows/clang-format.yml vendored Normal file
View File

@@ -0,0 +1,15 @@
name: clang-format
on: [push, pull_request]
jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DoozyX/clang-format-lint-action@v0.18.2
with:
source: "godot-git-plugin/src"
extensions: "h,cpp"
clangFormatVersion: 18

40
.gitignore vendored
View File

@@ -2,7 +2,8 @@
*.dblite
# Godot Serialisations
api.json
extension_api.json
!/ci/extension_api.json
# Visual Studio Cache
.vs/
@@ -10,26 +11,27 @@ api.json
# VSCode Cache
.vscode/
# Mac stuff
.DS_Store
# Vim
*.swp
# Binaries
bin/
intermediate/
__pycache__/
build/
*.dll
bin/
macos/
linux/
win64/
*.lib
*.a
*.obj
*.so
*.dylib
*.pdb
*.ilk
*.exe
*.os
*.out
.import/
# Binaries for distribution
!/demo/bin/
!libgitapi.dll
!libgitapi.so
!libgitapi.dylib
!git2.lib
!libgit.a
*.ilk
*.pdb
*.pyc
*.zip
# Misc
*.log

13
.gitmodules vendored
View File

@@ -1,3 +1,14 @@
[submodule "godot-cpp"]
path = godot-cpp
url = https://github.com/IronicallySerious/godot-cpp
url = https://github.com/godotengine/godot-cpp
branch = 3.x
[submodule "thirdparty/git2/libgit2"]
path = thirdparty/git2/libgit2
url = https://github.com/libgit2/libgit2
ignore = untracked
[submodule "thirdparty/ssh2/libssh2"]
path = thirdparty/ssh2/libssh2
url = https://github.com/libssh2/libssh2
[submodule "thirdparty/openssl"]
path = thirdparty/openssl
url = https://github.com/openssl/openssl

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016-2023 The Godot Engine community
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,20 +1,64 @@
# GDNative Based Git Plugin for Godot Version Control Editor Plugin
Implements the proxy end-points for the `EditorVCSInterface` API in the Godot Engine Editor. Uses [libgit2](https://libgit2.org) at its backend to simulate Git in code.
[![C/C++ CI](https://github.com/godotengine/godot-git-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/godotengine/godot-git-plugin/actions/workflows/build.yml)
## Build Instructions
<img src="/icon.png" width="25%" />
### Windows
1. Open `build.bat` as text.
2. Edit the relative paths to the Godot binary and from the Godot binary directory to this repository's directory in line 1 and line 2.
3. Run `build.bat`.
4. Run `cd ..` because the build file leaves you one level deeper in the repository.
5. Load the x64 command prompt: `x64 Native Tools Command Prompt for VS 2017`.
6. Run `scons platform=windows`
# Godot Git Plugin
### Linux
1. Open `build.sh` as text.
2. Edit the relative paths to the Godot binary and from the Godot binary directory to this repository's directory in line 1 and line 2.
3. Prepare script for execution: `chmod 755 build.sh`
4. Run ```. ./build.sh```.
5. Run `cd ..` because the build file leaves you one level deeper in the repository.
6. Run `scons platform=x11`.
Git implementation of the Godot Engine VCS interface in Godot. We use [libgit2](https://libgit2.org) as our backend to simulate Git in code.
## Installation
1. Grab the platform binaries here: https://github.com/godotengine/godot-git-plugin/releases
2. Then read the installation instructions: https://github.com/godotengine/godot-git-plugin/wiki
## Build
This section onwards is only meant to be used if you intend to compile the plugin from source.
### Required tools
- Full copy of the source code. Remember to use `git clone --recursive`, or initialize submodules with `git submodule update --init`.
- [SCons](https://scons.org/pages/download.html) (v3.1.2+), CMake, and Perl.
- C++17 and C90 compilers detectable by SCons and present in `PATH`.
### Release build
```
scons platform=<platform> target=editor
```
> You may get the GDExtension dump yourself from Godot using the instructions in the next section, or use the ones provided in `godot-cpp`.
For more build options, run `scons platform=<platform> -h`
## Dev builds
When new features are being worked on for the Godot VCS Integration, the build process sometimes requires developers to make changes in the GDExtension API along with this plugin. This means we need to manually generate the GDExtension API from the custom Godot builds and use it to compile godot-cpp, and then finally link the resulting godot-cpp binary into this plugin.
If you need to use a custom GDExtension API:
1. Dump the new bindings from the custom Godot build.
```shell
./path/to/godot/bin/godot.<platform>.editor.<arch> --headless --dump-gdextension-interface --dump-extension-api
```
2. Build the plugin along with the godot-cpp library.
```
scons platform=<platform> target=editor generate_bindings=yes dev_build=yes
```
> You only need to build godot-cpp once every change in the GDExtension API, hence, `generate_bindings=yes` should only be passed in during the first time after generating a new GDExtension API dump.
3. To test the plugin, set up a testing project with Godot, and copy or symlink the `addons` folder.
To view more options available while recompiling godot-git-plugin, run `scons platform=<platform> -h`.
---
## License
This plugin is under the MIT License. Third-party notices are present in [THIRDPARTY.md](THIRDPARTY.md).
OpenSSL License Attributions - This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/). This product includes cryptographic software written by Eric Young (eay@cryptsoft.com)

View File

@@ -1,98 +1,53 @@
#!python
import os, subprocess
#!/usr/bin/env python
import os
EnsureSConsVersion(3, 1, 2)
EnsurePythonVersion(3, 6)
opts = Variables([], ARGUMENTS)
# Gets the standard flags CC, CCX, etc.
env = DefaultEnvironment()
env = Environment(ENV=os.environ)
# Define our options
opts.Add(EnumVariable('target', "Compilation target", 'debug', ['d', 'debug', 'r', 'release']))
opts.Add(EnumVariable('platform', "Compilation platform", '', ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(EnumVariable('p', "Compilation target, alias for 'platform'", '', ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no'))
opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'demo/bin/'))
opts.Add(PathVariable('target_name', 'The library name.', 'libgitapi', PathVariable.PathAccept))
# Local dependency paths, adapt them to your setup
godot_headers_path = "godot-cpp/godot_headers/"
cpp_bindings_path = "godot-cpp/"
cpp_library = "libgodot-cpp"
libgit2_lib_path = "demo/bin/"
libgit2_include_path = "godot-git-plugin/thirdparty/libgit2/include/"
# only support 64 at this time..
bits = 64
opts.Add(PathVariable("target_path",
"The path where the lib is installed.", "addons/godot-git-plugin/"))
opts.Add(PathVariable("target_name", "The library name.",
"libgit_plugin", PathVariable.PathAccept))
# Updates the environment with the option variables.
opts.Update(env)
# Process some arguments
if env['use_llvm']:
env['CC'] = 'clang'
env['CXX'] = 'clang++'
if ARGUMENTS.get("custom_api_file", "") != "":
ARGUMENTS["custom_api_file"] = "../" + ARGUMENTS["custom_api_file"]
if env['p'] != '':
env['platform'] = env['p']
ARGUMENTS["target"] = "editor"
env = SConscript("godot-cpp/SConstruct").Clone()
env.PrependENVPath("PATH", os.getenv("PATH")) # Prepend PATH, done upstream in recent godot-cpp verions.
if env['platform'] == '':
print("No valid target platform selected.")
quit();
# Force linking with LTO on windows MSVC, silence the linker complaining that libgit uses LTO but we are not linking with it.
if env["platform"] == "windows" and env.get("is_msvc", False):
env.AppendUnique(LINKFLAGS=["/LTCG"])
# Check our platform specifics
if env['platform'] == "osx":
env['target_path'] += 'osx/'
cpp_library += '.osx'
libgit2_lib_path += 'osx/'
if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS = ['-g','-O2', '-arch', 'x86_64'])
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
else:
env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64'])
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
# OpenSSL Builder
env.Tool("openssl", toolpath=["tools"])
elif env['platform'] in ('x11', 'linux'):
env['target_path'] += 'x11/'
cpp_library += '.linux'
libgit2_lib_path += 'x11/'
if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS = ['-fPIC', '-g3','-Og', '-std=c++17'])
else:
env.Append(CCFLAGS = ['-fPIC', '-g','-O3', '-std=c++17'])
# SSH2 Builder
env.Tool("cmake", toolpath=["tools"])
env.Tool("ssh2", toolpath=["tools"])
env.Tool("git2", toolpath=["tools"])
elif env['platform'] == "windows":
env['target_path'] += 'win64/'
cpp_library += '.windows'
libgit2_lib_path += 'win64/'
# This makes sure to keep the session environment variables on windows,
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
env.Append(ENV = os.environ)
opts.Update(env)
env.Append(CCFLAGS = ['-DWIN32', '-D_WIN32', '-D_WINDOWS', '-W3', '-GR', '-D_CRT_SECURE_NO_WARNINGS'])
if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '-MDd'])
else:
env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '-MD'])
ssl = env.OpenSSL()
ssh2 = env.BuildSSH2(ssl)
ssl += ssh2
git2 = env.BuildGIT2(ssl)
if env['target'] in ('debug', 'd'):
cpp_library += '.debug'
else:
cpp_library += '.release'
Export("ssl")
Export("env")
cpp_library += '.' + str(bits)
# make sure our binding library properly includes
env.Append(CPPPATH=['.', godot_headers_path, cpp_bindings_path + 'include/', cpp_bindings_path + 'include/core/', cpp_bindings_path + 'include/gen/'])
env.Append(LIBPATH=[cpp_bindings_path + 'bin/', libgit2_lib_path])
env.Append(LIBS=[cpp_library, 'git2'])
# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=['godot-git-plugin/src/', libgit2_include_path])
sources = Glob('godot-git-plugin/src/*.cpp')
library = env.SharedLibrary(target=env['target_path'] + env['target_name'] , source=sources)
Default(library)
SConscript("godot-git-plugin/SCsub")
# Generates help for the -h scons option.
Help(opts.GenerateHelpText(env))

View File

@@ -1,3 +1,43 @@
# Third-Party Notices
The Godot Git Plugin source code uses the following third-party source code:
1. godotengine/godot-cpp - MIT License - https://github.com/godotengine/godot-cpp/tree/02336831735fd6affbe0a6fa252ec98d3e78120c
2. libgit2/libgit2 - GPLv2 with a special Linking Exception - https://github.com/libgit2/libgit2/tree/b7bad55e4bb0a285b073ba5e02b01d3f522fc95d
3. libssh2/libssh2 - BSD-3-Clause License - https://github.com/libssh2/libssh2/tree/635caa90787220ac3773c1d5ba11f1236c22eae8
4. openssl - OpenSSL License - https://github.com/openssl/openssl/tree/26baecb28ce461696966dac9ac889629db0b3b96
## License Texts
### godotengine/godot-cpp
```
# MIT License
Copyright (c) 2017-2022 Godot Engine contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
### libgit2/libgit2
```
libgit2 is Copyright (C) the libgit2 contributors,
unless otherwise stated. See the AUTHORS file for details.
@@ -420,7 +460,7 @@ The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -1019,3 +1059,288 @@ following restrictions are are met:
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
----------------------------------------------------------------------
Portions of the OpenSSL headers are included under the OpenSSL license:
Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
All rights reserved.
This package is an SSL implementation written
by Eric Young (eay@cryptsoft.com).
The implementation was written so as to conform with Netscapes SSL.
This library is free for commercial and non-commercial use as long as
the following conditions are aheared to. The following conditions
apply to all code found in this distribution, be it the RC4, RSA,
lhash, DES, etc., code; not just the SSL code. The SSL documentation
included with this distribution is covered by the same copyright terms
except that the holder is Tim Hudson (tjh@cryptsoft.com).
Copyright remains Eric Young's, and as such any Copyright notices in
the code are not to be removed.
If this package is used in a product, Eric Young should be given attribution
as the author of the parts of the library used.
This can be in the form of a textual message at program startup or
in documentation (online or textual) provided with the package.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
"This product includes cryptographic software written by
Eric Young (eay@cryptsoft.com)"
The word 'cryptographic' can be left out if the rouines from the library
being used are not cryptographic related :-).
4. If you include any Windows specific code (or a derivative thereof) from
the apps directory (application code) you must include an acknowledgement:
"This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
The licence and distribution terms for any publically available version or
derivative of this code cannot be changed. i.e. this code cannot simply be
copied and put under another distribution licence
[including the GNU Public Licence.]
====================================================================
Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. All advertising materials mentioning features or use of this
software must display the following acknowledgment:
"This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
endorse or promote products derived from this software without
prior written permission. For written permission, please contact
openssl-core@openssl.org.
5. Products derived from this software may not be called "OpenSSL"
nor may "OpenSSL" appear in their names without prior written
permission of the OpenSSL Project.
6. Redistributions of any form whatsoever must retain the following
acknowledgment:
"This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/)"
THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
```
### libssh2/libssh2
```
/* Copyright (c) 2004-2007 Sara Golemon <sarag@libssh2.org>
* Copyright (c) 2005,2006 Mikhail Gusarov <dottedmag@dottedmag.net>
* Copyright (c) 2006-2007 The Written Word, Inc.
* Copyright (c) 2007 Eli Fant <elifantu@mail.ru>
* Copyright (c) 2009-2021 Daniel Stenberg
* Copyright (C) 2008, 2009 Simon Josefsson
* Copyright (c) 2000 Markus Friedl
* Copyright (c) 2015 Microsoft Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms,
* with or without modification, are permitted provided
* that the following conditions are met:
*
* Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
*
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* Neither the name of the copyright holder nor the names
* of any other contributors may be used to endorse or
* promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*/
```
### OpenSSL
```
LICENSE ISSUES
==============
The OpenSSL toolkit stays under a double license, i.e. both the conditions of
the OpenSSL License and the original SSLeay license apply to the toolkit.
See below for the actual license texts.
OpenSSL License
---------------
/* ====================================================================
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* openssl-core@openssl.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
*
*/
Original SSLeay License
-----------------------
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
```

View File

@@ -0,0 +1,10 @@
[configuration]
entry_symbol = "git_plugin_init"
compatibility_minimum = "4.2.0"
[libraries]
linux.editor.x86_64 = "linux/libgit_plugin.linux.editor.x86_64.so"
macos.editor = "macos/libgit_plugin.macos.editor.universal.dylib"
windows.editor.x86_64 = "windows/libgit_plugin.windows.editor.x86_64.dll"

View File

@@ -1,9 +0,0 @@
set GODOT_PATH_RELATIVE_TO_PLUGIN="..\godot\bin"
set GIT_PLUGIN_RELATIVE_TO_GODOT="..\..\godot-git-plugin\"
git submodule init
git submodule update --init --recursive
cd %GODOT_PATH_RELATIVE_TO_PLUGIN%
godot.windows.tools.64.exe --gdnative-generate-json-api api.json
copy api.json %GIT_PLUGIN_RELATIVE_TO_GODOT%\api.json /Y
cd %GIT_PLUGIN_RELATIVE_TO_GODOT%\godot-cpp\
scons platform=windows generate_bindings=yes use_custom_api_file=yes custom_api_file=../api.json bits=64

View File

@@ -1,10 +0,0 @@
GODOT_PATH_RELATIVE_TO_PLUGIN="../godot/bin";
GIT_PLUGIN_RELATIVE_TO_GODOT="../../godot-git-plugin/";
git submodule init;
git submodule update --init --recursive;
cd $GODOT_PATH_RELATIVE_TO_PLUGIN;
./godot.x11.tools.64 --gdnative-generate-json-api api.json;
cp api.json $GIT_PLUGIN_RELATIVE_TO_GODOT/api.json;
cd $GIT_PLUGIN_RELATIVE_TO_GODOT;
cd godot-cpp/;
scons platform=linux generate_bindings=yes use_custom_api_file=yes custom_api_file=../api.json bits=64;

17
demo/.gitattributes vendored
View File

@@ -1,17 +0,0 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
#Explicitly declare text files you want to always be normalized and converted
#to native line endings on checkout.
*.cpp text
*.c text
*.h text
*.gd text
*.cs text
#Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
#Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary

7
demo/.gitignore vendored
View File

@@ -1,7 +0,0 @@
# Import cache
.import/
# Binaries
bin/
build/
lib/

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,7 +0,0 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[resource]
background_mode = 2
background_sky = SubResource( 1 )

View File

@@ -1,3 +0,0 @@
[gd_scene format=2]
[node name="Node2D" type="Node2D"]

View File

@@ -1,16 +0,0 @@
[general]
singleton=true
load_once=true
symbol_prefix="godot_"
reloadable=false
[entry]
Windows.64="res://bin/win64/libgitapi.dll"
X11.64="res://bin/x11/libgitapi.so"
[dependencies]
Windows.64=[ ]
X11.64=[ ]

View File

@@ -1,9 +0,0 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://git_api.gdnlib" type="GDNativeLibrary" id=1]
[resource]
resource_name = "GitAPI"
class_name = "GitAPI"
library = ExtResource( 1 )
script_class_name = "GitAPI"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -1,34 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@@ -1,12 +0,0 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View File

@@ -1,33 +0,0 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
_global_script_classes=[ {
"base": "",
"class": "GitAPI",
"language": "NativeScript",
"path": "res://git_api.gdns"
} ]
_global_script_class_icons={
"GitAPI": ""
}
[application]
config/name="demo"
run/main_scene="res://demo.tscn"
config/icon="res://icon.png"
[gdnative]
singletons=[ "res://git_api.gdnlib" ]
[rendering]
environment/default_environment="res://default_env.tres"

38
godot-git-plugin/SCsub Normal file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/env python
import os
env = {}
Import("env")
Import("ssl")
env["target_path"] = "../" + env["target_path"]
if not os.path.isdir(env["target_path"]):
os.mkdir(env["target_path"])
# Check our platform specifics
env["target_path"] += env["platform"] + "/"
if env["platform"] == "macos":
if env["macos_deployment_target"] != "default":
env.Append(CCFLAGS=["-mmacosx-version-min=" +
env["macos_deployment_target"]])
env.Append(LINKFLAGS=["-mmacosx-version-min=" +
env["macos_deployment_target"]])
elif env["platform"] == "windows":
env.Append(LIBS=["advapi32", "winhttp", "rpcrt4", "crypt32",
"ole32", "user32", "wsock32", "ws2_32", "bcrypt"])
env.Append(CPPPATH=[".", "src/"])
env.Append(CPPPATH=["#thirdparty/git2/libgit2/include/"])
lib_sources = Glob("src/*.cpp")
env.Depends(lib_sources, ssl)
library = env.SharedLibrary(
target=env["target_path"] +
"{}{}{}".format(env["target_name"], env["suffix"], env["SHLIBSUFFIX"]),
source=lib_sources
)
Default(library)

View File

@@ -1,31 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.572
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "godot-git-plugin", "godot-git-plugin.vcxproj", "{574C5E6A-EDEC-41A6-BDF7-4106698F80B0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{574C5E6A-EDEC-41A6-BDF7-4106698F80B0}.Debug|x64.ActiveCfg = Debug|x64
{574C5E6A-EDEC-41A6-BDF7-4106698F80B0}.Debug|x64.Build.0 = Debug|x64
{574C5E6A-EDEC-41A6-BDF7-4106698F80B0}.Debug|x86.ActiveCfg = Debug|Win32
{574C5E6A-EDEC-41A6-BDF7-4106698F80B0}.Debug|x86.Build.0 = Debug|Win32
{574C5E6A-EDEC-41A6-BDF7-4106698F80B0}.Release|x64.ActiveCfg = Release|x64
{574C5E6A-EDEC-41A6-BDF7-4106698F80B0}.Release|x64.Build.0 = Release|x64
{574C5E6A-EDEC-41A6-BDF7-4106698F80B0}.Release|x86.ActiveCfg = Release|Win32
{574C5E6A-EDEC-41A6-BDF7-4106698F80B0}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {76AE10F4-C459-45E7-AB91-BC7C0B0BA625}
EndGlobalSection
EndGlobal

View File

@@ -1,147 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{574C5E6A-EDEC-41A6-BDF7-4106698F80B0}</ProjectGuid>
<RootNamespace>godotgitplugin</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>D:\CPP Projects\godot-git-plugin\godot-git-plugin\thirdparty\libgit2\include;.\src\;..\godot-cpp\godot_headers\;..\godot-cpp\include\gen;..\godot-cpp\include\core\;..\godot-cpp\include\;$(IncludePath)</IncludePath>
<LibraryPath>D:\CPP Projects\godot-git-plugin\demo\bin\win64;..\godot-cpp\bin;$(LibraryPath)</LibraryPath>
<SourcePath>.\src\;$(VC_SourcePath);</SourcePath>
<OutDir>$(SolutionDir)..\demo\bin\win64\</OutDir>
<IntDir>$(SolutionDir)..\demo\bin\win64\intermediate\</IntDir>
<TargetName>libgitapi</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<AdditionalDependencies>libgodot-cpp.windows.debug.64.lib;git2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
<OutputFile>$(SolutionDir)..\demo\bin\win64\libgitapi.dll</OutputFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\gdlibrary.cpp" />
<ClCompile Include="src\git_api.cpp" />
<ClCompile Include="src\git_common.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\allocation_defs.h" />
<ClInclude Include="src\git_api.h" />
<ClInclude Include="src\git_common.h" />
</ItemGroup>
<ItemGroup>
<None Include=".clang-format" />
<None Include=".editorconfig" />
<None Include="cpp.hint" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,44 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\gdlibrary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\git_api.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\git_common.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\git_api.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\git_common.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\allocation_defs.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />
<None Include=".clang-format" />
<None Include=".editorconfig" />
</ItemGroup>
</Project>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ShowAllFiles>true</ShowAllFiles>
</PropertyGroup>
</Project>

View File

@@ -3,7 +3,7 @@
# chosen value in case the base style changes (last sync: Clang 6.0.1).
---
### General config, applies to all languages ###
BasedOnStyle: LLVM
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
# AlignConsecutiveAssignments: false
@@ -13,9 +13,9 @@ AlignAfterOpenBracket: DontAlign
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
# AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
# AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: true
# AllowShortIfStatementsOnASingleLine: false
# AllowShortLoopsOnASingleLine: false
# AlwaysBreakAfterDefinitionReturnType: None
# AlwaysBreakAfterReturnType: None
@@ -46,7 +46,7 @@ BreakBeforeTernaryOperators: false
# BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
# BreakStringLiterals: true
ColumnLimit: 0
ColumnLimit: 0
# CommentPragmas: '^ IWYU pragma:'
# CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
@@ -63,20 +63,20 @@ Cpp11BracedListStyle: false
# - BOOST_FOREACH
# IncludeBlocks: Preserve
IncludeCategories:
- Regex: '".*"'
Priority: 1
- Regex: '^<.*\.h>'
Priority: 2
- Regex: '^<.*'
Priority: 3
- Regex: '".*"'
Priority: 1
- Regex: '^<.*\.h>'
Priority: 2
- Regex: "^<.*"
Priority: 3
# IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: true
# IndentPPDirectives: None
IndentWidth: 4
IndentWidth: 4
# IndentWrappedFunctionNames: false
# JavaScriptQuotes: Leave
# JavaScriptWrapImports: true
# KeepEmptyLinesAtTheStartOfBlocks: true
KeepEmptyLinesAtTheStartOfBlocks: false
# MacroBlockBegin: ''
# MacroBlockEnd: ''
# MaxEmptyLinesToKeep: 1
@@ -94,7 +94,7 @@ IndentWidth: 4
# Language: TextProto
# BasedOnStyle: google
# ReflowComments: true
# SortIncludes: true
SortIncludes: false
# SortUsingDeclarations: true
# SpaceAfterCStyleCast: false
# SpaceAfterTemplateKeyword: true
@@ -107,21 +107,30 @@ IndentWidth: 4
# SpacesInCStyleCastParentheses: false
# SpacesInParentheses: false
# SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Always
TabWidth: 4
UseTab: Always
---
### C++ specific config ###
Language: Cpp
Standard: Cpp03
Language: Cpp
Standard: Cpp11
---
### ObjC specific config ###
Language: ObjC
Standard: Cpp03
Language: ObjC
Standard: Cpp11
ObjCBlockIndentWidth: 4
# ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: true
---
### Java specific config ###
Language: Java
Language: Java
# BreakAfterJavaFieldAnnotations: false
...
JavaImportGroups:
[
"org.godotengine",
"android",
"androidx",
"com.android",
"com.google",
"java",
"javax",
]

View File

@@ -1,9 +0,0 @@
#ifndef ALLOCATION_DEF_H
#define ALLOCATION_DEF_H
#define memnew(m_Class) new m_Class()
// NULL objects are not being handled to discourage lazy destruction of objects
#define memdelete(m_pointer) m_pointer ? WARN_PRINT("Git API tried to delete a NULL object") : delete m_pointer;
#endif // !ALLOCATION_DEF_H

View File

@@ -1,23 +1,31 @@
#include "git_api.h"
#include "git_plugin.h"
#include <Godot.hpp>
#include "godot_cpp/core/class_db.hpp"
#include "godot_cpp/godot.hpp"
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
void initialize_git_plugin_module(godot::ModuleInitializationLevel p_level) {
if (p_level != godot::MODULE_INITIALIZATION_LEVEL_EDITOR) {
return;
}
godot::Godot::gdnative_init(o);
godot::ClassDB::register_class<GitPlugin>();
}
extern "C" void GDN_EXPORT godot_gdnative_singleton(godot_gdnative_init_options *o) {
void uninitialize_git_plugin_module(godot::ModuleInitializationLevel p_level) {
if (p_level != godot::MODULE_INITIALIZATION_LEVEL_EDITOR) {
return;
}
}
extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) {
extern "C" {
godot::Godot::gdnative_terminate(o);
GDExtensionBool GDE_EXPORT git_plugin_init(const GDExtensionInterfaceGetProcAddress p_address, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
godot::GDExtensionBinding::InitObject init_obj(p_address, p_library, r_initialization);
init_obj.register_initializer(initialize_git_plugin_module);
init_obj.register_terminator(uninitialize_git_plugin_module);
init_obj.set_minimum_library_initialization_level(godot::MODULE_INITIALIZATION_LEVEL_EDITOR);
return init_obj.init();
}
extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
godot::Godot::nativescript_init(handle);
godot::register_tool_class<godot::GitAPI>();
}

View File

@@ -1,314 +0,0 @@
#include "git_api.h"
namespace godot {
GitAPI *GitAPI::singleton = NULL;
void GitAPI::_register_methods() {
register_method("_process", &GitAPI::_process);
register_method("_commit", &GitAPI::_commit);
register_method("_is_vcs_initialized", &GitAPI::_is_vcs_initialized);
register_method("_get_modified_files_data", &GitAPI::_get_modified_files_data);
register_method("_get_file_diff", &GitAPI::_get_file_diff);
register_method("_get_project_name", &GitAPI::_get_project_name);
register_method("_get_vcs_name", &GitAPI::_get_vcs_name);
register_method("_initialize", &GitAPI::_initialize);
register_method("_shut_down", &GitAPI::_shut_down);
register_method("_stage_file", &GitAPI::_stage_file);
register_method("_unstage_file", &GitAPI::_unstage_file);
}
void GitAPI::_commit(const String p_msg) {
git_signature *default_sign;
git_oid tree_id, parent_commit_id, new_commit_id;
git_tree *tree;
git_index *repo_index;
git_commit *parent_commit;
GIT2_CALL(git_repository_index(&repo_index, repo), "Could not get repository index", NULL);
for (int i = 0; i < staged_files.size(); i++) {
String file_path = ((String)staged_files[i]);
File *file = File::_new();
if (file->file_exists(file_path)) {
GIT2_CALL(git_index_add_bypath(repo_index, file_path.alloc_c_string()), "Could not add file by path", NULL);
} else {
GIT2_CALL(git_index_remove_bypath(repo_index, file_path.alloc_c_string()), "Could not add file by path", NULL);
}
}
GIT2_CALL(git_index_write_tree(&tree_id, repo_index), "Could not write index to tree", NULL);
GIT2_CALL(git_index_write(repo_index), "Could not write index to disk", NULL);
GIT2_CALL(git_signature_default(&default_sign, repo), "Could not get default signature", NULL);
GIT2_CALL(git_tree_lookup(&tree, repo, &tree_id), "Could not lookup tree from ID", NULL);
GIT2_CALL(git_reference_name_to_id(&parent_commit_id, repo, "HEAD"), "Could not get parent ID", NULL);
GIT2_CALL(git_commit_lookup(&parent_commit, repo, &parent_commit_id), "Could not lookup parent commit data", NULL);
GIT2_CALL(
git_commit_create_v(
&new_commit_id,
repo,
"HEAD",
default_sign,
default_sign,
"UTF-8",
p_msg.alloc_c_string(),
tree,
1,
parent_commit),
"Could not create commit",
NULL);
staged_files.clear();
git_index_free(repo_index);
git_signature_free(default_sign);
git_commit_free(parent_commit);
git_tree_free(tree);
}
void GitAPI::_stage_file(const String p_file_path) {
if (staged_files.find(p_file_path) == -1) {
staged_files.push_back(p_file_path);
}
}
void GitAPI::_unstage_file(const String p_file_path) {
if (staged_files.find(p_file_path) != -1) {
staged_files.erase(p_file_path);
}
}
void GitAPI::create_gitignore_and_gitattributes() {
File *file = File::_new();
if (!file->file_exists("res://.gitignore")) {
file->open("res://.gitignore", File::ModeFlags::WRITE);
file->store_string(
"# Import cache\n"
".import/\n\n"
"# Binaries\n"
"bin/\n"
"build/\n"
"lib/\n"
);
file->close();
}
if (!file->file_exists("res://.gitattributes")) {
file->open("res://.gitattributes", File::ModeFlags::WRITE);
file->store_string(
"# Set the default behavior, in case people don't have core.autocrlf set.\n"
"* text=auto\n\n"
"# Explicitly declare text files you want to always be normalized and converted\n"
"# to native line endings on checkout.\n"
"*.cpp text\n"
"*.c text\n"
"*.h text\n"
"*.gd text\n"
"*.cs text\n\n"
"# Declare files that will always have CRLF line endings on checkout.\n"
"*.sln text eol=crlf\n\n"
"# Denote all files that are truly binary and should not be modified.\n"
"*.png binary\n"
"*.jpg binary\n");
file->close();
}
}
void GitAPI::create_initial_commit() {
git_signature *sig;
git_oid tree_id, commit_id;
git_index *repo_index;
git_tree *tree;
GIT2_CALL(git_signature_default(&sig, repo), "Unable to create a commit signature. Perhaps 'user.name' and 'user.email' are not set", NULL);
GIT2_CALL(git_repository_index(&repo_index, repo), "Could not get repository index", NULL);
GIT2_CALL(git_index_write_tree(&tree_id, repo_index), "Could not create intial commit", NULL);
GIT2_CALL(git_tree_lookup(&tree, repo, &tree_id), "Could not create intial commit", NULL);
GIT2_CALL(
git_commit_create_v(
&commit_id,
repo,
"HEAD",
sig,
sig,
NULL,
"Initial commit",
tree,
0
),
"Could not create the initial commit",
NULL);
GIT2_CALL(git_index_write(repo_index), "Could not write index to disk", NULL);
git_index_free(repo_index);
git_tree_free(tree);
git_signature_free(sig);
}
bool GitAPI::_is_vcs_initialized() {
return is_initialized;
}
Dictionary GitAPI::_get_modified_files_data() {
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
opts.flags = GIT_STATUS_OPT_EXCLUDE_SUBMODULES;
opts.flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED | GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX | GIT_STATUS_OPT_SORT_CASE_SENSITIVELY | GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS;
git_status_list *statuses = NULL;
GIT2_CALL(git_status_list_new(&statuses, repo, &opts), "Could not get status information from repository", NULL);
Dictionary diff; // Schema is <file_path, status>
size_t count = git_status_list_entrycount(statuses);
for (size_t i = 0; i < count; ++i) {
const git_status_entry *entry = git_status_byindex(statuses, i);
String path;
if (entry->index_to_workdir) {
path = entry->index_to_workdir->new_file.path;
} else {
path = entry->head_to_index->new_file.path;
}
switch (entry->status) {
case GIT_STATUS_INDEX_NEW:
case GIT_STATUS_WT_NEW: {
diff[path] = 0;
} break;
case GIT_STATUS_INDEX_MODIFIED:
case GIT_STATUS_WT_MODIFIED: {
diff[path] = 1;
} break;
case GIT_STATUS_INDEX_RENAMED:
case GIT_STATUS_WT_RENAMED: {
diff[path] = 2;
} break;
case GIT_STATUS_INDEX_DELETED:
case GIT_STATUS_WT_DELETED: {
diff[path] = 3;
} break;
case GIT_STATUS_INDEX_TYPECHANGE:
case GIT_STATUS_WT_TYPECHANGE: {
diff[path] = 4;
} break;
}
}
git_status_list_free(statuses);
return diff;
}
Array GitAPI::_get_file_diff(const String file_path) {
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
git_diff *diff;
char *pathspec = file_path.alloc_c_string();
opts.context_lines = 3;
opts.interhunk_lines = 0;
opts.flags = GIT_DIFF_DISABLE_PATHSPEC_MATCH | GIT_DIFF_INCLUDE_UNTRACKED;
opts.pathspec.strings = &pathspec;
opts.pathspec.count = 1;
GIT2_CALL(git_diff_index_to_workdir(&diff, repo, NULL, &opts), "Could not create diff for index from working directory", NULL);
diff_contents.clear();
GIT2_CALL(git_diff_print(diff, GIT_DIFF_FORMAT_PATCH, diff_line_callback_function, NULL), "Call to diff handler provided unsuccessful", NULL);
git_diff_free(diff);
return diff_contents;
}
String GitAPI::_get_project_name() {
return String("project");
}
String GitAPI::_get_vcs_name() {
return "Git";
}
bool GitAPI::_initialize(const String p_project_root_path) {
ERR_FAIL_COND_V(p_project_root_path == "", false);
singleton = this;
int init = git_libgit2_init();
if (init > 1) {
WARN_PRINT("Multiple libgit2 instances are running");
}
if (repo) {
return true;
}
GIT2_CALL(git_repository_init(&repo, p_project_root_path.alloc_c_string(), 0), "Could not initialize repository", NULL);
if (git_repository_head_unborn(repo) == 1) {
create_gitignore_and_gitattributes();
create_initial_commit();
}
GIT2_CALL(git_repository_open(&repo, p_project_root_path.alloc_c_string()), "Could not open repository", NULL);
is_initialized = true;
return is_initialized;
}
bool GitAPI::_shut_down() {
git_repository_free(repo);
GIT2_CALL(git_libgit2_shutdown(), "Could not shutdown Git Addon", NULL);
return true;
}
void GitAPI::_init() {
}
void GitAPI::_process() {
}
GitAPI::GitAPI() {
}
GitAPI::~GitAPI() {
}
} // namespace godot

View File

@@ -1,64 +0,0 @@
#ifndef GIT_API_H
#define GIT_API_H
#include <Godot.hpp>
#include <Button.hpp>
#include <Control.hpp>
#include <EditorVCSInterface.hpp>
#include <PanelContainer.hpp>
#include <Directory.hpp>
#include <File.hpp>
#include <git_common.h>
#include <allocation_defs.h>
#include <git2.h>
namespace godot {
class GitAPI : public EditorVCSInterface {
GODOT_CLASS(GitAPI, EditorVCSInterface)
static GitAPI *singleton;
bool is_initialized;
Array staged_files;
PanelContainer *init_settings_panel_container;
Button *init_settings_button;
git_repository *repo;
void _commit(const String p_msg);
bool _is_vcs_initialized();
Dictionary _get_modified_files_data();
Array _get_file_diff(const String file_path);
String _get_project_name();
String _get_vcs_name();
bool _initialize(const String p_project_root_path);
bool _shut_down();
void _stage_file(const String p_file_path);
void _unstage_file(const String p_file_path);
public:
static void _register_methods();
static GitAPI *get_singleton() { return singleton; }
Array diff_contents;
void create_gitignore_and_gitattributes();
void create_initial_commit();
void _init();
void _process();
GitAPI();
~GitAPI();
};
} // namespace godot
#endif // !GIT_API_H

View File

@@ -0,0 +1,109 @@
#include <iostream>
#include <cstring>
#include "git_callbacks.h"
#include "git_plugin.h"
#include "godot_cpp/godot.hpp"
#include "godot_cpp/variant/utility_functions.hpp"
extern "C" int progress_cb(const char *str, int len, void *data) {
(void)data;
godot::UtilityFunctions::print("remote: ", godot::String::utf8(str, len).strip_edges());
return 0;
}
extern "C" int update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data) {
constexpr int short_commit_length = 8;
char a_str[short_commit_length + 1];
char b_str[short_commit_length + 1];
(void)data;
git_oid_tostr(b_str, short_commit_length, b);
if (git_oid_is_zero(a)) {
godot::UtilityFunctions::print("* [new] ", godot::String::utf8(b_str), " ", godot::String::utf8(refname));
} else {
git_oid_tostr(a_str, short_commit_length, a);
godot::UtilityFunctions::print("[updated] ", godot::String::utf8(a_str), "...", godot::String::utf8(b_str), " ", godot::String::utf8(refname));
}
return 0;
}
extern "C" int transfer_progress_cb(const git_indexer_progress *stats, void *payload) {
(void)payload;
if (stats->received_objects == stats->total_objects) {
godot::UtilityFunctions::print("Resolving deltas ", uint32_t(stats->indexed_deltas), "/", uint32_t(stats->total_deltas));
} else if (stats->total_objects > 0) {
godot::UtilityFunctions::print(
"Received ", uint32_t(stats->received_objects), "/", uint32_t(stats->total_objects),
" objects (", uint32_t(stats->indexed_objects), ") in ", uint32_t(stats->received_bytes), " bytes");
}
return 0;
}
extern "C" int fetchhead_foreach_cb(const char *ref_name, const char *remote_url, const git_oid *oid, unsigned int is_merge, void *payload) {
if (is_merge) {
git_oid_cpy((git_oid *)payload, oid);
}
return 0;
}
extern "C" int push_transfer_progress_cb(unsigned int current, unsigned int total, size_t bytes, void *payload) {
int64_t progress = 100;
if (total != 0) {
progress = (current * 100) / total;
}
godot::UtilityFunctions::print("Writing Objects: ", uint32_t(progress), "% (", uint32_t(current), "/", uint32_t(total), ", ", uint32_t(bytes), " bytes done.)");
return 0;
}
extern "C" int push_update_reference_cb(const char *refname, const char *status, void *data) {
if (status != NULL) {
godot::String status_str = godot::String::utf8(status);
godot::UtilityFunctions::print("[rejected] ", godot::String::utf8(refname), " ", status_str);
} else {
godot::UtilityFunctions::print("[updated] ", godot::String::utf8(refname));
}
return 0;
}
extern "C" int credentials_cb(git_cred **out, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload) {
Credentials *creds = (Credentials *)payload;
godot::String proper_username = username_from_url ? username_from_url : creds->username;
if (!creds->ssh_public_key_path.is_empty()) {
if (allowed_types & GIT_CREDENTIAL_SSH_KEY) {
return git_credential_ssh_key_new(out,
CString(proper_username).data,
CString(creds->ssh_public_key_path).data,
CString(creds->ssh_private_key_path).data,
CString(creds->ssh_passphrase).data);
}
}
if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT) {
return git_cred_userpass_plaintext_new(out, CString(proper_username).data, CString(creds->password).data);
}
if (allowed_types & GIT_CREDENTIAL_USERNAME) {
return git_credential_username_new(out, CString(proper_username).data);
}
return GIT_EUSER;
}
extern "C" int diff_hunk_cb(const git_diff_delta *delta, const git_diff_hunk *range, void *payload) {
DiffHelper *diff_helper = (DiffHelper *)payload;
godot::Dictionary hunk = diff_helper->git_plugin->create_diff_hunk(range->old_start, range->new_start, range->old_lines, range->new_lines);
diff_helper->diff_hunks->push_back(hunk);
return 1;
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "godot_cpp/variant/array.hpp"
#include "git2.h"
class GitPlugin;
struct DiffHelper {
godot::Array *diff_hunks;
GitPlugin *git_plugin;
};
extern "C" int progress_cb(const char *str, int len, void *data);
extern "C" int update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data);
extern "C" int transfer_progress_cb(const git_indexer_progress *stats, void *payload);
extern "C" int fetchhead_foreach_cb(const char *ref_name, const char *remote_url, const git_oid *oid, unsigned int is_merge, void *payload);
extern "C" int credentials_cb(git_cred **out, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload);
extern "C" int push_transfer_progress_cb(unsigned int current, unsigned int total, size_t bytes, void *payload);
extern "C" int push_update_reference_cb(const char *refname, const char *status, void *data);
extern "C" int diff_hunk_cb(const git_diff_delta *delta, const git_diff_hunk *range, void *payload);

View File

@@ -1,62 +0,0 @@
#include <git_common.h>
#include <git_api.h>
void check_git2_errors(int error, const char *message, const char *extra) {
const git_error *lg2err;
const char *lg2msg = "", *lg2spacer = "";
if (!error) {
return;
}
if ((lg2err = git_error_last()) != NULL && lg2err->message != NULL) {
lg2msg = lg2err->message;
lg2spacer = " - ";
}
if (extra) {
printf("Git API: %s '%s' [%d]%s%s\n", message, extra, error, lg2spacer, lg2msg);
} else {
printf("Git API: %s [%d]%s%s\n", message, error, lg2spacer, lg2msg);
}
}
extern "C" int diff_line_callback_function(const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, void *payload) {
// First we NULL terminate the line text incoming
char *content = new char[line->content_len + 1];
memcpy(content, line->content, line->content_len);
static int i = 0;
content[line->content_len] = '\0';
godot::String prefix = "";
switch (line->origin) {
case GIT_DIFF_LINE_DEL_EOFNL:
case GIT_DIFF_LINE_DELETION:
prefix = "-"; break;
case GIT_DIFF_LINE_ADD_EOFNL:
case GIT_DIFF_LINE_ADDITION:
prefix = "+"; break;
}
godot::String content_str = content;
godot::Dictionary result;
result["content"] = prefix + content_str;
result["status"] = prefix;
result["new_line_number"] = line->new_lineno;
result["line_count"] = line->num_lines;
result["old_line_number"] = line->old_lineno;
result["offset"] = line->content_offset;
godot::GitAPI::get_singleton()->diff_contents.push_back(result);
return 0;
}

View File

@@ -1,14 +0,0 @@
#ifndef GIT_COMMON_H
#define GIT_COMMON_H
#include <Godot.hpp>
#include <git2.h>
void check_git2_errors(int error, const char *message, const char *extra);
extern "C" int diff_line_callback_function(const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, void *payload);
#define GIT2_CALL(function_call, m_error_msg, m_additional_msg) check_git2_errors(function_call, m_error_msg, m_additional_msg);
#endif // !GIT_COMMON_H

View File

@@ -0,0 +1,711 @@
#include "git_plugin.h"
#include <cstring>
#include <git2/tree.h>
#include "godot_cpp/core/class_db.hpp"
#include "godot_cpp/classes/file_access.hpp"
#include "godot_cpp/variant/utility_functions.hpp"
#define GIT2_CALL(error, msg) \
if (check_errors(error, __FUNCTION__, __FILE__, __LINE__, msg)) { \
return; \
}
#define GIT2_CALL_R(error, msg, return_value) \
if (check_errors(error, __FUNCTION__, __FILE__, __LINE__, msg)) { \
return return_value; \
}
#define GIT2_CALL_IGNORE(error, msg, ignores) \
if (check_errors(error, __FUNCTION__, __FILE__, __LINE__, msg, ignores)) { \
return; \
}
#define GIT2_CALL_R_IGNORE(error, msg, return_value, ignores) \
if (check_errors(error, __FUNCTION__, __FILE__, __LINE__, msg, ignores)) { \
return return_value; \
}
#define COMMA ,
void GitPlugin::_bind_methods() {
// Doesn't seem to require binding functions for now
}
GitPlugin::GitPlugin() {
map_changes[GIT_STATUS_WT_NEW] = CHANGE_TYPE_NEW;
map_changes[GIT_STATUS_INDEX_NEW] = CHANGE_TYPE_NEW;
map_changes[GIT_STATUS_WT_MODIFIED] = CHANGE_TYPE_MODIFIED;
map_changes[GIT_STATUS_INDEX_MODIFIED] = CHANGE_TYPE_MODIFIED;
map_changes[GIT_STATUS_WT_RENAMED] = CHANGE_TYPE_RENAMED;
map_changes[GIT_STATUS_INDEX_RENAMED] = CHANGE_TYPE_RENAMED;
map_changes[GIT_STATUS_WT_DELETED] = CHANGE_TYPE_DELETED;
map_changes[GIT_STATUS_INDEX_DELETED] = CHANGE_TYPE_DELETED;
map_changes[GIT_STATUS_WT_TYPECHANGE] = CHANGE_TYPE_TYPECHANGE;
map_changes[GIT_STATUS_INDEX_TYPECHANGE] = CHANGE_TYPE_TYPECHANGE;
map_changes[GIT_STATUS_CONFLICTED] = CHANGE_TYPE_UNMERGED;
}
bool GitPlugin::check_errors(int error, godot::String function, godot::String file, int line, godot::String message, const std::vector<git_error_code> &ignores) {
const git_error *lg2err;
if (error == 0) {
return false;
}
for (auto &ig : ignores) {
if (error == ig) {
return false;
}
}
message = message + ".";
if ((lg2err = git_error_last()) != nullptr && lg2err->message != nullptr) {
message = message + " Error " + godot::String::num_int64(error) + ": ";
message = message + godot::String::utf8(lg2err->message);
}
godot::UtilityFunctions::push_error("GitPlugin: ", message, " in ", file, ":", function, "#L", line);
return true;
}
void GitPlugin::_set_credentials(const godot::String &username, const godot::String &password, const godot::String &ssh_public_key_path, const godot::String &ssh_private_key_path, const godot::String &ssh_passphrase) {
creds.username = username;
creds.password = password;
creds.ssh_public_key_path = ssh_public_key_path;
creds.ssh_private_key_path = ssh_private_key_path;
creds.ssh_passphrase = ssh_passphrase;
}
void GitPlugin::_discard_file(const godot::String &file_path) {
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
CString c_path(file_path);
char *paths[] = { c_path.data };
opts.paths = { paths, 1 };
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
GIT2_CALL(git_checkout_index(repo.get(), nullptr, &opts), "Could not checkout index");
}
void GitPlugin::_commit(const godot::String &msg) {
git_index_ptr repo_index;
GIT2_CALL(git_repository_index(Capture(repo_index), repo.get()), "Could not get repository index");
git_oid tree_id;
GIT2_CALL(git_index_write_tree(&tree_id, repo_index.get()), "Could not write index to tree");
GIT2_CALL(git_index_write(repo_index.get()), "Could not write index to disk");
git_tree_ptr tree;
GIT2_CALL(git_tree_lookup(Capture(tree), repo.get(), &tree_id), "Could not lookup tree from ID");
git_signature_ptr default_sign;
GIT2_CALL(git_signature_default(Capture(default_sign), repo.get()), "Could not get default signature");
git_oid parent_commit_id = {};
GIT2_CALL_IGNORE(git_reference_name_to_id(&parent_commit_id, repo.get(), "HEAD"), "Could not get repository HEAD", { GIT_ENOTFOUND });
git_commit_ptr parent_commit;
if (!git_oid_is_zero(&parent_commit_id)) {
GIT2_CALL(git_commit_lookup(Capture(parent_commit), repo.get(), &parent_commit_id), "Could not lookup parent commit data");
}
git_oid new_commit_id;
if (!has_merge) {
GIT2_CALL(
git_commit_create_v(
&new_commit_id,
repo.get(),
"HEAD",
default_sign.get(),
default_sign.get(),
"UTF-8",
CString(msg).data,
tree.get(),
parent_commit.get() ? 1 : 0,
parent_commit.get()),
"Could not create commit");
} else {
git_commit_ptr fetchhead_commit;
GIT2_CALL(git_commit_lookup(Capture(fetchhead_commit), repo.get(), &pull_merge_oid), "Could not lookup commit pointed to by HEAD");
GIT2_CALL(
git_commit_create_v(
&new_commit_id,
repo.get(),
"HEAD",
default_sign.get(),
default_sign.get(),
"UTF-8",
CString(msg).data,
tree.get(),
2,
parent_commit.get(),
fetchhead_commit.get()),
"Could not create merge commit");
has_merge = false;
GIT2_CALL(git_repository_state_cleanup(repo.get()), "Could not clean repository state");
}
}
void GitPlugin::_stage_file(const godot::String &file_path) {
CString c_path(file_path);
char *paths[] = { c_path.data };
git_strarray array = { paths, 1 };
git_index_ptr index;
GIT2_CALL(git_repository_index(Capture(index), repo.get()), "Could not get repository index");
GIT2_CALL(git_index_add_all(index.get(), &array, GIT_INDEX_ADD_DEFAULT | GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH, nullptr, nullptr), "Could not add " + file_path + " to index");
GIT2_CALL(git_index_write(index.get()), "Could not write changes to disk");
}
void GitPlugin::_unstage_file(const godot::String &file_path) {
CString c_path(file_path);
char *paths[] = { c_path.data };
git_strarray array = { paths, 1 };
git_reference_ptr head;
GIT2_CALL_IGNORE(git_repository_head(Capture(head), repo.get()), "Could not find repository HEAD", { GIT_ENOTFOUND COMMA GIT_EUNBORNBRANCH });
if (head) {
git_object_ptr head_commit;
GIT2_CALL(git_reference_peel(Capture(head_commit), head.get(), GIT_OBJ_COMMIT), "Could not peel HEAD reference");
GIT2_CALL(git_reset_default(repo.get(), head_commit.get(), &array), "Could not reset " + file_path + " to state at HEAD");
} else {
// If there is no HEAD commit, we should just remove the file from the index.
CString c_path(file_path);
git_index_ptr index;
GIT2_CALL(git_repository_index(Capture(index), repo.get()), "Could not get repository index");
GIT2_CALL(git_index_remove_bypath(index.get(), c_path.data), "Could not add " + file_path + " to index");
GIT2_CALL(git_index_write(index.get()), "Could not write changes to disk");
}
}
void GitPlugin::create_gitignore_and_gitattributes() {
if (!godot::FileAccess::file_exists(repo_project_path + "/.gitignore")) {
godot::Ref<godot::FileAccess> file = godot::FileAccess::open(repo_project_path + "/.gitignore", godot::FileAccess::ModeFlags::WRITE);
ERR_FAIL_COND(file.is_null());
file->store_string(
"# Godot 4+ specific ignores\n"
".godot/\n");
}
if (!godot::FileAccess::file_exists(repo_project_path + "/.gitattributes")) {
godot::Ref<godot::FileAccess> file = godot::FileAccess::open(repo_project_path + "/.gitattributes", godot::FileAccess::ModeFlags::WRITE);
ERR_FAIL_COND(file.is_null());
file->store_string(
"# Set the default behavior, in case people don't have core.autocrlf set.\n"
"* text=auto\n\n"
"# Explicitly declare text files you want to always be normalized and converted\n"
"# to native line endings on checkout.\n"
"*.cpp text\n"
"*.c text\n"
"*.h text\n"
"*.gd text\n"
"*.cs text\n\n"
"# Declare files that will always have CRLF line endings on checkout.\n"
"*.sln text eol=crlf\n\n"
"# Denote all files that are truly binary and should not be modified.\n"
"*.png binary\n"
"*.jpg binary\n");
}
}
godot::TypedArray<godot::Dictionary> GitPlugin::_get_modified_files_data() {
godot::TypedArray<godot::Dictionary> stats_files;
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
opts.flags = GIT_STATUS_OPT_EXCLUDE_SUBMODULES;
opts.flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED | GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX | GIT_STATUS_OPT_SORT_CASE_SENSITIVELY | GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS;
git_status_list_ptr statuses;
GIT2_CALL_R(git_status_list_new(Capture(statuses), repo.get(), &opts), "Could not get status information from repository", godot::TypedArray<godot::Dictionary>());
size_t count = git_status_list_entrycount(statuses.get());
for (size_t i = 0; i < count; ++i) {
const git_status_entry *entry = git_status_byindex(statuses.get(), i);
godot::String path;
if (entry->index_to_workdir) {
path = godot::String::utf8(entry->index_to_workdir->new_file.path);
} else {
path = godot::String::utf8(entry->head_to_index->new_file.path);
}
const static int git_status_wt = GIT_STATUS_WT_NEW | GIT_STATUS_WT_MODIFIED | GIT_STATUS_WT_DELETED | GIT_STATUS_WT_TYPECHANGE | GIT_STATUS_WT_RENAMED | GIT_STATUS_CONFLICTED;
const static int git_status_index = GIT_STATUS_INDEX_NEW | GIT_STATUS_INDEX_MODIFIED | GIT_STATUS_INDEX_DELETED | GIT_STATUS_INDEX_RENAMED | GIT_STATUS_INDEX_TYPECHANGE;
if (entry->status & git_status_wt) {
stats_files.push_back(create_status_file(path, map_changes[git_status_t(entry->status & git_status_wt)], TREE_AREA_UNSTAGED));
}
if (entry->status & git_status_index) {
if (entry->status & GIT_STATUS_INDEX_RENAMED) {
godot::String old_path = godot::String::utf8(entry->head_to_index->old_file.path);
stats_files.push_back(create_status_file(old_path, map_changes.at(GIT_STATUS_INDEX_DELETED), TREE_AREA_STAGED));
stats_files.push_back(create_status_file(path, map_changes.at(GIT_STATUS_INDEX_NEW), TREE_AREA_STAGED));
} else {
stats_files.push_back(create_status_file(path, map_changes.at(git_status_t(entry->status & git_status_index)), TREE_AREA_STAGED));
}
}
}
return stats_files;
}
godot::TypedArray<godot::String> GitPlugin::_get_branch_list() {
git_branch_iterator_ptr it;
GIT2_CALL_R(git_branch_iterator_new(Capture(it), repo.get(), GIT_BRANCH_LOCAL), "Could not create branch iterator", godot::TypedArray<godot::Dictionary>());
godot::TypedArray<godot::String> branch_names;
git_reference_ptr ref;
git_branch_t type;
while (git_branch_next(Capture(ref), &type, it.get()) != GIT_ITEROVER) {
const char *name = nullptr;
GIT2_CALL_R(git_branch_name(&name, ref.get()), "Could not get branch name", godot::TypedArray<godot::String>());
if (git_branch_is_head(ref.get())) {
// Always send the current branch as the first branch in list
branch_names.push_front(godot::String::utf8(name));
} else {
branch_names.push_back(godot::String::utf8(name));
}
}
return branch_names;
}
void GitPlugin::_create_branch(const godot::String &branch_name) {
git_oid head_commit_id;
GIT2_CALL(git_reference_name_to_id(&head_commit_id, repo.get(), "HEAD"), "Could not get HEAD commit ID");
git_commit_ptr head_commit;
GIT2_CALL(git_commit_lookup(Capture(head_commit), repo.get(), &head_commit_id), "Could not lookup HEAD commit");
git_reference_ptr branch_ref;
GIT2_CALL(git_branch_create(Capture(branch_ref), repo.get(), CString(branch_name).data, head_commit.get(), 0), "Could not create branch from HEAD");
}
void GitPlugin::_create_remote(const godot::String &remote_name, const godot::String &remote_url) {
git_remote_ptr remote;
GIT2_CALL(git_remote_create(Capture(remote), repo.get(), CString(remote_name).data, CString(remote_url).data), "Could not create remote");
}
void GitPlugin::_remove_branch(const godot::String &branch_name) {
git_reference_ptr branch;
GIT2_CALL(git_branch_lookup(Capture(branch), repo.get(), CString(branch_name).data, GIT_BRANCH_LOCAL), "Could not find branch " + branch_name);
GIT2_CALL(git_branch_delete(branch.get()), "Could not delete branch reference of " + branch_name);
}
void GitPlugin::_remove_remote(const godot::String &remote_name) {
GIT2_CALL(git_remote_delete(repo.get(), CString(remote_name).data), "Could not delete remote " + remote_name);
}
godot::TypedArray<godot::Dictionary> GitPlugin::_get_line_diff(const godot::String &file_path, const godot::String &text) {
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
opts.context_lines = 0;
opts.flags = GIT_DIFF_DISABLE_PATHSPEC_MATCH | GIT_DIFF_INCLUDE_UNTRACKED;
git_index_ptr index;
GIT2_CALL_R(git_repository_index(Capture(index), repo.get()), "Failed to get repository index", godot::TypedArray<godot::Dictionary>());
GIT2_CALL_R(git_index_read(index.get(), 0), "Failed to read index", godot::TypedArray<godot::Dictionary>());
const git_index_entry *entry = git_index_get_bypath(index.get(), CString(file_path).data, GIT_INDEX_STAGE_NORMAL);
if (!entry) {
return godot::TypedArray<godot::Dictionary>();
}
git_reference_ptr head;
GIT2_CALL_R(git_repository_head(Capture(head), repo.get()), "Failed to load repository head", godot::TypedArray<godot::Dictionary>());
git_blob_ptr blob;
GIT2_CALL_R(git_blob_lookup(Capture(blob), repo.get(), &entry->id), "Failed to load head blob", godot::TypedArray<godot::Dictionary>());
godot::TypedArray<godot::Dictionary> diff_contents;
DiffHelper diff_helper = { &diff_contents, this };
GIT2_CALL_R(git_diff_blob_to_buffer(blob.get(), nullptr, CString(text).data, text.length(), nullptr, &opts, nullptr, nullptr, diff_hunk_cb, nullptr, &diff_helper), "Failed to make diff", godot::TypedArray<godot::Dictionary>());
return diff_contents;
}
godot::String GitPlugin::_get_current_branch_name() {
git_reference_ptr head;
GIT2_CALL_R_IGNORE(git_repository_head(Capture(head), repo.get()), "Could not find repository HEAD", "", { GIT_ENOTFOUND COMMA GIT_EUNBORNBRANCH });
if (!head) {
// We are likely at a state where the initial commit hasn't been made yet.
return "";
}
git_reference_ptr branch;
GIT2_CALL_R(git_reference_resolve(Capture(branch), head.get()), "Could not resolve HEAD reference", "");
const char *name = "";
GIT2_CALL_R(git_branch_name(&name, branch.get()), "Could not get branch name from current branch reference", "");
return godot::String::utf8(name);
}
godot::TypedArray<godot::String> GitPlugin::_get_remotes() {
git_strarray remote_array;
GIT2_CALL_R(git_remote_list(&remote_array, repo.get()), "Could not get list of remotes", godot::TypedArray<godot::Dictionary>());
godot::TypedArray<godot::String> remotes;
for (int i = 0; i < remote_array.count; i++) {
remotes.push_back(godot::String::utf8(remote_array.strings[i]));
}
return remotes;
}
godot::TypedArray<godot::Dictionary> GitPlugin::_get_previous_commits(int32_t max_commits) {
git_revwalk_ptr walker;
GIT2_CALL_R(git_revwalk_new(Capture(walker), repo.get()), "Could not create new revwalk", godot::TypedArray<godot::Dictionary>());
GIT2_CALL_R(git_revwalk_sorting(walker.get(), GIT_SORT_TIME), "Could not sort revwalk by time", godot::TypedArray<godot::Dictionary>());
GIT2_CALL_R_IGNORE(git_revwalk_push_head(walker.get()), "Could not push HEAD to revwalk", godot::TypedArray<godot::Dictionary>(), { GIT_ENOTFOUND COMMA GIT_ERROR });
git_oid oid;
godot::TypedArray<godot::Dictionary> commits;
char commit_id[GIT_OID_HEXSZ + 1];
for (int i = 0; !git_revwalk_next(&oid, walker.get()) && i <= max_commits; i++) {
git_commit_ptr commit;
GIT2_CALL_R(git_commit_lookup(Capture(commit), repo.get(), &oid), "Failed to lookup the commit", commits);
git_oid_tostr(commit_id, GIT_OID_HEXSZ + 1, git_commit_id(commit.get()));
godot::String msg = godot::String::utf8(git_commit_message(commit.get()));
const git_signature *sig = git_commit_author(commit.get());
godot::String author = godot::String::utf8(sig->name) + " <" + godot::String::utf8(sig->email) + ">";
commits.push_back(create_commit(msg, author, commit_id, sig->when.time, sig->when.offset));
}
return commits;
}
void GitPlugin::_fetch(const godot::String &remote) {
godot::UtilityFunctions::print("GitPlugin: Performing fetch from ", remote);
git_remote_ptr remote_object;
GIT2_CALL(git_remote_lookup(Capture(remote_object), repo.get(), CString(remote).data), "Could not lookup remote \"" + remote + "\"");
git_remote_callbacks remote_cbs = GIT_REMOTE_CALLBACKS_INIT;
remote_cbs.credentials = &credentials_cb;
remote_cbs.update_tips = &update_cb;
remote_cbs.sideband_progress = &progress_cb;
remote_cbs.transfer_progress = &transfer_progress_cb;
remote_cbs.payload = &creds;
remote_cbs.push_transfer_progress = &push_transfer_progress_cb;
remote_cbs.push_update_reference = &push_update_reference_cb;
GIT2_CALL(git_remote_connect(remote_object.get(), GIT_DIRECTION_FETCH, &remote_cbs, nullptr, nullptr), "Could not connect to remote \"" + remote + "\". Are your credentials correct? Try using a PAT token (in case you are using Github) as your password");
git_fetch_options opts = GIT_FETCH_OPTIONS_INIT;
opts.callbacks = remote_cbs;
GIT2_CALL(git_remote_fetch(remote_object.get(), nullptr, &opts, "fetch"), "Could not fetch data from remote");
godot::UtilityFunctions::print("GitPlugin: Fetch ended");
}
void GitPlugin::_pull(const godot::String &remote) {
godot::UtilityFunctions::print("GitPlugin: Performing pull from ", remote);
git_remote_ptr remote_object;
GIT2_CALL(git_remote_lookup(Capture(remote_object), repo.get(), CString(remote).data), "Could not lookup remote \"" + remote + "\"");
git_remote_callbacks remote_cbs = GIT_REMOTE_CALLBACKS_INIT;
remote_cbs.credentials = &credentials_cb;
remote_cbs.update_tips = &update_cb;
remote_cbs.sideband_progress = &progress_cb;
remote_cbs.transfer_progress = &transfer_progress_cb;
remote_cbs.payload = &creds;
remote_cbs.push_transfer_progress = &push_transfer_progress_cb;
remote_cbs.push_update_reference = &push_update_reference_cb;
GIT2_CALL(git_remote_connect(remote_object.get(), GIT_DIRECTION_FETCH, &remote_cbs, nullptr, nullptr), "Could not connect to remote \"" + remote + "\". Are your credentials correct? Try using a PAT token (in case you are using Github) as your password");
git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT;
fetch_opts.callbacks = remote_cbs;
godot::String branch_name = _get_current_branch_name();
CString ref_spec_str("refs/heads/" + branch_name);
char *ref[] = { ref_spec_str.data };
git_strarray refspec = { ref, 1 };
GIT2_CALL(git_remote_fetch(remote_object.get(), &refspec, &fetch_opts, "pull"), "Could not fetch data from remote");
pull_merge_oid = {};
GIT2_CALL(git_repository_fetchhead_foreach(repo.get(), fetchhead_foreach_cb, &pull_merge_oid), "Could not read \"FETCH_HEAD\" file");
if (git_oid_is_zero(&pull_merge_oid)) {
godot::UtilityFunctions::push_error("GitPlugin: Could not find remote branch HEAD for " + branch_name + ". Try pushing the branch first.");
return;
}
git_annotated_commit_ptr fetchhead_annotated_commit;
GIT2_CALL(git_annotated_commit_lookup(Capture(fetchhead_annotated_commit), repo.get(), &pull_merge_oid), "Could not get merge commit");
const git_annotated_commit *merge_heads[] = { fetchhead_annotated_commit.get() };
git_merge_analysis_t merge_analysis;
git_merge_preference_t preference = GIT_MERGE_PREFERENCE_NONE;
GIT2_CALL(git_merge_analysis(&merge_analysis, &preference, repo.get(), merge_heads, 1), "Merge analysis failed");
if (merge_analysis & GIT_MERGE_ANALYSIS_FASTFORWARD) {
git_checkout_options ff_checkout_options = GIT_CHECKOUT_OPTIONS_INIT;
int err = 0;
git_reference_ptr target_ref;
GIT2_CALL(git_repository_head(Capture(target_ref), repo.get()), "Failed to get HEAD reference");
git_object_ptr target;
GIT2_CALL(git_object_lookup(Capture(target), repo.get(), &pull_merge_oid, GIT_OBJECT_COMMIT), "Failed to lookup OID " + godot::String(git_oid_tostr_s(&pull_merge_oid)));
ff_checkout_options.checkout_strategy = GIT_CHECKOUT_SAFE;
GIT2_CALL(git_checkout_tree(repo.get(), target.get(), &ff_checkout_options), "Failed to checkout HEAD reference");
git_reference_ptr new_target_ref;
GIT2_CALL(git_reference_set_target(Capture(new_target_ref), target_ref.get(), &pull_merge_oid, nullptr), "Failed to move HEAD reference");
godot::UtilityFunctions::print("GitPlugin: Fast Forwarded");
GIT2_CALL(git_repository_state_cleanup(repo.get()), "Could not clean repository state");
} else if (merge_analysis & GIT_MERGE_ANALYSIS_NORMAL) {
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
merge_opts.file_favor = GIT_MERGE_FILE_FAVOR_NORMAL;
merge_opts.file_flags = (GIT_MERGE_FILE_STYLE_DIFF3 | GIT_MERGE_FILE_DIFF_MINIMAL);
checkout_opts.checkout_strategy = (GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS | GIT_CHECKOUT_CONFLICT_STYLE_MERGE);
GIT2_CALL(git_merge(repo.get(), merge_heads, 1, &merge_opts, &checkout_opts), "Merge Failed");
git_index_ptr index;
GIT2_CALL(git_repository_index(Capture(index), repo.get()), "Could not get repository index");
if (git_index_has_conflicts(index.get())) {
godot::UtilityFunctions::push_error("GitPlugin: Index has conflicts. Solve conflicts and make a merge commit.");
} else {
godot::UtilityFunctions::push_error("GitPlugin: Changes are staged. Make a merge commit.");
}
has_merge = true;
} else if (merge_analysis & GIT_MERGE_ANALYSIS_UP_TO_DATE) {
godot::UtilityFunctions::print("GitPlugin: Already up to date");
GIT2_CALL(git_repository_state_cleanup(repo.get()), "Could not clean repository state");
} else {
godot::UtilityFunctions::push_error("GitPlugin: Can not merge");
}
godot::UtilityFunctions::print("GitPlugin: Pull ended");
}
void GitPlugin::_push(const godot::String &remote, bool force) {
godot::UtilityFunctions::print("GitPlugin: Performing push to ", remote);
git_remote_ptr remote_object;
GIT2_CALL(git_remote_lookup(Capture(remote_object), repo.get(), CString(remote).data), "Could not lookup remote \"" + remote + "\"");
git_remote_callbacks remote_cbs = GIT_REMOTE_CALLBACKS_INIT;
remote_cbs.credentials = &credentials_cb;
remote_cbs.update_tips = &update_cb;
remote_cbs.sideband_progress = &progress_cb;
remote_cbs.transfer_progress = &transfer_progress_cb;
remote_cbs.payload = &creds;
remote_cbs.push_transfer_progress = &push_transfer_progress_cb;
remote_cbs.push_update_reference = &push_update_reference_cb;
godot::String msg = "Could not connect to remote \"" + remote + "\". Are your credentials correct? Try using a PAT token (in case you are using Github) as your password";
GIT2_CALL(git_remote_connect(remote_object.get(), GIT_DIRECTION_PUSH, &remote_cbs, nullptr, nullptr), msg);
godot::String branch_name = _get_current_branch_name();
CString pushspec(godot::String() + (force ? "+" : "") + "refs/heads/" + branch_name);
const git_strarray refspec = { &pushspec.data, 1 };
git_push_options push_options = GIT_PUSH_OPTIONS_INIT;
push_options.callbacks = remote_cbs;
GIT2_CALL(git_remote_push(remote_object.get(), &refspec, &push_options), "Failed to push");
godot::UtilityFunctions::print("GitPlugin: Push ended");
}
bool GitPlugin::_checkout_branch(const godot::String &branch_name) {
git_reference_ptr branch;
GIT2_CALL_R(git_branch_lookup(Capture(branch), repo.get(), CString(branch_name).data, GIT_BRANCH_LOCAL), "Could not find branch", false);
const char *branch_ref_name = git_reference_name(branch.get());
git_object_ptr treeish;
GIT2_CALL_R(git_revparse_single(Capture(treeish), repo.get(), CString(branch_name).data), "Could not find branch head", false);
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
opts.checkout_strategy = GIT_CHECKOUT_SAFE;
GIT2_CALL_R(git_checkout_tree(repo.get(), treeish.get(), &opts), "Could not checkout branch tree", false);
GIT2_CALL_R(git_repository_set_head(repo.get(), branch_ref_name), "Could not set head", false);
return true;
}
godot::TypedArray<godot::Dictionary> GitPlugin::_get_diff(const godot::String &identifier, const int32_t area) {
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
godot::TypedArray<godot::Dictionary> diff_contents;
opts.context_lines = 2;
opts.interhunk_lines = 0;
opts.flags = GIT_DIFF_RECURSE_UNTRACKED_DIRS | GIT_DIFF_DISABLE_PATHSPEC_MATCH | GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_SHOW_UNTRACKED_CONTENT | GIT_DIFF_INCLUDE_TYPECHANGE;
CString pathspec(identifier);
opts.pathspec.strings = &pathspec.data;
opts.pathspec.count = 1;
git_diff_ptr diff;
switch ((TreeArea)area) {
case TREE_AREA_UNSTAGED: {
GIT2_CALL_R(git_diff_index_to_workdir(Capture(diff), repo.get(), nullptr, &opts), "Could not create diff for index from working directory", diff_contents);
} break;
case TREE_AREA_STAGED: {
git_object_ptr obj;
// Ignore the case when HEAD is not found. We need to compare with a null tree in the case where the HEAD reference object is empty.
GIT2_CALL_R_IGNORE(git_revparse_single(Capture(obj), repo.get(), "HEAD^{tree}"), "Could not get HEAD^{tree} object", diff_contents, { GIT_ENOTFOUND });
git_tree_ptr tree;
if (obj) {
GIT2_CALL_R_IGNORE(git_tree_lookup(Capture(tree), repo.get(), git_object_id(obj.get())), "Could not lookup HEAD^{tree}", diff_contents, { GIT_ENOTFOUND });
}
GIT2_CALL_R(git_diff_tree_to_index(Capture(diff), repo.get(), tree.get(), nullptr, &opts), "Could not create diff for tree from index directory", diff_contents);
} break;
case TREE_AREA_COMMIT: {
opts.pathspec = {};
git_object_ptr obj;
GIT2_CALL_R(git_revparse_single(Capture(obj), repo.get(), pathspec.data), "Could not get object at " + identifier, diff_contents);
git_commit_ptr commit;
GIT2_CALL_R(git_commit_lookup(Capture(commit), repo.get(), git_object_id(obj.get())), "Could not get commit " + identifier, diff_contents);
git_commit_ptr parent;
// We ignore the case when the parent is not found to handle the case when this commit is the root commit. We only need to diff against a null tree in that case.
GIT2_CALL_R_IGNORE(git_commit_parent(Capture(parent), commit.get(), 0), "Could not get parent commit of " + identifier, diff_contents, { GIT_ENOTFOUND });
git_tree_ptr commit_tree;
GIT2_CALL_R(git_commit_tree(Capture(commit_tree), commit.get()), "Could not get commit tree of " + identifier, diff_contents);
git_tree_ptr parent_tree;
if (parent) {
GIT2_CALL_R(git_commit_tree(Capture(parent_tree), parent.get()), "Could not get commit tree of " + identifier, diff_contents);
}
GIT2_CALL_R(git_diff_tree_to_tree(Capture(diff), repo.get(), parent_tree.get(), commit_tree.get(), &opts), "Could not generate diff for commit " + identifier, diff_contents);
} break;
}
diff_contents = _parse_diff(diff.get());
return diff_contents;
}
godot::TypedArray<godot::Dictionary> GitPlugin::_parse_diff(git_diff *diff) {
godot::TypedArray<godot::Dictionary> diff_contents;
for (int i = 0; i < git_diff_num_deltas(diff); i++) {
const git_diff_delta *delta = git_diff_get_delta(diff, i);
git_patch_ptr patch;
GIT2_CALL_R(git_patch_from_diff(Capture(patch), diff, i), "Could not create patch from diff", godot::TypedArray<godot::Dictionary>());
godot::Dictionary diff_file = create_diff_file(godot::String::utf8(delta->new_file.path), godot::String::utf8(delta->old_file.path));
godot::TypedArray<godot::Dictionary> diff_hunks;
for (int j = 0; j < git_patch_num_hunks(patch.get()); j++) {
const git_diff_hunk *git_hunk;
size_t line_count;
GIT2_CALL_R(git_patch_get_hunk(&git_hunk, &line_count, patch.get(), j), "Could not get hunk from patch", godot::TypedArray<godot::Dictionary>());
godot::Dictionary diff_hunk = create_diff_hunk(git_hunk->old_start, git_hunk->new_start, git_hunk->old_lines, git_hunk->new_lines);
godot::TypedArray<godot::Dictionary> diff_lines;
for (int k = 0; k < line_count; k++) {
const git_diff_line *git_diff_line;
GIT2_CALL_R(git_patch_get_line_in_hunk(&git_diff_line, patch.get(), j, k), "Could not get line from hunk in patch", godot::TypedArray<godot::Dictionary>());
char *content = new char[git_diff_line->content_len + 1];
std::memcpy(content, git_diff_line->content, git_diff_line->content_len);
content[git_diff_line->content_len] = '\0';
godot::String status = " "; // We reserve 1 null terminated space to fill the + or the - character at git_diff_line->origin
status[0] = git_diff_line->origin;
diff_lines.push_back(create_diff_line(git_diff_line->new_lineno, git_diff_line->old_lineno, godot::String::utf8(content), status));
delete[] content;
}
diff_hunk = add_line_diffs_into_diff_hunk(diff_hunk, diff_lines);
diff_hunks.push_back(diff_hunk);
}
diff_file = add_diff_hunks_into_diff_file(diff_file, diff_hunks);
diff_contents.push_back(diff_file);
}
return diff_contents;
}
godot::String GitPlugin::_get_vcs_name() {
return "Git";
}
bool GitPlugin::_initialize(const godot::String &project_path) {
using namespace godot;
ERR_FAIL_COND_V(project_path == "", false);
int init = git_libgit2_init();
if (init > 1) {
WARN_PRINT("Multiple libgit2 instances are running");
}
git_buf discovered_repo_path = {};
if (git_repository_discover(&discovered_repo_path, CString(project_path).data, 1, nullptr) == 0) {
repo_project_path = godot::String::utf8(discovered_repo_path.ptr);
godot::UtilityFunctions::print("Found a repository at " + repo_project_path + ".");
git_buf_dispose(&discovered_repo_path);
} else {
repo_project_path = project_path;
godot::UtilityFunctions::push_warning("Could not find any higher level repositories.");
}
godot::UtilityFunctions::print("Selected repository path: " + repo_project_path + ".");
GIT2_CALL_R(git_repository_init(Capture(repo), CString(repo_project_path).data, 0), "Could not initialize repository", false);
git_reference_ptr head;
GIT2_CALL_R_IGNORE(git_repository_head(Capture(head), repo.get()), "Could not get repository HEAD", false, { GIT_EUNBORNBRANCH COMMA GIT_ENOTFOUND });
if (!head) {
create_gitignore_and_gitattributes();
}
return true;
}
bool GitPlugin::_shut_down() {
repo.reset(); // Destroy repo object before libgit2 shuts down
GIT2_CALL_R(git_libgit2_shutdown(), "Could not shutdown Git Plugin", false);
return true;
}

View File

@@ -0,0 +1,65 @@
#pragma once
#include <unordered_map>
#include "git_callbacks.h"
#include "git_wrappers.h"
#include "godot_cpp/classes/editor_vcs_interface.hpp"
#include "git2.h"
struct Credentials {
godot::String username;
godot::String password;
godot::String ssh_public_key_path;
godot::String ssh_private_key_path;
godot::String ssh_passphrase;
};
class GitPlugin : public godot::EditorVCSInterface {
GDCLASS(GitPlugin, godot::EditorVCSInterface);
protected:
static void _bind_methods();
public:
Credentials creds;
bool has_merge = false;
git_repository_ptr repo;
git_oid pull_merge_oid = {};
godot::String repo_project_path;
std::unordered_map<git_status_t, ChangeType> map_changes;
GitPlugin();
// Endpoints
bool _initialize(const godot::String &project_path) override;
void _set_credentials(const godot::String &username, const godot::String &password, const godot::String &ssh_public_key_path, const godot::String &ssh_private_key_path, const godot::String &ssh_passphrase) override;
godot::TypedArray<godot::Dictionary> _get_modified_files_data() override;
void _stage_file(const godot::String &file_path) override;
void _unstage_file(const godot::String &file_path) override;
void _discard_file(const godot::String &file_path) override;
void _commit(const godot::String &msg) override;
godot::TypedArray<godot::Dictionary> _get_diff(const godot::String &identifier, int32_t area) override;
bool _shut_down() override;
godot::String _get_vcs_name() override;
godot::TypedArray<godot::Dictionary> _get_previous_commits(int32_t max_commits) override;
godot::TypedArray<godot::String> _get_branch_list() override;
godot::TypedArray<godot::String> _get_remotes() override;
void _create_branch(const godot::String &branch_name) override;
void _remove_branch(const godot::String &branch_name) override;
void _create_remote(const godot::String &remote_name, const godot::String &remote_url) override;
void _remove_remote(const godot::String &remote_name) override;
godot::String _get_current_branch_name() override;
bool _checkout_branch(const godot::String &branch_name) override;
void _pull(const godot::String &remote) override;
void _push(const godot::String &remote, bool force) override;
void _fetch(const godot::String &remote) override;
godot::TypedArray<godot::Dictionary> _get_line_diff(const godot::String &file_path, const godot::String &text) override;
// Helpers
godot::TypedArray<godot::Dictionary> _parse_diff(git_diff *p_diff);
bool check_errors(int error, godot::String function, godot::String file, int line, godot::String message, const std::vector<git_error_code> &ignores = {});
void create_gitignore_and_gitattributes();
bool create_initial_commit();
};

View File

@@ -0,0 +1,18 @@
#include "git_wrappers.h"
#include <cstring>
CString::CString(const godot::String &string) {
godot::CharString godot_char_str = string.utf8();
data = new char[godot_char_str.length() + 1];
std::memcpy(data, (void *)godot_char_str.get_data(), godot_char_str.length());
data[godot_char_str.length()] = '\0';
}
CString::~CString() {
if (data) {
delete[] data;
data = nullptr;
}
}

View File

@@ -0,0 +1,74 @@
#pragma once
#include <memory>
#include "godot_cpp/variant/string.hpp"
#include "git2.h"
class GitPlugin;
struct CString {
char *data = nullptr;
CString(const godot::String &string);
~CString();
CString() = delete;
CString(CString &&) = delete;
CString &operator=(const CString &) = delete;
CString &operator=(CString &&) = delete;
};
template <class T>
class Capture {
T &smart_ptr = nullptr;
using Raw = decltype(smart_ptr.get());
Raw raw = nullptr;
public:
Capture() = delete;
Capture(T &ptr) :
smart_ptr(ptr) {}
Capture(Capture &&) = delete;
Capture &operator=(const Capture &) = delete;
Capture &operator=(Capture &&) = delete;
operator Raw *() {
return &raw;
}
~Capture() {
if (raw) {
smart_ptr.reset(raw);
}
}
};
template <auto DeleteFn>
struct FunctionDeleter {
template <class T>
void operator()(T *ptr) {
DeleteFn(ptr);
}
};
template <class T, auto DeleteFn>
using unique_ptr_deleter = std::unique_ptr<T, FunctionDeleter<DeleteFn>>;
using git_annotated_commit_ptr = unique_ptr_deleter<git_annotated_commit, git_annotated_commit_free>;
using git_blob_ptr = unique_ptr_deleter<git_blob, git_blob_free>;
using git_branch_iterator_ptr = unique_ptr_deleter<git_branch_iterator, git_branch_iterator_free>;
using git_commit_ptr = unique_ptr_deleter<git_commit, git_commit_free>;
using git_diff_ptr = unique_ptr_deleter<git_diff, git_diff_free>;
using git_index_ptr = unique_ptr_deleter<git_index, git_index_free>;
using git_object_ptr = unique_ptr_deleter<git_object, git_object_free>;
using git_patch_ptr = unique_ptr_deleter<git_patch, git_patch_free>;
using git_reference_ptr = unique_ptr_deleter<git_reference, git_reference_free>;
using git_remote_ptr = unique_ptr_deleter<git_remote, git_remote_free>;
using git_repository_ptr = unique_ptr_deleter<git_repository, git_repository_free>;
using git_revwalk_ptr = unique_ptr_deleter<git_revwalk, git_revwalk_free>;
using git_signature_ptr = unique_ptr_deleter<git_signature, git_signature_free>;
using git_status_list_ptr = unique_ptr_deleter<git_status_list, git_status_list_free>;
using git_tree_ptr = unique_ptr_deleter<git_tree, git_tree_free>;
using git_tree_entry_ptr = unique_ptr_deleter<git_tree_entry, git_tree_entry_free>;

View File

@@ -1,3 +0,0 @@
# This file lists all thirdparty libraries used in this plugin with the latest commit link of when source was picked up
libgit2: https://github.com/libgit2/libgit2/commit/f039c836438f96407abc08cbd238b9102318deb2

View File

@@ -1,24 +0,0 @@
/*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2,
* as published by the Free Software Foundation.
*
* In addition to the permissions in the GNU General Public License,
* the authors give you unlimited permission to link the compiled
* version of this file into combinations with other programs,
* and to distribute those combinations without any restriction
* coming from the use of this file. (The General Public License
* restrictions do apply in other respects; for example, they cover
* modification of the file, and distribution when not linked into
* a combined executable.)
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/

View File

@@ -1,15 +0,0 @@
; Check http://editorconfig.org/ for more informations
; Top-most EditorConfig file
root = true
; tab indentation
[*]
indent_style = tab
trim_trailing_whitespace = true
insert_final_newline = true
; 4-column space indentation
[*.md]
indent_style = space
indent_size = 4
trim_trailing_whitespace = false

View File

@@ -1 +0,0 @@
* text=auto

View File

@@ -1,19 +0,0 @@
You are opening a _bug report_ against the libgit2 project: we use
GitHub Issues for tracking bug reports and feature requests. If you
have a question about an API or usage, please ask on StackOverflow:
http://stackoverflow.com/questions/tagged/libgit2. If you want to
have high-level discussions about the libgit2 project itself, visit
https://github.com/libgit2/discussions.
Otherwise, to report a bug, please fill out the reproduction steps
(below) and delete these introductory paragraphs. Thanks!
### Reproduction steps
### Expected behavior
### Actual behavior
### Version of libgit2 (release number or SHA1)
### Operating system(s) tested

View File

@@ -1,37 +0,0 @@
/tests/clar.suite
/tests/clar.suite.rule
/tests/.clarcache
/apidocs
/trash-*.exe
/libgit2.pc
/config.mak
*.o
*.a
*.exe
*.gcda
*.gcno
*.gcov
.lock-wafbuild
.waf*
build/
build-amiga/
tests/tmp/
msvc/Debug/
msvc/Release/
*.sln
*.suo
*.vc*proj*
*.sdf
*.opensdf
*.aps
*.cmake
!cmake/Modules/*.cmake
.DS_Store
*~
.*.swp
tags
mkmf.log
*.profdata
*.profraw
CMakeSettings.json
.vs

View File

@@ -1,22 +0,0 @@
Vicent Martí <vicent@github.com> Vicent Marti <tanoku@gmail.com>
Vicent Martí <vicent@github.com> Vicent Martí <tanoku@gmail.com>
Michael Schubert <schu@schu.io> schu <schu-github@schulog.org>
Ben Straub <bs@github.com> Ben Straub <ben@straubnet.net>
Ben Straub <bs@github.com> Ben Straub <bstraub@github.com>
Carlos Martín Nieto <cmn@dwim.me> <carlos@cmartin.tk>
Carlos Martín Nieto <cmn@dwim.me> <cmn@elego.de>
nulltoken <emeric.fermas@gmail.com> <emeric.fermas@gmail.com>
Scott J. Goldman <scottjg@github.com> <scottjgo@gmail.com>
Martin Woodward <martin.woodward@microsoft.com> <martinwo@microsoft.com>
Peter Drahoš <drahosp@gmail.com> <drahosp@gmail.com>
Adam Roben <adam@github.com> <adam@roben.org>
Adam Roben <adam@github.com> <adam@github.com>
Xavier L. <xavier.l@afrosoft.tk> <xavier.l@afrosoft.ca>
Xavier L. <xavier.l@afrosoft.tk> <xavier.l@afrosoft.tk>
Sascha Cunz <sascha@babbelbox.org> <Sascha@BabbelBox.org>
Authmillenon <authmillenon@googlemail.com> <martin@ucsmail.de>
Authmillenon <authmillenon@googlemail.com> <authmillenon@googlemail.com>
Edward Thomson <ethomson@edwardthomson.com> <ethomson@microsoft.com>
Edward Thomson <ethomson@edwardthomson.com> <ethomson@github.com>
J. David Ibáñez <jdavid.ibp@gmail.com> <jdavid@itaapy.com>
Russell Belfer <rb@github.com> <arrbee@arrbee.com>

View File

@@ -1,78 +0,0 @@
The following people contribute or have contributed
to the libgit2 project (sorted alphabetically):
Alex Budovski
Alexei Sholik
Andreas Ericsson
Anton "antong" Gyllenberg
Ankur Sethi
Arthur Schreiber
Ben Noordhuis
Ben Straub
Benjamin C Meyer
Brian Downing
Brian Lopez
Carlos Martín Nieto
Colin Timmermans
Daniel Huckstep
Dave Borowitz
David Boyce
David Glesser
Dmitry Kakurin
Dmitry Kovega
Emeric Fermas
Emmanuel Rodriguez
Eric Myhre
Erik Aigner
Florian Forster
Holger Weiss
Ingmar Vanhassel
J. David Ibáñez
Jacques Germishuys
Jakob Pfender
Jason Penny
Jason R. McNeil
Jerome Lambourg
Johan 't Hart
John Wiegley
Jonathan "Duke" Leto
Julien Miotte
Julio Espinoza-Sokal
Justin Love
Kelly "kelly.leahy" Leahy
Kirill A. Shutemov
Lambert CLARA
Luc Bertrand
Marc Pegon
Marcel Groothuis
Marco Villegas
Michael "schu" Schubert
Microsoft Corporation
Olivier Ramonat
Peter Drahoš
Pierre Habouzit
Pierre-Olivier Latour
Przemyslaw Pawelczyk
Ramsay Jones
Robert G. Jakabosky
Romain Geissler
Romain Muller
Russell Belfer
Sakari Jokinen
Samuel Charles "Sam" Day
Sarath Lakshman
Sascha Cunz
Sascha Peilicke
Scott Chacon
Sebastian Schuberth
Sergey Nikishin
Shawn O. Pearce
Shuhei Tanuma
Steve Frécinaux
Sven Strickroth
Tim Branyen
Tim Clem
Tim Harder
Torsten Bögershausen
Trent Mick
Vicent Marti

View File

@@ -1,339 +0,0 @@
# CMake build script for the libgit2 project
#
# Building (out of source build):
# > mkdir build && cd build
# > cmake .. [-DSETTINGS=VALUE]
# > cmake --build .
#
# Testing:
# > ctest -V
#
# Install:
# > cmake --build . --target install
PROJECT(libgit2 C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
CMAKE_POLICY(SET CMP0015 NEW)
IF(POLICY CMP0051)
CMAKE_POLICY(SET CMP0051 NEW)
ENDIF()
IF(POLICY CMP0042)
CMAKE_POLICY(SET CMP0042 NEW)
ENDIF()
IF(POLICY CMP0054)
CMAKE_POLICY(SET CMP0054 NEW)
ENDIF()
# Add find modules to the path
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/Modules/")
INCLUDE(CheckLibraryExists)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckSymbolExists)
INCLUDE(CheckStructHasMember)
INCLUDE(CheckPrototypeDefinition) # Added in CMake 3.0
INCLUDE(AddCFlagIfSupported)
INCLUDE(FindPkgLibraries)
INCLUDE(FindThreads)
INCLUDE(FindStatNsec)
INCLUDE(IdeSplitSources)
INCLUDE(FeatureSummary)
INCLUDE(EnableWarnings)
# Build options
#
OPTION(SONAME "Set the (SO)VERSION of the target" ON)
OPTION(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
OPTION(THREADSAFE "Build libgit2 as threadsafe" ON)
OPTION(BUILD_CLAR "Build Tests using the Clar suite" ON)
OPTION(BUILD_EXAMPLES "Build library usage example apps" OFF)
OPTION(BUILD_FUZZERS "Build the fuzz targets" OFF)
OPTION(TAGS "Generate tags" OFF)
OPTION(PROFILE "Generate profiling information" OFF)
OPTION(ENABLE_TRACE "Enables tracing support" OFF)
OPTION(LIBGIT2_FILENAME "Name of the produced binary" OFF)
OPTION(USE_SSH "Link with libssh2 to enable SSH support" ON)
OPTION(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON)
OPTION(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS/Generic" ON)
OPTION(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
OPTION(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF)
OPTION(USE_LEAK_CHECKER "Run tests with leak checker" OFF)
OPTION(VALGRIND "Configure build for valgrind" OFF)
OPTION(DEBUG_POOL "Enable debug pool allocator" OFF)
OPTION(ENABLE_WERROR "Enable compilation with -Werror" OFF)
OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF)
SET(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
OPTION(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
SET(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
IF (UNIX)
IF (NOT USE_HTTPS)
OPTION(USE_NTLMCLIENT "Enable NTLM support on Unix." OFF )
ELSE()
OPTION(USE_NTLMCLIENT "Enable NTLM support on Unix." ON )
ENDIF()
ENDIF()
IF (UNIX AND NOT APPLE)
OPTION(ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF)
ENDIF()
IF (APPLE)
OPTION(USE_ICONV "Link with and use iconv library" ON)
ENDIF()
IF(MSVC)
# This option must match the settings used in your program, in particular if you
# are linking statically
OPTION(STATIC_CRT "Link the static CRT libraries" ON)
# If you want to embed a copy of libssh2 into libgit2, pass a
# path to libssh2
OPTION(EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF)
ENDIF()
IF(WIN32)
# By default, libgit2 is built with WinHTTP. To use the built-in
# HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument.
OPTION(WINHTTP "Use Win32 WinHTTP routines" ON)
ENDIF()
IF(MSVC)
# Enable MSVC CRTDBG memory leak reporting when in debug mode.
OPTION(MSVC_CRTDBG "Enable CRTDBG memory leak reporting" OFF)
ENDIF()
FILE(STRINGS "${libgit2_SOURCE_DIR}/include/git2/version.h" GIT2_HEADER REGEX "^#define LIBGIT2_VERSION \"[^\"]*\"$")
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"([0-9]+).*$" "\\1" LIBGIT2_VERSION_MAJOR "${GIT2_HEADER}")
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_MINOR "${GIT2_HEADER}")
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_REV "${GIT2_HEADER}")
SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}")
FILE(STRINGS "${libgit2_SOURCE_DIR}/include/git2/version.h" GIT2_HEADER_SOVERSION REGEX "^#define LIBGIT2_SOVERSION [0-9]+$")
STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "${GIT2_HEADER_SOVERSION}")
IF (DEPRECATE_HARD)
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
ENDIF()
# Platform specific compilation flags
IF (MSVC)
IF (STDCALL)
MESSAGE(FATAL_ERROR "The STDCALL option is no longer supported; libgit2 is now always built as a cdecl library. If you're using PInvoke, please add the CallingConventions.Cdecl attribute for support.")
ENDIF()
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
STRING(REPLACE "/Zm1000" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
# /GF - String pooling
# /MP - Parallel build
SET(CMAKE_C_FLAGS "/GF /MP /nologo ${CMAKE_C_FLAGS}")
# /Gd - explicitly set cdecl calling convention
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd")
IF (STATIC_CRT)
SET(CRT_FLAG_DEBUG "/MTd")
SET(CRT_FLAG_RELEASE "/MT")
ELSE()
SET(CRT_FLAG_DEBUG "/MDd")
SET(CRT_FLAG_RELEASE "/MD")
ENDIF()
IF (MSVC_CRTDBG)
SET(GIT_MSVC_CRTDBG 1)
SET(CRT_FLAG_DEBUG "${CRT_FLAG_DEBUG}")
SET(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} Dbghelp.lib")
ENDIF()
# /Zi - Create debugging information
# /Od - Disable optimization
# /D_DEBUG - #define _DEBUG
# /MTd - Statically link the multithreaded debug version of the CRT
# /MDd - Dynamically link the multithreaded debug version of the CRT
# /RTC1 - Run time checks
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}")
# /DNDEBUG - Disables asserts
# /MT - Statically link the multithreaded release version of the CRT
# /MD - Dynamically link the multithreaded release version of the CRT
# /O2 - Optimize for speed
# /Oy - Enable frame pointer omission (FPO) (otherwise CMake will automatically turn it off)
# /GL - Link time code generation (whole program optimization)
# /Gy - Function-level linking
SET(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /O2 /Oy /GL /Gy ${CRT_FLAG_RELEASE}")
# /Oy- - Disable frame pointer omission (FPO)
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/DNDEBUG /Zi /O2 /Oy- /GL /Gy ${CRT_FLAG_RELEASE}")
# /O1 - Optimize for size
SET(CMAKE_C_FLAGS_MINSIZEREL "/DNDEBUG /O1 /Oy /GL /Gy ${CRT_FLAG_RELEASE}")
# /IGNORE:4221 - Ignore empty compilation units
SET(CMAKE_STATIC_LINKER_FLAGS "/IGNORE:4221")
# /DYNAMICBASE - Address space load randomization (ASLR)
# /NXCOMPAT - Data execution prevention (DEP)
# /LARGEADDRESSAWARE - >2GB user address space on x86
# /VERSION - Embed version information in PE header
SET(CMAKE_EXE_LINKER_FLAGS "/DYNAMICBASE /NXCOMPAT /LARGEADDRESSAWARE /VERSION:${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}")
# /DEBUG - Create a PDB
# /LTCG - Link time code generation (whole program optimization)
# /OPT:REF /OPT:ICF - Fold out duplicate code at link step
# /INCREMENTAL:NO - Required to use /LTCG
# /DEBUGTYPE:cv,fixup - Additional data embedded in the PDB (requires /INCREMENTAL:NO, so not on for Debug)
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup")
SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
# Same linker settings for DLL as EXE
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}")
ELSE ()
IF (ENABLE_REPRODUCIBLE_BUILDS)
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> Dq <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>")
ENDIF()
SET(CMAKE_C_FLAGS "-D_GNU_SOURCE ${CMAKE_C_FLAGS}")
ENABLE_WARNINGS(all)
ENABLE_WARNINGS(extra)
IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
SET(CMAKE_C_FLAGS "-D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS ${CMAKE_C_FLAGS}")
ENDIF()
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -O0")
IF (MINGW OR MSYS) # MinGW and MSYS always do PIC and complain if we tell them to
STRING(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
ELSEIF (BUILD_SHARED_LIBS)
ADD_C_FLAG_IF_SUPPORTED(-fvisibility=hidden)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
ENDIF ()
IF (MINGW)
# MinGW >= 3.14 uses the C99-style stdio functions
# automatically, but forks like mingw-w64 still want
# us to define this in order to use them
ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1)
ENDIF ()
ENABLE_WARNINGS(documentation)
DISABLE_WARNINGS(missing-field-initializers)
ENABLE_WARNINGS(strict-aliasing)
ENABLE_WARNINGS(strict-prototypes)
ENABLE_WARNINGS(declaration-after-statement)
ENABLE_WARNINGS(shift-count-overflow)
ENABLE_WARNINGS(unused-const-variable)
ENABLE_WARNINGS(unused-function)
ENABLE_WARNINGS(int-conversion)
# MinGW uses gcc, which expects POSIX formatting for printf, but
# uses the Windows C library, which uses its own format specifiers.
# Disable format specifier warnings.
IF(MINGW)
DISABLE_WARNINGS(format)
DISABLE_WARNINGS(format-security)
ELSE()
ENABLE_WARNINGS(format)
ENABLE_WARNINGS(format-security)
ENDIF()
IF("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
DISABLE_WARNINGS(documentation-deprecated-sync)
ENDIF()
IF (PROFILE)
SET(CMAKE_C_FLAGS "-pg ${CMAKE_C_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "-pg ${CMAKE_EXE_LINKER_FLAGS}")
ENDIF ()
ENDIF()
IF( NOT CMAKE_CONFIGURATION_TYPES )
# Build Debug by default
IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF ()
ELSE()
# Using a multi-configuration generator eg MSVC or Xcode
# that uses CMAKE_CONFIGURATION_TYPES and not CMAKE_BUILD_TYPE
ENDIF()
IF(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
# The actual sanitizer link target will be added when linking the fuzz
# targets.
SET(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
ADD_C_FLAG(-fsanitize=fuzzer-no-link)
UNSET(CMAKE_REQUIRED_FLAGS)
ENDIF ()
ADD_SUBDIRECTORY(src)
# Tests
IF (NOT MSVC)
IF (NOT BUILD_SHARED_LIBS)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
ENDIF()
ENDIF ()
IF (BUILD_CLAR)
ENABLE_TESTING()
ADD_SUBDIRECTORY(tests)
ENDIF ()
IF (TAGS)
FIND_PROGRAM(CTAGS ctags)
IF (NOT CTAGS)
MESSAGE(FATAL_ERROR "Could not find ctags command")
ENDIF ()
FILE(GLOB_RECURSE SRC_ALL *.[ch])
ADD_CUSTOM_COMMAND(
OUTPUT tags
COMMAND ${CTAGS} -a ${SRC_ALL}
DEPENDS ${SRC_ALL}
)
ADD_CUSTOM_TARGET(
do_tags ALL
DEPENDS tags
)
ENDIF ()
IF (BUILD_EXAMPLES)
ADD_SUBDIRECTORY(examples)
ENDIF ()
IF(BUILD_FUZZERS)
IF(NOT USE_STANDALONE_FUZZERS)
IF(BUILD_EXAMPLES)
MESSAGE(FATAL_ERROR "Cannot build the fuzzer targets and the examples together")
ENDIF()
IF(BUILD_CLAR)
MESSAGE(FATAL_ERROR "Cannot build the fuzzer targets and the tests together")
ENDIF()
ENDIF()
ADD_SUBDIRECTORY(fuzzers)
ENDIF()
IF(CMAKE_VERSION VERSION_GREATER 3)
FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
ELSE()
PRINT_ENABLED_FEATURES()
PRINT_DISABLED_FEATURES()
ENDIF()

View File

@@ -1,390 +0,0 @@
libgit2 - the Git linkable library
==================================
| Build Status | |
| ------------ | - |
| **master** branch CI builds | [![Azure Pipelines Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/libgit2?branchName=master)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=master) |
| **v0.28 branch** CI builds | [![Azure Pipelines Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/libgit2?branchName=maint/v0.28)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v0.28) |
| **v0.27 branch** CI builds | [![Azure Pipelines Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/libgit2?branchName=maint/v0.27)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v0.27) |
| **v0.26 branch** CI builds | [![Azure Pipelines Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/libgit2?branchName=maint/v0.26)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v0.26) |
| **Nightly** builds | [![Azure Pipelines Build Status](https://libgit2.visualstudio.com/libgit2/_apis/build/status/nightly?branchName=master&label=Full+Build)](https://libgit2.visualstudio.com/libgit2/_build/latest?definitionId=9&branchName=master) [![Coverity Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/coverity?branchName=master&label=Coverity+Build)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=21?branchName=master) [![Coverity Scan Build Status](https://scan.coverity.com/projects/639/badge.svg)](https://scan.coverity.com/projects/639) |
`libgit2` is a portable, pure C implementation of the Git core methods
provided as a linkable library with a solid API, allowing to build Git
functionality into your application. Language bindings like
[Rugged](https://github.com/libgit2/rugged) (Ruby),
[LibGit2Sharp](https://github.com/libgit2/libgit2sharp) (.NET),
[pygit2](http://www.pygit2.org/) (Python) and
[NodeGit](http://nodegit.org) (Node) allow you to build Git tooling
in your favorite language.
`libgit2` is used to power Git GUI clients like
[GitKraken](https://gitkraken.com/) and [gmaster](https://gmaster.io/)
and on Git hosting providers like [GitHub](https://github.com/),
[GitLab](https://gitlab.com/) and
[Azure DevOps](https://azure.com/devops).
We perform the merge every time you click "merge pull request".
`libgit2` is licensed under a **very permissive license** (GPLv2 with a special
Linking Exception). This basically means that you can link it (unmodified)
with any kind of software without having to release its source code.
Additionally, the example code has been released to the public domain (see the
[separate license](examples/COPYING) for more information).
Table of Contents
=================
* [Quick Start](#quick-start)
* [Getting Help](#getting-help)
* [What It Can Do](#what-it-can-do)
* [Optional dependencies](#optional-dependencies)
* [Initialization](#initialization)
* [Threading](#threading)
* [Conventions](#conventions)
* [Building libgit2 - Using CMake](#building-libgit2---using-cmake)
* [Building](#building)
* [Installation](#installation)
* [Advanced Usage](#advanced-usage)
* [Compiler and linker options](#compiler-and-linker-options)
* [MacOS X](#macos-x)
* [Android](#android)
* [Language Bindings](#language-bindings)
* [How Can I Contribute?](#how-can-i-contribute)
* [License](#license)
Quick Start
===========
**Prerequisites** for building libgit2:
1. [CMake](https://cmake.org/), and is recommended to be installed into
your `PATH`.
2. [Python](https://www.python.org) is used by our test framework, and
should be installed into your `PATH`.
3. C compiler: libgit2 is C90 and should compile on most compilers.
* Windows: Visual Studio is recommended
* Mac: Xcode is recommended
* Unix: gcc or clang is recommended.
**Build**
1. Create a build directory beneath the libgit2 source directory, and change
into it: `mkdir build && cd build`
2. Create the cmake build environment: `cmake ..`
3. Build libgit2: `cmake --build .`
Trouble with these steps? Read our [troubleshooting guide](docs/troubleshooting.md).
More detailed build guidance is available below.
Getting Help
============
**Join us on Slack**
Visit [slack.libgit2.org](http://slack.libgit2.org/) to sign up, then join
us in `#libgit2`. If you prefer IRC, you can also point your client to our
slack channel once you've registered.
**Getting Help**
If you have questions about the library, please be sure to check out the
[API documentation](http://libgit2.github.com/libgit2/). If you still have
questions, reach out to us on Slack or post a question on
[StackOverflow](http://stackoverflow.com/questions/tagged/libgit2) (with the `libgit2` tag).
**Reporting Bugs**
Please open a [GitHub Issue](https://github.com/libgit2/libgit2/issues) and
include as much information as possible. If possible, provide sample code
that illustrates the problem you're seeing. If you're seeing a bug only
on a specific repository, please provide a link to it if possible.
We ask that you not open a GitHub Issue for help, only for bug reports.
**Reporting Security Issues**
Please have a look at SECURITY.md.
What It Can Do
==============
libgit2 provides you with the ability to manage Git repositories in the
programming language of your choice. It's used in production to power many
applications including GitHub.com, Plastic SCM and Azure DevOps.
It does not aim to replace the git tool or its user-facing commands. Some APIs
resemble the plumbing commands as those align closely with the concepts of the
Git system, but most commands a user would type are out of scope for this
library to implement directly.
The library provides:
* SHA conversions, formatting and shortening
* abstracted ODB backend system
* commit, tag, tree and blob parsing, editing, and write-back
* tree traversal
* revision walking
* index file (staging area) manipulation
* reference management (including packed references)
* config file management
* high level repository management
* thread safety and reentrancy
* descriptive and detailed error messages
* ...and more (over 175 different API calls)
As libgit2 is purely a consumer of the Git system, we have to
adjust to changes made upstream. This has two major consequences:
* Some changes may require us to change provided interfaces. While we try to
implement functions in a generic way so that no future changes are required,
we cannot promise a completely stable API.
* As we have to keep up with changes in behavior made upstream, we may lag
behind in some areas. We usually to document these incompatibilities in our
issue tracker with the label "git change".
Optional dependencies
=====================
While the library provides git functionality without the need for
dependencies, it can make use of a few libraries to add to it:
- pthreads (non-Windows) to enable threadsafe access as well as multi-threaded pack generation
- OpenSSL (non-Windows) to talk over HTTPS and provide the SHA-1 functions
- LibSSH2 to enable the SSH transport
- iconv (OSX) to handle the HFS+ path encoding peculiarities
Initialization
===============
The library needs to keep track of some global state. Call
git_libgit2_init();
before calling any other libgit2 functions. You can call this function many times. A matching number of calls to
git_libgit2_shutdown();
will free the resources. Note that if you have worker threads, you should
call `git_libgit2_shutdown` *after* those threads have exited. If you
require assistance coordinating this, simply have the worker threads call
`git_libgit2_init` at startup and `git_libgit2_shutdown` at shutdown.
Threading
=========
See [threading](docs/threading.md) for information
Conventions
===========
See [conventions](docs/conventions.md) for an overview of the external
and internal API/coding conventions we use.
Building libgit2 - Using CMake
==============================
Building
--------
`libgit2` builds cleanly on most platforms without any external dependencies.
Under Unix-like systems, like Linux, \*BSD and Mac OS X, libgit2 expects `pthreads` to be available;
they should be installed by default on all systems. Under Windows, libgit2 uses the native Windows API
for threading.
The `libgit2` library is built using [CMake](<https://cmake.org/>) (version 2.8 or newer) on all platforms.
On most systems you can build the library using the following commands
$ mkdir build && cd build
$ cmake ..
$ cmake --build .
Alternatively you can point the CMake GUI tool to the CMakeLists.txt file and generate platform specific build project or IDE workspace.
Running Tests
-------------
Once built, you can run the tests from the `build` directory with the command
$ ctest -V
Alternatively you can run the test suite directly using,
$ ./libgit2_clar
Invoking the test suite directly is useful because it allows you to execute
individual tests, or groups of tests using the `-s` flag. For example, to
run the index tests:
$ ./libgit2_clar -sindex
To run a single test named `index::racy::diff`, which corresponds to the test
function [`test_index_racy__diff`](https://github.com/libgit2/libgit2/blob/master/tests/index/racy.c#L23):
$ ./libgit2_clar -sindex::racy::diff
The test suite will print a `.` for every passing test, and an `F` for any
failing test. An `S` indicates that a test was skipped because it is not
applicable to your platform or is particularly expensive.
**Note:** There should be _no_ failing tests when you build an unmodified
source tree from a [release](https://github.com/libgit2/libgit2/releases),
or from the [master branch](https://github.com/libgit2/libgit2/tree/master).
Please contact us or [open an issue](https://github.com/libgit2/libgit2/issues)
if you see test failures.
Installation
------------
To install the library you can specify the install prefix by setting:
$ cmake .. -DCMAKE_INSTALL_PREFIX=/install/prefix
$ cmake --build . --target install
Advanced Usage
--------------
For more advanced use or questions about CMake please read <https://cmake.org/Wiki/CMake_FAQ>.
The following CMake variables are declared:
- `BIN_INSTALL_DIR`: Where to install binaries to.
- `LIB_INSTALL_DIR`: Where to install libraries to.
- `INCLUDE_INSTALL_DIR`: Where to install headers to.
- `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON)
- `BUILD_CLAR`: Build [Clar](https://github.com/vmg/clar)-based test suite (defaults to ON)
- `THREADSAFE`: Build libgit2 with threading support (defaults to ON)
To list all build options and their current value, you can do the
following:
# Create and set up a build directory
$ mkdir build
$ cmake ..
# List all build options and their values
$ cmake -L
Compiler and linker options
---------------------------
CMake lets you specify a few variables to control the behavior of the
compiler and linker. These flags are rarely used but can be useful for
64-bit to 32-bit cross-compilation.
- `CMAKE_C_FLAGS`: Set your own compiler flags
- `CMAKE_FIND_ROOT_PATH`: Override the search path for libraries
- `ZLIB_LIBRARY`, `OPENSSL_SSL_LIBRARY` AND `OPENSSL_CRYPTO_LIBRARY`:
Tell CMake where to find those specific libraries
MacOS X
-------
If you want to build a universal binary for Mac OS X, CMake sets it
all up for you if you use `-DCMAKE_OSX_ARCHITECTURES="i386;x86_64"`
when configuring.
Android
-------
Extract toolchain from NDK using, `make-standalone-toolchain.sh` script.
Optionally, crosscompile and install OpenSSL inside of it. Then create CMake
toolchain file that configures paths to your crosscompiler (substitute `{PATH}`
with full path to the toolchain):
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION Android)
SET(CMAKE_C_COMPILER {PATH}/bin/arm-linux-androideabi-gcc)
SET(CMAKE_CXX_COMPILER {PATH}/bin/arm-linux-androideabi-g++)
SET(CMAKE_FIND_ROOT_PATH {PATH}/sysroot/)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Add `-DCMAKE_TOOLCHAIN_FILE={pathToToolchainFile}` to cmake command
when configuring.
Language Bindings
==================================
Here are the bindings to libgit2 that are currently available:
* C++
* libqgit2, Qt bindings <https://projects.kde.org/projects/playground/libs/libqgit2/repository/>
* Chicken Scheme
* chicken-git <https://wiki.call-cc.org/egg/git>
* D
* dlibgit <https://github.com/s-ludwig/dlibgit>
* Delphi
* GitForDelphi <https://github.com/libgit2/GitForDelphi>
* Erlang
* Geef <https://github.com/carlosmn/geef>
* Go
* git2go <https://github.com/libgit2/git2go>
* GObject
* libgit2-glib <https://wiki.gnome.org/Projects/Libgit2-glib>
* Guile
* Guile-Git <https://gitlab.com/guile-git/guile-git>
* Haskell
* hgit2 <https://github.com/jwiegley/gitlib>
* Java
* Jagged <https://github.com/ethomson/jagged>
* Julia
* LibGit2.jl <https://github.com/jakebolewski/LibGit2.jl>
* Lua
* luagit2 <https://github.com/libgit2/luagit2>
* .NET
* libgit2sharp <https://github.com/libgit2/libgit2sharp>
* Node.js
* nodegit <https://github.com/nodegit/nodegit>
* Objective-C
* objective-git <https://github.com/libgit2/objective-git>
* OCaml
* ocaml-libgit2 <https://github.com/fxfactorial/ocaml-libgit2>
* Parrot Virtual Machine
* parrot-libgit2 <https://github.com/letolabs/parrot-libgit2>
* Perl
* Git-Raw <https://github.com/jacquesg/p5-Git-Raw>
* PHP
* php-git <https://github.com/libgit2/php-git>
* PowerShell
* PSGit <https://github.com/PoshCode/PSGit>
* Python
* pygit2 <https://github.com/libgit2/pygit2>
* R
* git2r <https://github.com/ropensci/git2r>
* Ruby
* Rugged <https://github.com/libgit2/rugged>
* Rust
* git2-rs <https://github.com/rust-lang/git2-rs>
* Swift
* SwiftGit2 <https://github.com/SwiftGit2/SwiftGit2>
* Vala
* libgit2.vapi <https://github.com/apmasell/vapis/blob/master/libgit2.vapi>
If you start another language binding to libgit2, please let us know so
we can add it to the list.
How Can I Contribute?
==================================
We welcome new contributors! We have a number of issues marked as
["up for grabs"](https://github.com/libgit2/libgit2/issues?q=is%3Aissue+is%3Aopen+label%3A%22up+for+grabs%22)
and
["easy fix"](https://github.com/libgit2/libgit2/issues?utf8=✓&q=is%3Aissue+is%3Aopen+label%3A%22easy+fix%22)
that are good places to jump in and get started. There's much more detailed
information in our list of [outstanding projects](docs/projects.md).
Please be sure to check the [contribution guidelines](docs/contributing.md) to
understand our workflow, and the libgit2 [coding conventions](docs/conventions.md).
License
==================================
`libgit2` is under GPL2 **with linking exception**. This means you can link to
and use the library from any program, proprietary or open source; paid or
gratis. However, if you modify libgit2 itself, you must distribute the
source to your modified version of libgit2.
See the [COPYING file](COPYING) for the full license text.

View File

@@ -1,14 +0,0 @@
# Security Policy
## Supported Versions
This project will always provide security fixes for the latest two released
versions. E.g. if the latest version is v0.28.x, then we will provide security
fixes for both v0.28.x and v0.27.y, but no later versions.
## Reporting a Vulnerability
In case you think to have found a security issue with libgit2, please do not
open a public issue. Instead, you can report the issue to the private mailing
list [security@libgit2.com](mailto:security@libgit2.com). We will acknowledge
receipt of your message in at most three days and try to clarify further steps.

View File

@@ -1,13 +0,0 @@
{
"name": "libgit2",
"github": "libgit2/libgit2",
"input": "include",
"prefix": "git_",
"output": "docs",
"branch": "gh-pages",
"examples": "examples",
"legacy": {
"input": {"src/git": ["v0.1.0"],
"src/git2": ["v0.2.0", "v0.3.0"]}
}
}

View File

@@ -1,165 +0,0 @@
resources:
- repo: self
trigger:
- master
- maint/*
jobs:
- job: linux_amd64_trusty_gcc_openssl
displayName: 'Linux (amd64; Trusty; GCC; OpenSSL)'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- template: azure-pipelines/docker.yml
parameters:
imageName: 'libgit2/trusty-amd64:latest'
environmentVariables: |
CC=gcc
CMAKE_GENERATOR=Unix Makefiles
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
- job: linux_amd64_trusty_gcc_mbedtls
displayName: 'Linux (amd64; Trusty; GCC; mbedTLS)'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- template: azure-pipelines/docker.yml
parameters:
imageName: 'libgit2/trusty-amd64:latest'
environmentVariables: |
CC=gcc
CMAKE_GENERATOR=Unix Makefiles
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
- job: linux_amd64_trusty_clang_openssl
displayName: 'Linux (amd64; Trusty; Clang; OpenSSL)'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- template: azure-pipelines/docker.yml
parameters:
imageName: 'libgit2/trusty-amd64:latest'
environmentVariables: |
CC=clang
CMAKE_GENERATOR=Unix Makefiles
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
- job: linux_amd64_trusty_clang_mbedtls
displayName: 'Linux (amd64; Trusty; Clang; mbedTLS)'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- template: azure-pipelines/docker.yml
parameters:
imageName: 'libgit2/trusty-amd64:latest'
environmentVariables: |
CC=clang
CMAKE_GENERATOR=Unix Makefiles
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
- job: macos
displayName: 'macOS'
pool:
vmImage: 'macOS 10.13'
steps:
- bash: . '$(Build.SourcesDirectory)/azure-pipelines/setup-osx.sh'
displayName: Setup
- template: azure-pipelines/bash.yml
parameters:
environmentVariables:
TMPDIR: $(Agent.TempDirectory)
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks
SKIP_SSH_TESTS: true
- job: windows_vs_amd64
displayName: 'Windows (amd64; Visual Studio)'
pool: Hosted
steps:
- template: azure-pipelines/bash.yml
parameters:
environmentVariables:
CMAKE_GENERATOR: Visual Studio 12 2013 Win64
CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON
SKIP_SSH_TESTS: true
- job: windows_vs_x86
displayName: 'Windows (x86; Visual Studio)'
pool: Hosted
steps:
- template: azure-pipelines/bash.yml
parameters:
environmentVariables:
CMAKE_GENERATOR: Visual Studio 12 2013
CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS
SKIP_SSH_TESTS: true
- job: windows_mingw_amd64
displayName: 'Windows (amd64; MinGW)'
pool: Hosted
steps:
- bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
displayName: Setup
env:
TEMP: $(Agent.TempDirectory)
ARCH: amd64
- template: azure-pipelines/bash.yml
parameters:
environmentVariables:
BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
CMAKE_GENERATOR: MinGW Makefiles
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
SKIP_SSH_TESTS: true
- job: windows_mingw_x86
displayName: 'Windows (x86; MinGW)'
pool: Hosted
steps:
- bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
displayName: Setup
workingDirectory: '$(Build.BinariesDirectory)'
env:
TEMP: $(Agent.TempDirectory)
ARCH: x86
- template: azure-pipelines/bash.yml
parameters:
environmentVariables:
BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
CMAKE_GENERATOR: MinGW Makefiles
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
SKIP_SSH_TESTS: true
- job: documentation
displayName: 'Generate Documentation'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- script: |
git config user.name 'Documentation Generation'
git config user.email 'libgit2@users.noreply.github.com'
git branch gh-pages origin/gh-pages
docker run --rm -v $(Build.SourcesDirectory):/src -w /src libgit2/docurium:latest cm doc api.docurium
git checkout gh-pages
cp -R * '$(Build.BinariesDirectory)'
displayName: 'Generate Documentation'
- task: archivefiles@2
displayName: 'Archive Documentation'
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/api-documentation.zip'
- task: publishbuildartifacts@1
displayName: 'Upload Documentation Artifact'
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'docs'
- script: |
git remote -v
echo 'machine github.com' > ~/.netrc
echo 'login $(GITHUB_USERNAME)' >> ~/.netrc
echo 'password $(GITHUB_PAT)' >> ~/.netrc
git push origin gh-pages
displayName: 'Publish Documentation'
condition: eq(variables['Build.Reason'], 'IndividualCI')

View File

@@ -1,17 +0,0 @@
# These are the steps used for building on machines with bash.
steps:
- bash: . '$(Build.SourcesDirectory)/azure-pipelines/build.sh'
displayName: Build
workingDirectory: '$(Build.BinariesDirectory)'
env: ${{ parameters.environmentVariables }}
- bash: . '$(Build.SourcesDirectory)/azure-pipelines/test.sh'
displayName: Test
workingDirectory: '$(Build.BinariesDirectory)'
env: ${{ parameters.environmentVariables }}
- task: PublishTestResults@2
displayName: Publish Test Results
condition: succeededOrFailed()
inputs:
testResultsFiles: 'results_*.xml'
searchFolder: '$(Build.BinariesDirectory)'
mergeTestResults: true

View File

@@ -1,55 +0,0 @@
#!/usr/bin/env bash
#
# Environment variables:
#
# SOURCE_DIR: Set to the directory of the libgit2 source (optional)
# If not set, it will be derived relative to this script.
set -e
SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
BUILD_DIR=$(pwd)
BUILD_PATH=${BUILD_PATH:=$PATH}
CMAKE=$(which cmake)
indent() { sed "s/^/ /"; }
echo "Source directory: ${SOURCE_DIR}"
echo "Build directory: ${BUILD_DIR}"
echo ""
if [ "$(uname -s)" = "Darwin" ]; then
echo "macOS version:"
sw_vers | indent
fi
if [ -f "/etc/debian_version" ]; then
echo "Debian version:"
lsb_release -a | indent
fi
echo "Kernel version:"
uname -a 2>&1 | indent
echo "CMake version:"
env PATH="$BUILD_PATH" "$CMAKE" --version 2>&1 | indent
if test -n "$CC"; then
echo "Compiler version:"
"$CC" --version 2>&1 | indent
fi
echo ""
echo "##############################################################################"
echo "## Configuring build environment"
echo "##############################################################################"
echo cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G \"${CMAKE_GENERATOR}\" ${CMAKE_OPTIONS}
env PATH="$BUILD_PATH" "$CMAKE" ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G "${CMAKE_GENERATOR}" ${CMAKE_OPTIONS}
echo ""
echo "##############################################################################"
echo "## Building libgit2"
echo "##############################################################################"
env PATH="$BUILD_PATH" "$CMAKE" --build .

View File

@@ -1,41 +0,0 @@
#!/bin/bash
set -e
# Environment check
[ -z "$COVERITY_TOKEN" ] && echo "Need to set a coverity token" && exit 1
SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
BUILD_DIR=$(pwd)
case $(uname -m) in
i?86) BITS=32 ;;
amd64|x86_64) BITS=64 ;;
esac
SCAN_TOOL=https://scan.coverity.com/download/cxx/linux${BITS}
TOOL_BASE=$(pwd)/_coverity-scan
# Install coverity tools
if [ ! -d "$TOOL_BASE" ]; then
echo "Downloading coverity..."
mkdir -p "$TOOL_BASE"
pushd "$TOOL_BASE"
wget -O coverity_tool.tgz $SCAN_TOOL \
--post-data "project=libgit2&token=$COVERITY_TOKEN"
tar xzf coverity_tool.tgz
popd
TOOL_DIR=$(find "$TOOL_BASE" -type d -name 'cov-analysis*')
ln -s "$TOOL_DIR" "$TOOL_BASE"/cov-analysis
fi
cp "${SOURCE_DIR}/script/user_nodefs.h" "$TOOL_BASE"/cov-analysis/config/user_nodefs.h
COV_BUILD="$TOOL_BASE/cov-analysis/bin/cov-build"
# Configure and build
cmake ${SOURCE_DIR}
COVERITY_UNSUPPORTED=1 \
$COV_BUILD --dir cov-int \
cmake --build .

View File

@@ -1,33 +0,0 @@
#!/bin/bash
set -e
# Results check
[ ! -d "cov-int" ] && echo "Coverity directory not found" && exit 1
# Upload results
tar czf libgit2.tgz cov-int
SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
SHA=$(cd ${SOURCE_DIR} && git rev-parse --short HEAD)
HTML="$(curl \
--silent \
--write-out "\n%{http_code}" \
--form token="$COVERITY_TOKEN" \
--form email=libgit2@gmail.com \
--form file=@libgit2.tgz \
--form version="$SHA" \
--form description="libgit2 build" \
https://scan.coverity.com/builds?project=libgit2)"
# Body is everything up to the last line
BODY="$(echo "$HTML" | head -n-1)"
# Status code is the last line
STATUS_CODE="$(echo "$HTML" | tail -n1)"
if [ "${STATUS_CODE}" != "200" -a "${STATUS_CODE}" != "201" ]; then
echo "Received error code ${STATUS_CODE} from Coverity"
exit 1
fi

View File

@@ -1,36 +0,0 @@
resources:
- repo: self
jobs:
- job: coverity
displayName: 'Coverity'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- task: Docker@0
displayName: Build
inputs:
action: 'Run an image'
imageName: 'libgit2/trusty-openssl:latest'
volumes: |
$(Build.SourcesDirectory):/src
$(Build.BinariesDirectory):/build
envVars: |
COVERITY_TOKEN=$(COVERITY_TOKEN)
workDir: '/build'
containerCommand: '/src/azure-pipelines/coverity-build.sh'
detached: false
- task: Docker@0
displayName: Publish
inputs:
action: 'Run an image'
imageName: 'libgit2/trusty-openssl:latest'
volumes: |
$(Build.SourcesDirectory):/src
$(Build.BinariesDirectory):/build
envVars: |
COVERITY_TOKEN=$(COVERITY_TOKEN)
workDir: '/build'
containerCommand: '/src/azure-pipelines/coverity-publish.sh'
detached: false
continueOnError: true

View File

@@ -1,37 +0,0 @@
# These are the steps used in a container-based build in VSTS.
steps:
- ${{ if eq(parameters.qemu, 'true') }}:
- script: docker run --rm --privileged multiarch/qemu-user-static:register --reset
displayName: 'Register Docker QEMU'
- task: docker@0
displayName: Build
inputs:
action: 'Run an image'
imageName: ${{ parameters.imageName }}
volumes: |
$(Build.SourcesDirectory):/src
$(Build.BinariesDirectory):/build
envVars: ${{ parameters.environmentVariables }}
workDir: '/build'
containerCommand: '/src/azure-pipelines/build.sh'
detached: false
- task: docker@0
displayName: Test
inputs:
action: 'Run an image'
imageName: ${{ parameters.imageName }}
volumes: |
$(Build.SourcesDirectory):/src
$(Build.BinariesDirectory):/build
envVars: ${{ parameters.environmentVariables }}
workDir: '/build'
containerCommand: '/src/azure-pipelines/test.sh'
detached: false
- task: publishtestresults@2
displayName: Publish Test Results
condition: succeededOrFailed()
inputs:
testResultsFiles: 'results_*.xml'
searchFolder: '$(Build.BinariesDirectory)'
mergeTestResults: true

View File

@@ -1,199 +0,0 @@
resources:
- repo: self
jobs:
- job: linux_amd64_trusty_gcc_openssl
displayName: 'Linux (amd64; Trusty; GCC; OpenSSL)'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- template: docker.yml
parameters:
imageName: 'libgit2/trusty-amd64:latest'
environmentVariables: |
CC=gcc
CMAKE_GENERATOR=Unix Makefiles
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
RUN_INVASIVE_TESTS=true
- job: linux_amd64_trusty_gcc_mbedtls
displayName: 'Linux (amd64; Trusty; GCC; mbedTLS)'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- template: docker.yml
parameters:
imageName: 'libgit2/trusty-amd64:latest'
environmentVariables: |
CC=gcc
CMAKE_GENERATOR=Unix Makefiles
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
RUN_INVASIVE_TESTS=true
- job: linux_amd64_trusty_clang_openssl
displayName: 'Linux (amd64; Trusty; Clang; OpenSSL)'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- template: docker.yml
parameters:
imageName: 'libgit2/trusty-amd64:latest'
environmentVariables: |
CC=clang
CMAKE_GENERATOR=Unix Makefiles
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
RUN_INVASIVE_TESTS=true
- job: linux_amd64_trusty_clang_mbedtls
displayName: 'Linux (amd64; Trusty; Clang; mbedTLS)'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- template: docker.yml
parameters:
imageName: 'libgit2/trusty-amd64:latest'
environmentVariables: |
CC=clang
CMAKE_GENERATOR=Unix Makefiles
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
RUN_INVASIVE_TESTS=true
- job: macos
displayName: 'macOS'
pool:
vmImage: 'macOS 10.13'
steps:
- bash: . '$(Build.SourcesDirectory)/azure-pipelines/setup-osx.sh'
displayName: Setup
- template: bash.yml
parameters:
environmentVariables:
TMPDIR: $(Agent.TempDirectory)
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks
RUN_INVASIVE_TESTS: true
SKIP_SSH_TESTS: true
- job: windows_vs_amd64
displayName: 'Windows (amd64; Visual Studio)'
pool: Hosted
steps:
- template: bash.yml
parameters:
environmentVariables:
CMAKE_GENERATOR: Visual Studio 12 2013 Win64
CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON
RUN_INVASIVE_TESTS: true
SKIP_SSH_TESTS: true
- job: windows_vs_x86
displayName: 'Windows (x86; Visual Studio)'
pool: Hosted
steps:
- template: bash.yml
parameters:
environmentVariables:
CMAKE_GENERATOR: Visual Studio 12 2013
CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS
RUN_INVASIVE_TESTS: true
SKIP_SSH_TESTS: true
- job: windows_mingw_amd64
displayName: 'Windows (amd64; MinGW)'
pool: Hosted
steps:
- bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
displayName: Setup
env:
TEMP: $(Agent.TempDirectory)
ARCH: amd64
- template: bash.yml
parameters:
environmentVariables:
BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
CMAKE_GENERATOR: MinGW Makefiles
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
RUN_INVASIVE_TESTS: true
SKIP_SSH_TESTS: true
- job: windows_mingw_x86
displayName: 'Windows (x86; MinGW)'
pool: Hosted
steps:
- bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
displayName: Setup
workingDirectory: '$(Build.BinariesDirectory)'
env:
TEMP: $(Agent.TempDirectory)
ARCH: x86
- template: bash.yml
parameters:
environmentVariables:
BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
CMAKE_GENERATOR: MinGW Makefiles
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
RUN_INVASIVE_TESTS: true
SKIP_SSH_TESTS: true
- job: linux_x86_bionic_gcc_openssl
displayName: 'Linux (x86; Bionic; GCC; OpenSSL)'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- template: docker.yml
parameters:
qemu: 'true'
imageName: 'libgit2/bionic-x86:latest'
environmentVariables: |
CC=gcc
CMAKE_GENERATOR=Unix Makefiles
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
RUN_INVASIVE_TESTS=true
- job: linux_x86_bionic_clang_openssl
displayName: 'Linux (x86; Bionic; Clang; OpenSSL)'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- template: docker.yml
parameters:
qemu: 'true'
imageName: 'libgit2/bionic-x86:latest'
environmentVariables: |
CC=clang
CMAKE_GENERATOR=Unix Makefiles
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
RUN_INVASIVE_TESTS=true
- job: linux_arm32_bionic_gcc_openssl
displayName: 'Linux (arm32; Bionic; GCC; OpenSSL)'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- template: docker.yml
parameters:
qemu: 'true'
imageName: 'libgit2/bionic-arm32:latest'
environmentVariables: |
CC=gcc
CMAKE_GENERATOR=Unix Makefiles
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
RUN_INVASIVE_TESTS=true
SKIP_PROXY_TESTS=true
- job: linux_arm64_bionic_gcc_openssl
displayName: 'Linux (arm64; Bionic; GCC; OpenSSL)'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- template: docker.yml
parameters:
qemu: 'true'
imageName: 'libgit2/bionic-arm64:latest'
environmentVariables: |
CC=gcc
CMAKE_GENERATOR=Unix Makefiles
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
RUN_INVASIVE_TESTS=true
SKIP_PROXY_TESTS=true

View File

@@ -1,27 +0,0 @@
#!/bin/sh
set -e
set -x
TMPDIR=${TMPDIR:-/tmp}
if [ -z "$SKIP_APT" ]; then
apt-get update
apt-get -y install build-essential pkg-config clang cmake openssl libssl-dev libssh2-1-dev libcurl4-gnutls-dev openssh-server
fi
mkdir -p /var/run/sshd
if [ "$MBEDTLS" ]; then
MBEDTLS_DIR=${MBEDTLS_DIR:-$(mktemp -d ${TMPDIR}/mbedtls.XXXXXXXX)}
git clone --depth 10 --single-branch --branch mbedtls-2.6.1 https://github.com/ARMmbed/mbedtls.git ${MBEDTLS_DIR}
cd ${MBEDTLS_DIR}
CFLAGS=-fPIC cmake -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DUSE_STATIC_MBEDTLS_LIBRARY=ON .
cmake --build .
if [ -z "$SKIP_MBEDTLS_INSTALL" ]; then
make install
fi
fi

View File

@@ -1,15 +0,0 @@
#!/bin/sh -e
echo "##############################################################################"
echo "## Downloading mingw"
echo "##############################################################################"
case "$ARCH" in
amd64)
MINGW_URI="https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-x86_64-8.1.0-release-win32-seh-rt_v6-rev0.zip";;
x86)
MINGW_URI="https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-i686-8.1.0-release-win32-sjlj-rt_v6-rev0.zip";;
esac
curl -s -L "$MINGW_URI" -o "$TEMP"/mingw-"$ARCH".zip
unzip -q "$TEMP"/mingw-"$ARCH".zip -d "$TEMP"

View File

@@ -1,8 +0,0 @@
#!/bin/sh
set -x
brew update
brew install pkgconfig zlib curl openssl libssh2 ninja
ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libLeaksAtExit.dylib /usr/local/lib

View File

@@ -1,247 +0,0 @@
#!/usr/bin/env bash
set -e
if [ -n "$SKIP_TESTS" ]; then
exit 0
fi
SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
BUILD_DIR=$(pwd)
TMPDIR=${TMPDIR:-/tmp}
USER=${USER:-$(whoami)}
SUCCESS=1
cleanup() {
echo "Cleaning up..."
if [ ! -z "$GITDAEMON_PID" ]; then
echo "Stopping git daemon..."
kill $GITDAEMON_PID
fi
if [ ! -z "$SSHD_DIR" -a -f "${SSHD_DIR}/pid" ]; then
echo "Stopping SSH..."
kill $(cat "${SSHD_DIR}/pid")
fi
echo "Done."
}
run_test() {
if [[ "$GITTEST_FLAKY_RETRY" > 0 ]]; then
ATTEMPTS_REMAIN=$GITTEST_FLAKY_RETRY
else
ATTEMPTS_REMAIN=1
fi
FAILED=0
while [[ "$ATTEMPTS_REMAIN" > 0 ]]; do
if [ "$FAILED" -eq 1 ]; then
echo ""
echo "Re-running flaky ${1} tests..."
echo ""
fi
RETURN_CODE=0
CLAR_SUMMARY="${BUILD_DIR}/results_${1}.xml" ctest -V -R "^${1}$" || RETURN_CODE=$? && true
if [ "$RETURN_CODE" -eq 0 ]; then
break
fi
echo "Test exited with code: $RETURN_CODE"
ATTEMPTS_REMAIN="$(($ATTEMPTS_REMAIN-1))"
FAILED=1
done
if [ "$FAILED" -ne 0 ]; then
SUCCESS=0
fi
}
# Configure the test environment; run them early so that we're certain
# that they're started by the time we need them.
echo "##############################################################################"
echo "## Configuring test environment"
echo "##############################################################################"
if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
echo "Starting git daemon..."
GITDAEMON_DIR=`mktemp -d ${TMPDIR}/gitdaemon.XXXXXXXX`
git init --bare "${GITDAEMON_DIR}/test.git"
git daemon --listen=localhost --export-all --enable=receive-pack --base-path="${GITDAEMON_DIR}" "${GITDAEMON_DIR}" 2>/dev/null &
GITDAEMON_PID=$!
fi
if [ -z "$SKIP_PROXY_TESTS" ]; then
curl -L https://github.com/ethomson/poxyproxy/releases/download/v0.7.0/poxyproxy-0.7.0.jar >poxyproxy.jar
echo ""
echo "Starting HTTP proxy (Basic)..."
java -jar poxyproxy.jar --address 127.0.0.1 --port 8080 --credentials foo:bar --auth-type basic --quiet &
echo ""
echo "Starting HTTP proxy (NTLM)..."
java -jar poxyproxy.jar --address 127.0.0.1 --port 8090 --credentials foo:bar --auth-type ntlm --quiet &
fi
if [ -z "$SKIP_SSH_TESTS" ]; then
echo "Starting ssh daemon..."
HOME=`mktemp -d ${TMPDIR}/home.XXXXXXXX`
SSHD_DIR=`mktemp -d ${TMPDIR}/sshd.XXXXXXXX`
git init --bare "${SSHD_DIR}/test.git"
cat >"${SSHD_DIR}/sshd_config" <<-EOF
Port 2222
ListenAddress 0.0.0.0
Protocol 2
HostKey ${SSHD_DIR}/id_rsa
PidFile ${SSHD_DIR}/pid
AuthorizedKeysFile ${HOME}/.ssh/authorized_keys
LogLevel DEBUG
RSAAuthentication yes
PasswordAuthentication yes
PubkeyAuthentication yes
ChallengeResponseAuthentication no
StrictModes no
# Required here as sshd will simply close connection otherwise
UsePAM no
EOF
ssh-keygen -t rsa -f "${SSHD_DIR}/id_rsa" -N "" -q
/usr/sbin/sshd -f "${SSHD_DIR}/sshd_config" -E "${SSHD_DIR}/log"
# Set up keys
mkdir "${HOME}/.ssh"
ssh-keygen -t rsa -f "${HOME}/.ssh/id_rsa" -N "" -q
cat "${HOME}/.ssh/id_rsa.pub" >>"${HOME}/.ssh/authorized_keys"
while read algorithm key comment; do
echo "[localhost]:2222 $algorithm $key" >>"${HOME}/.ssh/known_hosts"
done <"${SSHD_DIR}/id_rsa.pub"
# Get the fingerprint for localhost and remove the colons so we can
# parse it as a hex number. Older versions have a different output
# format.
if [[ $(ssh -V 2>&1) == OpenSSH_6* ]]; then
SSH_FINGERPRINT=$(ssh-keygen -F '[localhost]:2222' -f "${HOME}/.ssh/known_hosts" -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':')
else
SSH_FINGERPRINT=$(ssh-keygen -E md5 -F '[localhost]:2222' -f "${HOME}/.ssh/known_hosts" -l | tail -n 1 | cut -d ' ' -f 3 | cut -d : -f2- | tr -d :)
fi
fi
# Run the tests that do not require network connectivity.
if [ -z "$SKIP_OFFLINE_TESTS" ]; then
echo ""
echo "##############################################################################"
echo "## Running (offline) tests"
echo "##############################################################################"
run_test offline
fi
if [ -n "$RUN_INVASIVE_TESTS" ]; then
echo ""
echo "Running invasive tests"
echo ""
export GITTEST_INVASIVE_FS_SIZE=1
export GITTEST_INVASIVE_MEMORY=1
export GITTEST_INVASIVE_SPEED=1
run_test invasive
unset GITTEST_INVASIVE_FS_SIZE
unset GITTEST_INVASIVE_MEMORY
unset GITTEST_INVASIVE_SPEED
fi
if [ -z "$SKIP_ONLINE_TESTS" ]; then
# Run the various online tests. The "online" test suite only includes the
# default online tests that do not require additional configuration. The
# "proxy" and "ssh" test suites require further setup.
echo ""
echo "##############################################################################"
echo "## Running (online) tests"
echo "##############################################################################"
export GITTEST_FLAKY_RETRY=5
run_test online
unset GITTEST_FLAKY_RETRY
fi
if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
echo ""
echo "Running gitdaemon tests"
echo ""
export GITTEST_REMOTE_URL="git://localhost/test.git"
run_test gitdaemon
unset GITTEST_REMOTE_URL
fi
if [ -z "$SKIP_PROXY_TESTS" ]; then
echo ""
echo "Running proxy tests (Basic authentication)"
echo ""
export GITTEST_REMOTE_PROXY_HOST="localhost:8080"
export GITTEST_REMOTE_PROXY_USER="foo"
export GITTEST_REMOTE_PROXY_PASS="bar"
run_test proxy
unset GITTEST_REMOTE_PROXY_HOST
unset GITTEST_REMOTE_PROXY_USER
unset GITTEST_REMOTE_PROXY_PASS
echo ""
echo "Running proxy tests (NTLM authentication)"
echo ""
export GITTEST_REMOTE_PROXY_HOST="localhost:8090"
export GITTEST_REMOTE_PROXY_USER="foo"
export GITTEST_REMOTE_PROXY_PASS="bar"
run_test proxy
unset GITTEST_REMOTE_PROXY_HOST
unset GITTEST_REMOTE_PROXY_USER
unset GITTEST_REMOTE_PROXY_PASS
fi
if [ -z "$SKIP_SSH_TESTS" ]; then
echo ""
echo "Running ssh tests"
echo ""
export GITTEST_REMOTE_URL="ssh://localhost:2222/$SSHD_DIR/test.git"
export GITTEST_REMOTE_USER=$USER
export GITTEST_REMOTE_SSH_KEY="${HOME}/.ssh/id_rsa"
export GITTEST_REMOTE_SSH_PUBKEY="${HOME}/.ssh/id_rsa.pub"
export GITTEST_REMOTE_SSH_PASSPHRASE=""
export GITTEST_REMOTE_SSH_FINGERPRINT="${SSH_FINGERPRINT}"
run_test ssh
unset GITTEST_REMOTE_URL
unset GITTEST_REMOTE_USER
unset GITTEST_REMOTE_SSH_KEY
unset GITTEST_REMOTE_SSH_PUBKEY
unset GITTEST_REMOTE_SSH_PASSPHRASE
unset GITTEST_REMOTE_SSH_FINGERPRINT
fi
if [ -z "$SKIP_FUZZERS" ]; then
echo ""
echo "##############################################################################"
echo "## Running fuzzers"
echo "##############################################################################"
ctest -V -R 'fuzzer'
fi
cleanup
if [ "$SUCCESS" -ne 1 ]; then
echo "Some tests failed."
exit 1
fi
echo "Success."
exit 0

View File

@@ -1,30 +0,0 @@
# - Append compiler flag to CMAKE_C_FLAGS if compiler supports it
# ADD_C_FLAG_IF_SUPPORTED(<flag>)
# <flag> - the compiler flag to test
# This internally calls the CHECK_C_COMPILER_FLAG macro.
INCLUDE(CheckCCompilerFlag)
MACRO(ADD_C_FLAG _FLAG)
STRING(TOUPPER ${_FLAG} UPCASE)
STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
IF(IS_${UPCASE_PRETTY}_SUPPORTED)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
ELSE()
MESSAGE(FATAL_ERROR "Required flag ${_FLAG} is not supported")
ENDIF()
ENDMACRO()
MACRO(ADD_C_FLAG_IF_SUPPORTED _FLAG)
STRING(TOUPPER ${_FLAG} UPCASE)
STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
IF(IS_${UPCASE_PRETTY}_SUPPORTED)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
ENDIF()
ENDMACRO()

View File

@@ -1,29 +0,0 @@
@CHECK_PROTOTYPE_DEFINITION_HEADER@
static void cmakeRequireSymbol(int dummy, ...) {
(void) dummy;
}
static void checkSymbol(void) {
#ifndef @CHECK_PROTOTYPE_DEFINITION_SYMBOL@
cmakeRequireSymbol(0, &@CHECK_PROTOTYPE_DEFINITION_SYMBOL@);
#endif
}
@CHECK_PROTOTYPE_DEFINITION_PROTO@ {
return @CHECK_PROTOTYPE_DEFINITION_RETURN@;
}
#ifdef __CLASSIC_C__
int main() {
int ac;
char*av[];
#else
int main(int ac, char *av[]) {
#endif
checkSymbol();
if (ac > 1000) {
return *av[0];
}
return 0;
}

View File

@@ -1,96 +0,0 @@
# - Check if the protoype we expect is correct.
# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE)
# FUNCTION - The name of the function (used to check if prototype exists)
# PROTOTYPE- The prototype to check.
# RETURN - The return value of the function.
# HEADER - The header files required.
# VARIABLE - The variable to store the result.
# Example:
# check_prototype_definition(getpwent_r
# "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)"
# "NULL"
# "unistd.h;pwd.h"
# SOLARIS_GETPWENT_R)
# The following variables may be set before calling this macro to
# modify the way the check is run:
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
# Copyright 2010-2011 Andreas Schneider <asn@cryptomilk.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
#
get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE)
if ("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n")
set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS})
if (CMAKE_REQUIRED_LIBRARIES)
set(CHECK_PROTOTYPE_DEFINITION_LIBS
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
else(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_PROTOTYPE_DEFINITION_LIBS)
endif(CMAKE_REQUIRED_LIBRARIES)
if (CMAKE_REQUIRED_INCLUDES)
set(CMAKE_SYMBOL_EXISTS_INCLUDES
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
else(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_SYMBOL_EXISTS_INCLUDES)
endif(CMAKE_REQUIRED_INCLUDES)
foreach(_FILE ${_HEADER})
set(CHECK_PROTOTYPE_DEFINITION_HEADER
"${CHECK_PROTOTYPE_DEFINITION_HEADER}#include <${_FILE}>\n")
endforeach(_FILE)
set(CHECK_PROTOTYPE_DEFINITION_SYMBOL ${_FUNCTION})
set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE})
set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN})
configure_file("${__check_proto_def_dir}/CheckPrototypeDefinition.c.in"
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY)
file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE)
try_compile(${_VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS}
"${CHECK_PROTOTYPE_DEFINITION_LIBS}"
"${CMAKE_SYMBOL_EXISTS_INCLUDES}"
OUTPUT_VARIABLE OUTPUT)
if (${_VARIABLE})
set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n"
"${OUTPUT}\n\n")
else (${_VARIABLE})
message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False")
set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n"
"${OUTPUT}\n\n${_SOURCE}\n\n")
endif (${_VARIABLE})
endif("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
endfunction(CHECK_PROTOTYPE_DEFINITION)

View File

@@ -1,15 +0,0 @@
MACRO(ENABLE_WARNINGS flag)
ADD_C_FLAG_IF_SUPPORTED(-W${flag})
ENDMACRO()
MACRO(DISABLE_WARNINGS flag)
ADD_C_FLAG_IF_SUPPORTED(-Wno-${flag})
ENDMACRO()
IF(ENABLE_WERROR)
IF(MSVC)
ADD_COMPILE_OPTIONS(-WX)
ELSE()
ADD_C_FLAG_IF_SUPPORTED(-Werror)
ENDIF()
ENDIF()

View File

@@ -1,26 +0,0 @@
# Find CoreFoundation.framework
# This will define :
#
# COREFOUNDATION_FOUND
# COREFOUNDATION_LIBRARIES
# COREFOUNDATION_LDFLAGS
#
FIND_PATH(COREFOUNDATION_INCLUDE_DIR NAMES CoreFoundation.h)
FIND_LIBRARY(COREFOUNDATION_LIBRARIES NAMES CoreFoundation)
IF (COREFOUNDATION_INCLUDE_DIR AND COREFOUNDATION_LIBRARIES)
IF (NOT CoreFoundation_FIND_QUIETLY)
MESSAGE("-- Found CoreFoundation ${COREFOUNDATION_LIBRARIES}")
ENDIF()
SET(COREFOUNDATION_FOUND TRUE)
SET(COREFOUNDATION_LDFLAGS "-framework CoreFoundation")
ENDIF ()
IF (CoreFoundation_FIND_REQUIRED AND NOT COREFOUNDATION_FOUND)
MESSAGE(FATAL "-- CoreFoundation not found")
ENDIF()
MARK_AS_ADVANCED(
COREFOUNDATION_INCLUDE_DIR
COREFOUNDATION_LIBRARIES
)

View File

@@ -1,324 +0,0 @@
# - Try to find GSSAPI
# Once done this will define
#
# KRB5_CONFIG - Path to krb5-config
# GSSAPI_ROOT_DIR - Set this variable to the root installation of GSSAPI
#
# Read-Only variables:
# GSSAPI_FLAVOR_MIT - set to TURE if MIT Kerberos has been found
# GSSAPI_FLAVOR_HEIMDAL - set to TRUE if Heimdal Kerberos has been found
# GSSAPI_FOUND - system has GSSAPI
# GSSAPI_INCLUDE_DIR - the GSSAPI include directory
# GSSAPI_LIBRARIES - Link these to use GSSAPI
# GSSAPI_DEFINITIONS - Compiler switches required for using GSSAPI
#
#=============================================================================
# Copyright (c) 2013 Andreas Schneider <asn@cryptomilk.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
#
find_path(GSSAPI_ROOT_DIR
NAMES
include/gssapi.h
include/gssapi/gssapi.h
HINTS
${_GSSAPI_ROOT_HINTS}
PATHS
${_GSSAPI_ROOT_PATHS}
)
mark_as_advanced(GSSAPI_ROOT_DIR)
if (UNIX)
find_program(KRB5_CONFIG
NAMES
krb5-config
PATHS
${GSSAPI_ROOT_DIR}/bin
/opt/local/bin)
mark_as_advanced(KRB5_CONFIG)
if (KRB5_CONFIG)
# Check if we have MIT KRB5
execute_process(
COMMAND
${KRB5_CONFIG} --vendor
RESULT_VARIABLE
_GSSAPI_VENDOR_RESULT
OUTPUT_VARIABLE
_GSSAPI_VENDOR_STRING)
if (_GSSAPI_VENDOR_STRING MATCHES ".*Massachusetts.*")
set(GSSAPI_FLAVOR_MIT TRUE)
else()
execute_process(
COMMAND
${KRB5_CONFIG} --libs gssapi
RESULT_VARIABLE
_GSSAPI_LIBS_RESULT
OUTPUT_VARIABLE
_GSSAPI_LIBS_STRING)
if (_GSSAPI_LIBS_STRING MATCHES ".*roken.*")
set(GSSAPI_FLAVOR_HEIMDAL TRUE)
endif()
endif()
# Get the include dir
execute_process(
COMMAND
${KRB5_CONFIG} --cflags gssapi
RESULT_VARIABLE
_GSSAPI_INCLUDE_RESULT
OUTPUT_VARIABLE
_GSSAPI_INCLUDE_STRING)
string(REGEX REPLACE "(\r?\n)+$" "" _GSSAPI_INCLUDE_STRING "${_GSSAPI_INCLUDE_STRING}")
string(REGEX REPLACE " *-I" "" _GSSAPI_INCLUDEDIR "${_GSSAPI_INCLUDE_STRING}")
endif()
if (NOT GSSAPI_FLAVOR_MIT AND NOT GSSAPI_FLAVOR_HEIMDAL)
# Check for HEIMDAL
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_GSSAPI heimdal-gssapi)
endif (PKG_CONFIG_FOUND)
if (_GSSAPI_FOUND)
set(GSSAPI_FLAVOR_HEIMDAL TRUE)
else()
find_path(_GSSAPI_ROKEN
NAMES
roken.h
PATHS
${GSSAPI_ROOT_DIR}/include
${_GSSAPI_INCLUDEDIR})
if (_GSSAPI_ROKEN)
set(GSSAPI_FLAVOR_HEIMDAL TRUE)
endif()
endif ()
endif()
endif (UNIX)
find_path(GSSAPI_INCLUDE_DIR
NAMES
gssapi.h
gssapi/gssapi.h
PATHS
${GSSAPI_ROOT_DIR}/include
${_GSSAPI_INCLUDEDIR}
)
if (GSSAPI_FLAVOR_MIT)
find_library(GSSAPI_LIBRARY
NAMES
gssapi_krb5
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(KRB5_LIBRARY
NAMES
krb5
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(K5CRYPTO_LIBRARY
NAMES
k5crypto
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(COM_ERR_LIBRARY
NAMES
com_err
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
if (GSSAPI_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${GSSAPI_LIBRARY}
)
endif (GSSAPI_LIBRARY)
if (KRB5_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${KRB5_LIBRARY}
)
endif (KRB5_LIBRARY)
if (K5CRYPTO_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${K5CRYPTO_LIBRARY}
)
endif (K5CRYPTO_LIBRARY)
if (COM_ERR_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${COM_ERR_LIBRARY}
)
endif (COM_ERR_LIBRARY)
endif (GSSAPI_FLAVOR_MIT)
if (GSSAPI_FLAVOR_HEIMDAL)
find_library(GSSAPI_LIBRARY
NAMES
gssapi
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(KRB5_LIBRARY
NAMES
krb5
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(HCRYPTO_LIBRARY
NAMES
hcrypto
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(COM_ERR_LIBRARY
NAMES
com_err
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(HEIMNTLM_LIBRARY
NAMES
heimntlm
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(HX509_LIBRARY
NAMES
hx509
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(ASN1_LIBRARY
NAMES
asn1
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(WIND_LIBRARY
NAMES
wind
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(ROKEN_LIBRARY
NAMES
roken
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
if (GSSAPI_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${GSSAPI_LIBRARY}
)
endif (GSSAPI_LIBRARY)
if (KRB5_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${KRB5_LIBRARY}
)
endif (KRB5_LIBRARY)
if (HCRYPTO_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${HCRYPTO_LIBRARY}
)
endif (HCRYPTO_LIBRARY)
if (COM_ERR_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${COM_ERR_LIBRARY}
)
endif (COM_ERR_LIBRARY)
if (HEIMNTLM_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${HEIMNTLM_LIBRARY}
)
endif (HEIMNTLM_LIBRARY)
if (HX509_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${HX509_LIBRARY}
)
endif (HX509_LIBRARY)
if (ASN1_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${ASN1_LIBRARY}
)
endif (ASN1_LIBRARY)
if (WIND_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${WIND_LIBRARY}
)
endif (WIND_LIBRARY)
if (ROKEN_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${WIND_LIBRARY}
)
endif (ROKEN_LIBRARY)
endif (GSSAPI_FLAVOR_HEIMDAL)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GSSAPI DEFAULT_MSG GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIR)
if (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
set(GSSAPI_FOUND TRUE)
endif (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
# show the GSSAPI_INCLUDE_DIRS and GSSAPI_LIBRARIES variables only in the advanced view
mark_as_advanced(GSSAPI_INCLUDE_DIRS GSSAPI_LIBRARIES)

View File

@@ -1,39 +0,0 @@
# - Try to find http-parser
#
# Defines the following variables:
#
# HTTP_PARSER_FOUND - system has http-parser
# HTTP_PARSER_INCLUDE_DIR - the http-parser include directory
# HTTP_PARSER_LIBRARIES - Link these to use http-parser
# HTTP_PARSER_VERSION_MAJOR - major version
# HTTP_PARSER_VERSION_MINOR - minor version
# HTTP_PARSER_VERSION_STRING - the version of http-parser found
# Find the header and library
FIND_PATH(HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h)
FIND_LIBRARY(HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser)
# Found the header, read version
if (HTTP_PARSER_INCLUDE_DIR AND EXISTS "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h")
FILE(READ "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h" HTTP_PARSER_H)
IF (HTTP_PARSER_H)
STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MAJOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MAJOR "${HTTP_PARSER_H}")
STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MINOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MINOR "${HTTP_PARSER_H}")
SET(HTTP_PARSER_VERSION_STRING "${HTTP_PARSER_VERSION_MAJOR}.${HTTP_PARSER_VERSION_MINOR}")
ENDIF()
UNSET(HTTP_PARSER_H)
ENDIF()
# Handle the QUIETLY and REQUIRED arguments and set HTTP_PARSER_FOUND
# to TRUE if all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
# Hide advanced variables
MARK_AS_ADVANCED(HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
# Set standard variables
IF (HTTP_PARSER_FOUND)
SET(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY})
set(HTTP_PARSER_INCLUDE_DIRS ${HTTP_PARSER_INCLUDE_DIR})
ENDIF()

View File

@@ -1,45 +0,0 @@
# - Try to find Iconv
# Once done this will define
#
# ICONV_FOUND - system has Iconv
# ICONV_INCLUDE_DIR - the Iconv include directory
# ICONV_LIBRARIES - Link these to use Iconv
#
IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
# Already in cache, be silent
SET(ICONV_FIND_QUIETLY TRUE)
ENDIF()
FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
CHECK_FUNCTION_EXISTS(iconv_open libc_has_iconv)
FIND_LIBRARY(iconv_lib NAMES iconv libiconv libiconv-2 c)
IF(ICONV_INCLUDE_DIR AND libc_has_iconv)
SET(ICONV_FOUND TRUE)
SET(ICONV_LIBRARIES "")
IF(NOT ICONV_FIND_QUIETLY)
MESSAGE(STATUS "Found Iconv: provided by libc")
ENDIF(NOT ICONV_FIND_QUIETLY)
ELSEIF(ICONV_INCLUDE_DIR AND iconv_lib)
SET(ICONV_FOUND TRUE)
# split iconv into -L and -l linker options, so we can
# set them for pkg-config
GET_FILENAME_COMPONENT(iconv_path ${iconv_lib} PATH)
GET_FILENAME_COMPONENT(iconv_name ${iconv_lib} NAME_WE)
STRING(REGEX REPLACE "^lib" "" iconv_name ${iconv_name})
SET(ICONV_LIBRARIES "-L${iconv_path} -l${iconv_name}")
IF(NOT ICONV_FIND_QUIETLY)
MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
ENDIF(NOT ICONV_FIND_QUIETLY)
ELSE()
IF(Iconv_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Iconv")
ENDIF(Iconv_FIND_REQUIRED)
ENDIF()
MARK_AS_ADVANCED(
ICONV_INCLUDE_DIR
ICONV_LIBRARIES
)

View File

@@ -1,38 +0,0 @@
# Copyright (C) 2007-2009 LuaDist.
# Created by Peter Kapec <kapecp@gmail.com>
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the COPYRIGHT file distributed with LuaDist.
# Note:
# Searching headers and libraries is very simple and is NOT as powerful as scripts
# distributed with CMake, because LuaDist defines directories to search for.
# Everyone is encouraged to contact the author with improvements. Maybe this file
# becomes part of CMake distribution sometimes.
# - Find pcre
# Find the native PCRE headers and libraries.
#
# PCRE_INCLUDE_DIRS - where to find pcre.h, etc.
# PCRE_LIBRARIES - List of libraries when using pcre.
# PCRE_FOUND - True if pcre found.
# Look for the header file.
FIND_PATH(PCRE_INCLUDE_DIR NAMES pcreposix.h)
# Look for the library.
FIND_LIBRARY(PCRE_LIBRARY NAMES pcre)
FIND_LIBRARY(PCRE_POSIX_LIBRARY NAMES pcreposix)
# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_POSIX_LIBRARY PCRE_INCLUDE_DIR)
# Copy the results to the output variables.
IF(PCRE_FOUND)
SET(PCRE_LIBRARIES ${PCRE_LIBRARY} ${PCRE_POSIX_LIBRARY})
SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
ELSE(PCRE_FOUND)
SET(PCRE_LIBRARIES)
SET(PCRE_INCLUDE_DIRS)
ENDIF(PCRE_FOUND)
MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES)

View File

@@ -1,38 +0,0 @@
# Copyright (C) 2007-2009 LuaDist.
# Created by Peter Kapec <kapecp@gmail.com>
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the COPYRIGHT file distributed with LuaDist.
# Note:
# Searching headers and libraries is very simple and is NOT as powerful as scripts
# distributed with CMake, because LuaDist defines directories to search for.
# Everyone is encouraged to contact the author with improvements. Maybe this file
# becomes part of CMake distribution sometimes.
# - Find pcre
# Find the native PCRE2 headers and libraries.
#
# PCRE2_INCLUDE_DIRS - where to find pcre.h, etc.
# PCRE2_LIBRARIES - List of libraries when using pcre.
# PCRE2_FOUND - True if pcre found.
# Look for the header file.
FIND_PATH(PCRE2_INCLUDE_DIR NAMES pcre2posix.h)
# Look for the library.
FIND_LIBRARY(PCRE2_LIBRARY NAMES pcre2-8)
FIND_LIBRARY(PCRE2_POSIX_LIBRARY NAMES pcre2-posix)
# Handle the QUIETLY and REQUIRED arguments and set PCRE2_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_POSIX_LIBRARY PCRE2_INCLUDE_DIR)
# Copy the results to the output variables.
IF(PCRE2_FOUND)
SET(PCRE2_LIBRARIES ${PCRE2_LIBRARY} ${PCRE2_POSIX_LIBRARY})
SET(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})
ELSE(PCRE2_FOUND)
SET(PCRE2_LIBRARIES)
SET(PCRE2_INCLUDE_DIRS)
ENDIF(PCRE2_FOUND)
MARK_AS_ADVANCED(PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES)

View File

@@ -1,28 +0,0 @@
INCLUDE(FindPkgConfig)
# This function will find and set up a pkg-config based module.
# If a pc-file was found, it will resolve library paths to
# absolute paths. Furthermore, the function will automatically
# fall back to use static libraries in case no dynamic libraries
# were found.
FUNCTION(FIND_PKGLIBRARIES prefix package)
PKG_CHECK_MODULES(${prefix} ${package})
IF(NOT ${prefix}_FOUND)
RETURN()
ENDIF()
FOREACH(LIBRARY ${${prefix}_LIBRARIES})
FIND_LIBRARY(${LIBRARY}_RESOLVED ${LIBRARY} PATHS ${${prefix}_LIBRARY_DIRS})
IF(${${LIBRARY}_RESOLVED} STREQUAL "${LIBRARY}_RESOLVED-NOTFOUND")
MESSAGE(FATAL_ERROR "could not resolve ${LIBRARY}")
ENDIF()
LIST(APPEND RESOLVED_LIBRARIES ${${LIBRARY}_RESOLVED})
ENDFOREACH(LIBRARY)
SET(${prefix}_FOUND 1 PARENT_SCOPE)
SET(${prefix}_LIBRARIES ${RESOLVED_LIBRARIES} PARENT_SCOPE)
SET(${prefix}_INCLUDE_DIRS ${${prefix}_INCLUDE_DIRS} PARENT_SCOPE)
SET(${prefix}_LDFLAGS ${${prefix}_LDFLAGS} PARENT_SCOPE)
MESSAGE(STATUS " Resolved libraries: ${RESOLVED_LIBRARIES}")
ENDFUNCTION()

View File

@@ -1,28 +0,0 @@
# Find Security.framework
# This will define :
#
# SECURITY_FOUND
# SECURITY_LIBRARIES
# SECURITY_LDFLAGS
# SECURITY_HAS_SSLCREATECONTEXT
#
FIND_PATH(SECURITY_INCLUDE_DIR NAMES Security/Security.h)
FIND_LIBRARY(SECURITY_LIBRARIES NAMES Security)
IF (SECURITY_INCLUDE_DIR AND SECURITY_LIBRARIES)
IF (NOT Security_FIND_QUIETLY)
MESSAGE("-- Found Security ${SECURITY_LIBRARIES}")
ENDIF()
SET(SECURITY_FOUND TRUE)
SET(SECURITY_LDFLAGS "-framework Security")
CHECK_LIBRARY_EXISTS("${SECURITY_LIBRARIES}" SSLCreateContext "Security/SecureTransport.h" SECURITY_HAS_SSLCREATECONTEXT)
ENDIF ()
IF (Security_FIND_REQUIRED AND NOT SECURITY_FOUND)
MESSAGE(FATAL "-- Security not found")
ENDIF()
MARK_AS_ADVANCED(
SECURITY_INCLUDE_DIR
SECURITY_LIBRARIES
)

View File

@@ -1,26 +0,0 @@
INCLUDE(FeatureSummary)
CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtim "sys/types.h;sys/stat.h"
HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C)
CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtimespec "sys/types.h;sys/stat.h"
HAVE_STRUCT_STAT_ST_MTIMESPEC LANGUAGE C)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_nsec sys/stat.h
HAVE_STRUCT_STAT_MTIME_NSEC LANGUAGE C)
IF (HAVE_STRUCT_STAT_ST_MTIM)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h
HAVE_STRUCT_STAT_NSEC LANGUAGE C)
ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h
HAVE_STRUCT_STAT_NSEC LANGUAGE C)
ELSE ()
SET( HAVE_STRUCT_STAT_NSEC ON )
ENDIF()
IF (HAVE_STRUCT_STAT_NSEC OR WIN32)
OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" ON )
ELSE()
SET(USE_NSEC OFF)
ENDIF()
ADD_FEATURE_INFO(nanoseconds USE_NSEC "whether to use sub-second file mtimes and ctimes")

View File

@@ -1,93 +0,0 @@
# - Try to find mbedTLS
# Once done this will define
#
# Read-Only variables
# MBEDTLS_FOUND - system has mbedTLS
# MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
# MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
# MBEDTLS_LIBRARIES - Link these to use mbedTLS
# MBEDTLS_LIBRARY - path to mbedTLS library
# MBEDX509_LIBRARY - path to mbedTLS X.509 library
# MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
#
# Hint
# MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation.
SET(_MBEDTLS_ROOT_HINTS
${MBEDTLS_ROOT_DIR}
ENV MBEDTLS_ROOT_DIR
)
SET(_MBEDTLS_ROOT_HINTS_AND_PATHS
HINTS ${_MBEDTLS_ROOT_HINTS}
PATHS ${_MBEDTLS_ROOT_PATHS}
)
FIND_PATH(MBEDTLS_INCLUDE_DIR
NAMES mbedtls/version.h
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES include
)
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
# Already in cache, be silent
SET(MBEDTLS_FIND_QUIETLY TRUE)
ENDIF()
FIND_LIBRARY(MBEDTLS_LIBRARY
NAMES mbedtls libmbedtls
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES library
)
FIND_LIBRARY(MBEDX509_LIBRARY
NAMES mbedx509 libmbedx509
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES library
)
FIND_LIBRARY(MBEDCRYPTO_LIBRARY
NAMES mbedcrypto libmbedcrypto
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES library
)
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
SET(MBEDTLS_FOUND TRUE)
ENDIF()
IF(MBEDTLS_FOUND)
# split mbedTLS into -L and -l linker options, so we can set them for pkg-config
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
IF(NOT MBEDTLS_FIND_QUIETLY)
MESSAGE(STATUS "Found mbedTLS:")
FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
IF (MBEDTLSMATCH)
STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
ENDIF(MBEDTLSMATCH)
MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
ENDIF(NOT MBEDTLS_FIND_QUIETLY)
ELSE(MBEDTLS_FOUND)
IF(MBEDTLS_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find mbedTLS")
ENDIF(MBEDTLS_FIND_REQUIRED)
ENDIF(MBEDTLS_FOUND)
MARK_AS_ADVANCED(
MBEDTLS_INCLUDE_DIR
MBEDTLS_LIBRARY_DIR
MBEDTLS_LIBRARIES
MBEDTLS_LIBRARY
MBEDX509_LIBRARY
MBEDCRYPTO_LIBRARY
)

View File

@@ -1,22 +0,0 @@
# This function splits the sources files up into their appropriate
# subdirectories. This is especially useful for IDEs like Xcode and
# Visual Studio, so that you can navigate into the libgit2_clar project,
# and see the folders within the tests folder (instead of just seeing all
# source and tests in a single folder.)
FUNCTION(IDE_SPLIT_SOURCES target)
IF(MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode)
GET_TARGET_PROPERTY(sources ${target} SOURCES)
FOREACH(source ${sources})
IF(source MATCHES ".*/")
STRING(REPLACE ${libgit2_SOURCE_DIR}/ "" rel ${source})
IF(rel)
STRING(REGEX REPLACE "/([^/]*)$" "" rel ${rel})
IF(rel)
STRING(REPLACE "/" "\\\\" rel ${rel})
SOURCE_GROUP(${rel} FILES ${source})
ENDIF()
ENDIF()
ENDIF()
ENDFOREACH()
ENDIF()
ENDFUNCTION()

View File

@@ -1,126 +0,0 @@
# Select the backend to use
# We try to find any packages our backends might use
FIND_PACKAGE(OpenSSL)
FIND_PACKAGE(mbedTLS)
IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
FIND_PACKAGE(Security)
FIND_PACKAGE(CoreFoundation)
ENDIF()
# Auto-select TLS backend
IF (USE_HTTPS STREQUAL ON)
message(ON)
IF (SECURITY_FOUND)
IF (SECURITY_HAS_SSLCREATECONTEXT)
SET(HTTPS_BACKEND "SecureTransport")
ELSE()
MESSAGE("-- Security framework is too old, falling back to OpenSSL")
SET(HTTPS_BACKEND "OpenSSL")
ENDIF()
ELSEIF (WINHTTP)
SET(HTTPS_BACKEND "WinHTTP")
ELSEIF(OPENSSL_FOUND)
SET(HTTPS_BACKEND "OpenSSL")
ELSEIF(MBEDTLS_FOUND)
SET(HTTPS_BACKEND "mbedTLS")
ELSE()
MESSAGE(FATAL_ERROR "Unable to autodetect a usable HTTPS backend."
"Please pass the backend name explicitly (-DUSE_HTTPS=backend)")
ENDIF()
ELSEIF(USE_HTTPS)
message(expl)
# HTTPS backend was explicitly set
SET(HTTPS_BACKEND ${USE_HTTPS})
ELSE()
SET(HTTPS_BACKEND NO)
ENDIF()
IF(HTTPS_BACKEND)
# Check that we can find what's required for the selected backend
IF (HTTPS_BACKEND STREQUAL "SecureTransport")
IF (NOT COREFOUNDATION_FOUND)
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, CoreFoundation.framework not found")
ENDIF()
IF (NOT SECURITY_FOUND)
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, Security.framework not found")
ENDIF()
IF (NOT SECURITY_HAS_SSLCREATECONTEXT)
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, SSLCreateContext not supported")
ENDIF()
SET(GIT_SECURE_TRANSPORT 1)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${SECURITY_INCLUDE_DIR})
LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LIBRARIES} ${SECURITY_LIBRARIES})
LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
ELSEIF (HTTPS_BACKEND STREQUAL "OpenSSL")
IF (NOT OPENSSL_FOUND)
MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
ENDIF()
SET(GIT_OPENSSL 1)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${OPENSSL_INCLUDE_DIR})
LIST(APPEND LIBGIT2_LIBS ${OPENSSL_LIBRARIES})
LIST(APPEND LIBGIT2_PC_LIBS ${OPENSSL_LDFLAGS})
LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
ELSEIF(HTTPS_BACKEND STREQUAL "mbedTLS")
IF (NOT MBEDTLS_FOUND)
MESSAGE(FATAL_ERROR "Asked for mbedTLS backend, but it wasn't found")
ENDIF()
IF(NOT CERT_LOCATION)
MESSAGE("Auto-detecting default certificates location")
IF(CMAKE_SYSTEM_NAME MATCHES Darwin)
# Check for an Homebrew installation
SET(OPENSSL_CMD "/usr/local/opt/openssl/bin/openssl")
ELSE()
SET(OPENSSL_CMD "openssl")
ENDIF()
EXECUTE_PROCESS(COMMAND ${OPENSSL_CMD} version -d OUTPUT_VARIABLE OPENSSL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(OPENSSL_DIR)
STRING(REGEX REPLACE "^OPENSSLDIR: \"(.*)\"$" "\\1/" OPENSSL_DIR ${OPENSSL_DIR})
SET(OPENSSL_CA_LOCATIONS
"ca-bundle.pem" # OpenSUSE Leap 42.1
"cert.pem" # Ubuntu 14.04, FreeBSD
"certs/ca-certificates.crt" # Ubuntu 16.04
"certs/ca.pem" # Debian 7
)
FOREACH(SUFFIX IN LISTS OPENSSL_CA_LOCATIONS)
SET(LOC "${OPENSSL_DIR}${SUFFIX}")
IF(NOT CERT_LOCATION AND EXISTS "${OPENSSL_DIR}${SUFFIX}")
SET(CERT_LOCATION ${LOC})
ENDIF()
ENDFOREACH()
ELSE()
MESSAGE("Unable to find OpenSSL executable. Please provide default certificate location via CERT_LOCATION")
ENDIF()
ENDIF()
IF(CERT_LOCATION)
IF(NOT EXISTS ${CERT_LOCATION})
MESSAGE(FATAL_ERROR "Cannot use CERT_LOCATION=${CERT_LOCATION} as it doesn't exist")
ENDIF()
ADD_FEATURE_INFO(CERT_LOCATION ON "using certificates from ${CERT_LOCATION}")
ADD_DEFINITIONS(-DGIT_DEFAULT_CERT_LOCATION="${CERT_LOCATION}")
ENDIF()
SET(GIT_MBEDTLS 1)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
# mbedTLS has no pkgconfig file, hence we can't require it
# https://github.com/ARMmbed/mbedtls/issues/228
# For now, pass its link flags as our own
LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
ELSEIF (HTTPS_BACKEND STREQUAL "WinHTTP")
# WinHTTP setup was handled in the WinHTTP-specific block above
ELSE()
MESSAGE(FATAL_ERROR "Asked for backend ${HTTPS_BACKEND} but it wasn't found")
ENDIF()
SET(GIT_HTTPS 1)
ADD_FEATURE_INFO(HTTPS GIT_HTTPS "using ${HTTPS_BACKEND}")
ELSE()
SET(GIT_HTTPS 0)
ADD_FEATURE_INFO(HTTPS NO "")
ENDIF()

View File

@@ -1,66 +0,0 @@
# Select a hash backend
# USE_SHA1=CollisionDetection(ON)/HTTPS/Generic/OFF
IF(USE_SHA1 STREQUAL ON OR USE_SHA1 STREQUAL "CollisionDetection")
SET(SHA1_BACKEND "CollisionDetection")
ELSEIF(USE_SHA1 STREQUAL "HTTPS")
message("Checking HTTPS backend… ${HTTPS_BACKEND}")
IF(HTTPS_BACKEND STREQUAL "SecureTransport")
SET(SHA1_BACKEND "CommonCrypto")
ELSEIF(HTTPS_BACKEND STREQUAL "WinHTTP")
SET(SHA1_BACKEND "Win32")
ELSEIF(HTTPS_BACKEND)
SET(SHA1_BACKEND ${HTTPS_BACKEND})
ELSE()
ENDIF()
IF(NOT HTTPS_BACKEND)
SET(SHA1_BACKEND "CollisionDetection")
ENDIF()
message(STATUS "Using SHA1 backend ${SHA1_BACKEND}")
ELSEIF(USE_SHA1 STREQUAL "Generic")
SET(SHA1_BACKEND "Generic")
# ELSEIF(NOT USE_SHA1)
ELSE()
MESSAGE(FATAL_ERROR "Invalid value for USE_SHA1: ${USE_SHA1}")
ENDIF()
IF(SHA1_BACKEND STREQUAL "CollisionDetection")
SET(GIT_SHA1_COLLISIONDETECT 1)
ADD_DEFINITIONS(-DSHA1DC_NO_STANDARD_INCLUDES=1)
ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\")
ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\")
FILE(GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
ELSEIF(SHA1_BACKEND STREQUAL "OpenSSL")
# OPENSSL_FOUND should already be set, we're checking HTTPS_BACKEND
SET(GIT_SHA1_OPENSSL 1)
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
LIST(APPEND LIBGIT2_PC_LIBS "-lssl")
ELSE()
LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
ENDIF()
FILE(GLOB SRC_SHA1 hash/sha1/openssl.*)
ELSEIF(SHA1_BACKEND STREQUAL "CommonCrypto")
SET(GIT_SHA1_COMMON_CRYPTO 1)
FILE(GLOB SRC_SHA1 hash/sha1/common_crypto.*)
ELSEIF(SHA1_BACKEND STREQUAL "mbedTLS")
SET(GIT_SHA1_MBEDTLS 1)
FILE(GLOB SRC_SHA1 hash/sha1/mbedtls.*)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
# mbedTLS has no pkgconfig file, hence we can't require it
# https://github.com/ARMmbed/mbedtls/issues/228
# For now, pass its link flags as our own
LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
ELSEIF(SHA1_BACKEND STREQUAL "Win32")
SET(GIT_SHA1_WIN32 1)
FILE(GLOB SRC_SHA1 hash/sha1/win32.*)
ELSEIF(SHA1_BACKEND STREQUAL "Generic")
FILE(GLOB SRC_SHA1 hash/sha1/generic.*)
# ELSEIF(NOT USE_SHA1)
ELSE()
MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend: ${SHA1_BACKEND}")
ENDIF()
ADD_FEATURE_INFO(SHA ON "using ${SHA1_BACKEND}")

View File

@@ -1,5 +0,0 @@
FILE(GLOB SRC_HTTP "*.c" "*.h")
ADD_LIBRARY(http-parser OBJECT ${SRC_HTTP})
ENABLE_WARNINGS(implicit-fallthrough=1)

View File

@@ -1,23 +0,0 @@
http_parser.c is based on src/http/ngx_http_parse.c from NGINX copyright
Igor Sysoev.
Additional changes are licensed under the same terms as NGINX and
copyright Joyent, Inc. and other Node contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

File diff suppressed because it is too large Load Diff

View File

@@ -1,305 +0,0 @@
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef http_parser_h
#define http_parser_h
#ifdef __cplusplus
extern "C" {
#endif
#define HTTP_PARSER_VERSION_MAJOR 2
#define HTTP_PARSER_VERSION_MINOR 0
#include <sys/types.h>
#if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600)
#include <BaseTsd.h>
typedef __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
typedef SIZE_T size_t;
typedef SSIZE_T ssize_t;
#elif defined(__sun) || defined(__sun__)
#include <sys/inttypes.h>
#else
#include <stdint.h>
#endif
/* Compile with -DHTTP_PARSER_STRICT=0 to make less checks, but run
* faster
*/
#ifndef HTTP_PARSER_STRICT
# define HTTP_PARSER_STRICT 1
#endif
/* Maximium header size allowed */
#define HTTP_MAX_HEADER_SIZE (80*1024)
typedef struct http_parser http_parser;
typedef struct http_parser_settings http_parser_settings;
/* Callbacks should return non-zero to indicate an error. The parser will
* then halt execution.
*
* The one exception is on_headers_complete. In a HTTP_RESPONSE parser
* returning '1' from on_headers_complete will tell the parser that it
* should not expect a body. This is used when receiving a response to a
* HEAD request which may contain 'Content-Length' or 'Transfer-Encoding:
* chunked' headers that indicate the presence of a body.
*
* http_data_cb does not return data chunks. It will be call arbitrarally
* many times for each string. E.G. you might get 10 callbacks for "on_url"
* each providing just a few characters more data.
*/
typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);
typedef int (*http_cb) (http_parser*);
/* Request Methods */
#define HTTP_METHOD_MAP(XX) \
XX(0, DELETE, DELETE) \
XX(1, GET, GET) \
XX(2, HEAD, HEAD) \
XX(3, POST, POST) \
XX(4, PUT, PUT) \
/* pathological */ \
XX(5, CONNECT, CONNECT) \
XX(6, OPTIONS, OPTIONS) \
XX(7, TRACE, TRACE) \
/* webdav */ \
XX(8, COPY, COPY) \
XX(9, LOCK, LOCK) \
XX(10, MKCOL, MKCOL) \
XX(11, MOVE, MOVE) \
XX(12, PROPFIND, PROPFIND) \
XX(13, PROPPATCH, PROPPATCH) \
XX(14, SEARCH, SEARCH) \
XX(15, UNLOCK, UNLOCK) \
/* subversion */ \
XX(16, REPORT, REPORT) \
XX(17, MKACTIVITY, MKACTIVITY) \
XX(18, CHECKOUT, CHECKOUT) \
XX(19, MERGE, MERGE) \
/* upnp */ \
XX(20, MSEARCH, M-SEARCH) \
XX(21, NOTIFY, NOTIFY) \
XX(22, SUBSCRIBE, SUBSCRIBE) \
XX(23, UNSUBSCRIBE, UNSUBSCRIBE) \
/* RFC-5789 */ \
XX(24, PATCH, PATCH) \
XX(25, PURGE, PURGE) \
enum http_method
{
#define XX(num, name, string) HTTP_##name = num,
HTTP_METHOD_MAP(XX)
#undef XX
};
enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
/* Flag values for http_parser.flags field */
enum flags
{ F_CHUNKED = 1 << 0
, F_CONNECTION_KEEP_ALIVE = 1 << 1
, F_CONNECTION_CLOSE = 1 << 2
, F_TRAILING = 1 << 3
, F_UPGRADE = 1 << 4
, F_SKIPBODY = 1 << 5
};
/* Map for errno-related constants
*
* The provided argument should be a macro that takes 2 arguments.
*/
#define HTTP_ERRNO_MAP(XX) \
/* No error */ \
XX(OK, "success") \
\
/* Callback-related errors */ \
XX(CB_message_begin, "the on_message_begin callback failed") \
XX(CB_url, "the on_url callback failed") \
XX(CB_header_field, "the on_header_field callback failed") \
XX(CB_header_value, "the on_header_value callback failed") \
XX(CB_headers_complete, "the on_headers_complete callback failed") \
XX(CB_body, "the on_body callback failed") \
XX(CB_message_complete, "the on_message_complete callback failed") \
\
/* Parsing-related errors */ \
XX(INVALID_EOF_STATE, "stream ended at an unexpected time") \
XX(HEADER_OVERFLOW, \
"too many header bytes seen; overflow detected") \
XX(CLOSED_CONNECTION, \
"data received after completed connection: close message") \
XX(INVALID_VERSION, "invalid HTTP version") \
XX(INVALID_STATUS, "invalid HTTP status code") \
XX(INVALID_METHOD, "invalid HTTP method") \
XX(INVALID_URL, "invalid URL") \
XX(INVALID_HOST, "invalid host") \
XX(INVALID_PORT, "invalid port") \
XX(INVALID_PATH, "invalid path") \
XX(INVALID_QUERY_STRING, "invalid query string") \
XX(INVALID_FRAGMENT, "invalid fragment") \
XX(LF_EXPECTED, "LF character expected") \
XX(INVALID_HEADER_TOKEN, "invalid character in header") \
XX(INVALID_CONTENT_LENGTH, \
"invalid character in content-length header") \
XX(INVALID_CHUNK_SIZE, \
"invalid character in chunk size header") \
XX(INVALID_CONSTANT, "invalid constant string") \
XX(INVALID_INTERNAL_STATE, "encountered unexpected internal state")\
XX(STRICT, "strict mode assertion failed") \
XX(PAUSED, "parser is paused") \
XX(UNKNOWN, "an unknown error occurred")
/* Define HPE_* values for each errno value above */
#define HTTP_ERRNO_GEN(n, s) HPE_##n,
enum http_errno {
HTTP_ERRNO_MAP(HTTP_ERRNO_GEN)
};
#undef HTTP_ERRNO_GEN
/* Get an http_errno value from an http_parser */
#define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno)
struct http_parser {
/** PRIVATE **/
unsigned char type : 2; /* enum http_parser_type */
unsigned char flags : 6; /* F_* values from 'flags' enum; semi-public */
unsigned char state; /* enum state from http_parser.c */
unsigned char header_state; /* enum header_state from http_parser.c */
unsigned char index; /* index into current matcher */
uint32_t nread; /* # bytes read in various scenarios */
uint64_t content_length; /* # bytes in body (0 if no Content-Length header) */
/** READ-ONLY **/
unsigned short http_major;
unsigned short http_minor;
unsigned short status_code; /* responses only */
unsigned char method; /* requests only */
unsigned char http_errno : 7;
/* 1 = Upgrade header was present and the parser has exited because of that.
* 0 = No upgrade header present.
* Should be checked when http_parser_execute() returns in addition to
* error checking.
*/
unsigned char upgrade : 1;
/** PUBLIC **/
void *data; /* A pointer to get hook to the "connection" or "socket" object */
};
struct http_parser_settings {
http_cb on_message_begin;
http_data_cb on_url;
http_data_cb on_header_field;
http_data_cb on_header_value;
http_cb on_headers_complete;
http_data_cb on_body;
http_cb on_message_complete;
};
enum http_parser_url_fields
{ UF_SCHEMA = 0
, UF_HOST = 1
, UF_PORT = 2
, UF_PATH = 3
, UF_QUERY = 4
, UF_FRAGMENT = 5
, UF_USERINFO = 6
, UF_MAX = 7
};
/* Result structure for http_parser_parse_url().
*
* Callers should index into field_data[] with UF_* values iff field_set
* has the relevant (1 << UF_*) bit set. As a courtesy to clients (and
* because we probably have padding left over), we convert any port to
* a uint16_t.
*/
struct http_parser_url {
uint16_t field_set; /* Bitmask of (1 << UF_*) values */
uint16_t port; /* Converted UF_PORT string */
struct {
uint16_t off; /* Offset into buffer in which field starts */
uint16_t len; /* Length of run in buffer */
} field_data[UF_MAX];
};
void http_parser_init(http_parser *parser, enum http_parser_type type);
size_t http_parser_execute(http_parser *parser,
const http_parser_settings *settings,
const char *data,
size_t len);
/* If http_should_keep_alive() in the on_headers_complete or
* on_message_complete callback returns 0, then this should be
* the last message on the connection.
* If you are the server, respond with the "Connection: close" header.
* If you are the client, close the connection.
*/
int http_should_keep_alive(const http_parser *parser);
/* Returns a string version of the HTTP method. */
const char *http_method_str(enum http_method m);
/* Return a string name of the given error */
const char *http_errno_name(enum http_errno err);
/* Return a string description of the given error */
const char *http_errno_description(enum http_errno err);
/* Parse a URL; return nonzero on failure */
int http_parser_parse_url(const char *buf, size_t buflen,
int is_connect,
struct http_parser_url *u);
/* Pause or un-pause the parser; a nonzero value pauses */
void http_parser_pause(http_parser *parser, int paused);
/* Checks if this is the final chunk of the body. */
int http_body_is_final(const http_parser *parser);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,20 +0,0 @@
FILE(GLOB SRC_NTLMCLIENT "ntlm.c" "unicode_builtin.c" "util.c")
ADD_DEFINITIONS(-DNTLM_STATIC=1)
DISABLE_WARNINGS(implicit-fallthrough)
IF (HTTPS_BACKEND STREQUAL "SecureTransport")
ADD_DEFINITIONS(-DCRYPT_COMMONCRYPTO)
SET(SRC_NTLMCLIENT_CRYPTO "crypt_commoncrypto.c")
ELSEIF (HTTPS_BACKEND STREQUAL "OpenSSL")
ADD_DEFINITIONS(-DCRYPT_OPENSSL)
SET(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c")
ELSEIF (HTTPS_BACKEND STREQUAL "mbedTLS")
ADD_DEFINITIONS(-DCRYPT_MBEDTLS)
SET(SRC_NTLMCLIENT_CRYPTO "crypt_mbedtls.c")
ELSE ()
MESSAGE(FATAL_ERROR "Unable to use libgit2's HTTPS backend (${HTTPS_BACKEND}) for NTLM crypto")
ENDIF()
ADD_LIBRARY(ntlmclient OBJECT ${SRC_NTLMCLIENT} ${SRC_NTLMCLIENT_CRYPTO})

View File

@@ -1,33 +0,0 @@
/*
* Copyright (c) Edward Thomson. All rights reserved.
*
* This file is part of ntlmclient, distributed under the MIT license.
* For full terms and copyright information, and for third-party
* copyright information, see the included LICENSE.txt file.
*/
#ifndef PRIVATE_COMPAT_H__
#define PRIVATE_COMPAT_H__
#if defined (_MSC_VER)
typedef unsigned char bool;
# ifndef true
# define true 1
# endif
# ifndef false
# define false 0
# endif
#else
# include <stdbool.h>
#endif
#ifdef __linux__
# include <endian.h>
# define htonll htobe64
#endif
#ifndef MIN
# define MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif
#endif /* PRIVATE_COMPAT_H__ */

View File

@@ -1,64 +0,0 @@
/*
* Copyright (c) Edward Thomson. All rights reserved.
*
* This file is part of ntlmclient, distributed under the MIT license.
* For full terms and copyright information, and for third-party
* copyright information, see the included LICENSE.txt file.
*/
#ifndef PRIVATE_CRYPT_COMMON_H__
#define PRIVATE_CRYPT_COMMON_H__
#if defined(CRYPT_OPENSSL)
# include "crypt_openssl.h"
#elif defined(CRYPT_MBEDTLS)
# include "crypt_mbedtls.h"
#elif defined(CRYPT_COMMONCRYPTO)
# include "crypt_commoncrypto.h"
#else
# error "no crypto support"
#endif
#define CRYPT_DES_BLOCKSIZE 8
#define CRYPT_MD4_DIGESTSIZE 16
#define CRYPT_MD5_DIGESTSIZE 16
typedef unsigned char ntlm_des_block[CRYPT_DES_BLOCKSIZE];
extern bool ntlm_random_bytes(
ntlm_client *ntlm,
unsigned char *out,
size_t len);
extern bool ntlm_des_encrypt(
ntlm_des_block *out,
ntlm_des_block *plaintext,
ntlm_des_block *key);
extern bool ntlm_md4_digest(
unsigned char out[CRYPT_MD4_DIGESTSIZE],
const unsigned char *in,
size_t in_len);
extern ntlm_hmac_ctx *ntlm_hmac_ctx_init(void);
extern bool ntlm_hmac_ctx_reset(ntlm_hmac_ctx *ctx);
extern bool ntlm_hmac_md5_init(
ntlm_hmac_ctx *ctx,
const unsigned char *key,
size_t key_len);
extern bool ntlm_hmac_md5_update(
ntlm_hmac_ctx *ctx,
const unsigned char *data,
size_t data_len);
extern bool ntlm_hmac_md5_final(
unsigned char *out,
size_t *out_len,
ntlm_hmac_ctx *ctx);
extern void ntlm_hmac_ctx_free(ntlm_hmac_ctx *ctx);
#endif /* PRIVATE_CRYPT_COMMON_H__ */

View File

@@ -1,120 +0,0 @@
/*
* Copyright (c) Edward Thomson. All rights reserved.
*
* This file is part of ntlmclient, distributed under the MIT license.
* For full terms and copyright information, and for third-party
* copyright information, see the included LICENSE.txt file.
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <CommonCrypto/CommonCrypto.h>
#include "ntlm.h"
#include "crypt.h"
bool ntlm_random_bytes(
ntlm_client *ntlm,
unsigned char *out,
size_t len)
{
int fd, ret;
size_t total = 0;
if ((fd = open("/dev/urandom", O_RDONLY)) < 0) {
ntlm_client_set_errmsg(ntlm, strerror(errno));
return false;
}
while (total < len) {
if ((ret = read(fd, out, (len - total))) < 0) {
ntlm_client_set_errmsg(ntlm, strerror(errno));
return false;
} else if (ret == 0) {
ntlm_client_set_errmsg(ntlm, "unexpected eof on random device");
return false;
}
total += ret;
}
close(fd);
return true;
}
bool ntlm_des_encrypt(
ntlm_des_block *out,
ntlm_des_block *plaintext,
ntlm_des_block *key)
{
size_t written;
CCCryptorStatus result = CCCrypt(kCCEncrypt,
kCCAlgorithmDES, kCCOptionECBMode,
key, sizeof(ntlm_des_block), NULL,
plaintext, sizeof(ntlm_des_block),
out, sizeof(ntlm_des_block), &written);
return (result == kCCSuccess) ? true : false;
}
bool ntlm_md4_digest(
unsigned char out[CRYPT_MD4_DIGESTSIZE],
const unsigned char *in,
size_t in_len)
{
return !!CC_MD4(in, in_len, out);
}
ntlm_hmac_ctx *ntlm_hmac_ctx_init(void)
{
return calloc(1, sizeof(ntlm_hmac_ctx));
}
bool ntlm_hmac_ctx_reset(ntlm_hmac_ctx *ctx)
{
memset(ctx, 0, sizeof(ntlm_hmac_ctx));
return true;
}
bool ntlm_hmac_md5_init(
ntlm_hmac_ctx *ctx,
const unsigned char *key,
size_t key_len)
{
CCHmacInit(&ctx->native, kCCHmacAlgMD5, key, key_len);
return true;
}
bool ntlm_hmac_md5_update(
ntlm_hmac_ctx *ctx,
const unsigned char *data,
size_t data_len)
{
CCHmacUpdate(&ctx->native, data, data_len);
return true;
}
bool ntlm_hmac_md5_final(
unsigned char *out,
size_t *out_len,
ntlm_hmac_ctx *ctx)
{
if (*out_len < CRYPT_MD5_DIGESTSIZE)
return false;
CCHmacFinal(&ctx->native, out);
*out_len = CRYPT_MD5_DIGESTSIZE;
return true;
}
void ntlm_hmac_ctx_free(ntlm_hmac_ctx *ctx)
{
free(ctx);
}

View File

@@ -1,18 +0,0 @@
/*
* Copyright (c) Edward Thomson. All rights reserved.
*
* This file is part of ntlmclient, distributed under the MIT license.
* For full terms and copyright information, and for third-party
* copyright information, see the included LICENSE.txt file.
*/
#ifndef PRIVATE_CRYPT_COMMONCRYPTO_H__
#define PRIVATE_CRYPT_COMMONCRYPTO_H__
#include <CommonCrypto/CommonCrypto.h>
typedef struct {
CCHmacContext native;
} ntlm_hmac_ctx;
#endif /* PRIVATE_CRYPT_COMMONCRYPTO_H__ */

Some files were not shown because too many files have changed in this diff Show More