50 Commits

Author SHA1 Message Date
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
Twarit
b20bde7d3e Update windows binaries for 3.2 beta 2 2019-11-25 01:13:01 +05:30
IronicallySerious
0e4f8acd3d Fix dirty read on initialiation status for the libgit2 instance 2019-11-25 00:44:12 +05:30
Twarit
531495001e Fix compat with fixed typo in function names 2019-11-24 23:04:47 +05:30
24 changed files with 251 additions and 114 deletions

4
.gitignore vendored
View File

@@ -27,9 +27,5 @@ build/
# Binaries for distribution
!/demo/bin/
!libgitapi.dll
!libgitapi.so
!libgitapi.dylib
!git2.lib
!libgit.a

2
.gitmodules vendored
View File

@@ -1,3 +1,3 @@
[submodule "godot-cpp"]
path = godot-cpp
url = https://github.com/IronicallySerious/godot-cpp
url = https://github.com/GodotNativeTools/godot-cpp

57
.travis.yml Normal file
View File

@@ -0,0 +1,57 @@
language: cpp
dist: xenial
osx_image: xcode10.1
env:
global:
- SCONS_CACHE="$HOME/.scons_cache"
- SCONS_CACHE_LIMIT=1024
cache:
directories:
- $SCONS_CACHE
matrix:
include:
- name: Linux Debug
os: linux
compiler: gcc
env: TARGET=debug PLATFORM=x11
addons:
apt:
sources:
- llvm-toolchain-xenial-6.0
packages:
[scons, pkg-config, build-essential, p7zip-full]
- name: Linux Release
os: linux
compiler: gcc
addons:
apt:
packages:
[scons, pkg-config, build-essential, p7zip-full]
env: TARGET=release PLATFORM=x11
install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew update;
brew install scons p7zip;
fi
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
curl -LO https://downloads.sourceforge.net/project/scons/scons-local/3.0.5/scons-local-3.0.5.zip;
unzip scons-local-3.0.5.zip;
fi
script:
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
export SCONS="./scons.bat";
/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2017/BuildTools/Common7/Tools/VsDevCmd.bat;
./build_libs.bat $TARGET;
else
export SCONS="scons";
./build_libs.sh $TARGET;
fi
- $SCONS platform=$PLATFORM target=$TARGET $SCONS_FLAGS;

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016-2019 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,21 @@
# 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.
## Installation Instructions
1. Plugin binary releases for Linux & Windows are here: <https://github.com/godotengine/godot-git-plugin/releases>
2. Installation instructions are here: https://github.com/godotengine/godot-git-plugin/wiki
## Build Instructions
> Replace `Release` with `Debug` for a debug build.
### 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`
1. Load the x64 command prompt: `x64 Native Tools Command Prompt for VS 20XX`.
2. Run `build_libs.bat Release`.
3. Run `scons platform=windows target=release`
### 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`.
1. Prepare script for execution: `chmod 755 build_libs.sh`
2. Run ```. ./build_libs.sh Release```.
3. Run `scons platform=x11 target=release`.

View File

@@ -48,7 +48,7 @@ if env['platform'] == "osx":
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(CCFLAGS = ['-g','-O3', '-arch', 'x86_64', '-std=c++17'])
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
elif env['platform'] in ('x11', 'linux'):
@@ -69,6 +69,7 @@ elif env['platform'] == "windows":
env.Append(ENV = os.environ)
env.Append(CCFLAGS = ['-DWIN32', '-D_WIN32', '-D_WINDOWS', '-W3', '-GR', '-D_CRT_SECURE_NO_WARNINGS'])
env.Append(LIBS=['Advapi32'])
if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '-MDd'])
else:
@@ -76,8 +77,10 @@ elif env['platform'] == "windows":
if env['target'] in ('debug', 'd'):
cpp_library += '.debug'
env['target_path'] += 'debug/'
else:
cpp_library += '.release'
env['target_path'] += 'release/'
cpp_library += '.' + str(bits)

20
appveyor.yml Normal file
View File

@@ -0,0 +1,20 @@
environment:
matrix:
- vs_version: 15
os: Visual Studio 2017
configuration:
- Release
- Debug
platform:
- x64
install:
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
- curl -LO https://downloads.sourceforge.net/project/scons/scons-local/3.0.5/scons-local-3.0.5.zip
- unzip scons-local-3.0.5.zip
- ./build_libs.bat %configuration%
- scons platform=windows target=%configuration%

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;

15
build_libs.bat Normal file
View File

@@ -0,0 +1,15 @@
git submodule init
git submodule update --init --recursive
cd godot-git-plugin\thirdparty\libgit2\
mkdir build
cd build\
del /F CMakeCache.txt
cmake ..
cmake --build .
cd ../../../../
copy godot-git-plugin\thirdparty\libgit2\build\%1\git2.lib demo\bin\win64\
cd godot-cpp\
scons platform=windows target=%1 generate_bindings=yes bits=64
cd ..

16
build_libs.sh Executable file
View File

@@ -0,0 +1,16 @@
git submodule init;
git submodule update --init --recursive;
cd godot-git-plugin/thirdparty/libgit2/
mkdir build
cd build/
rm CMakeCache.txt
cmake ..
cmake --build .
cd ../../../../
mv godot-git-plugin/thirdparty/libgit2/build/libgit2.a demo/bin/x11/libgit2.a
cd godot-cpp/;
apt-get install scons
scons platform=linux target=$1 generate_bindings=yes bits=64;
cd ..

8
demo/.gitattributes vendored
View File

@@ -1,17 +1,17 @@
# 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.
# 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.
# 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.
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -7,8 +7,8 @@ reloadable=false
[entry]
Windows.64="res://bin/win64/libgitapi.dll"
X11.64="res://bin/x11/libgitapi.so"
Windows.64="res://bin/win64/release/libgitapi.dll"
X11.64="res://bin/x11/release/libgitapi.so"
[dependencies]

View File

@@ -22,32 +22,32 @@
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{574C5E6A-EDEC-41A6-BDF7-4106698F80B0}</ProjectGuid>
<RootNamespace>godotgitplugin</RootNamespace>
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
<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>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<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>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
@@ -73,10 +73,18 @@
<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>
<OutDir>$(SolutionDir)..\demo\bin\win64\debug\</OutDir>
<IntDir>$(SolutionDir)..\demo\bin\win64\intermediate\</IntDir>
<TargetName>libgitapi</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|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>
<TargetName>libgitapi</TargetName>
<IntDir>$(SolutionDir)..\demo\bin\win64\intermediate\</IntDir>
<OutDir>$(SolutionDir)..\demo\bin\win64\release\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
@@ -95,7 +103,7 @@
<Link>
<AdditionalDependencies>libgodot-cpp.windows.debug.64.lib;git2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
<OutputFile>$(SolutionDir)..\demo\bin\win64\libgitapi.dll</OutputFile>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -124,6 +132,7 @@
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libgodot-cpp.windows.release.64.lib;git2.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>

View File

@@ -9,7 +9,7 @@ void GitAPI::_register_methods() {
register_method("_process", &GitAPI::_process);
register_method("_commit", &GitAPI::_commit);
register_method("_get_is_vcs_intialized", &GitAPI::_get_is_vcs_intialized);
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);
@@ -22,6 +22,12 @@ void GitAPI::_register_methods() {
void GitAPI::_commit(const String p_msg) {
if (!can_commit) {
godot::Godot::print("Git API cannot commit. Check previous errors.");
return;
}
git_signature *default_sign;
git_oid tree_id, parent_commit_id, new_commit_id;
git_tree *tree;
@@ -31,7 +37,7 @@ void GitAPI::_commit(const String p_msg) {
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]);
String file_path = staged_files[i];
File *file = File::_new();
if (file->file_exists(file_path)) {
@@ -50,19 +56,19 @@ void GitAPI::_commit(const String p_msg) {
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);
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();
@@ -96,14 +102,13 @@ void GitAPI::create_gitignore_and_gitattributes() {
file->open("res://.gitignore", File::ModeFlags::WRITE);
file->store_string(
"# Import cache\n"
".import/\n\n"
"# Import cache\n"
".import/\n\n"
"# Binaries\n"
"bin/\n"
"build/\n"
"lib/\n"
);
"# Binaries\n"
"bin/\n"
"build/\n"
"lib/\n");
file->close();
}
@@ -111,61 +116,66 @@ void GitAPI::create_gitignore_and_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"
"# 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"
"# 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"
"# 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");
"# 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() {
bool 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);
if (git_signature_default(&sig, repo) != 0) {
godot::Godot::print_error("Unable to create a commit signature. Perhaps 'user.name' and 'user.email' are not set. Set default user name and user email by `git config` and initialize again", __func__, __FILE__, __LINE__);
return false;
}
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);
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);
return true;
}
bool GitAPI::_get_is_vcs_intialized() {
bool GitAPI::_is_vcs_initialized() {
return is_initialized;
}
@@ -272,16 +282,21 @@ bool GitAPI::_initialize(const String p_project_root_path) {
WARN_PRINT("Multiple libgit2 instances are running");
}
if (is_initialized) {
if (repo) {
return true;
}
can_commit = 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();
if (!create_initial_commit()) {
godot::Godot::print_error("Initial commit could not be created. Commit functionality will not work.", __func__, __FILE__, __LINE__);
can_commit = false;
}
}
GIT2_CALL(git_repository_open(&repo, p_project_root_path.alloc_c_string()), "Could not open repository", NULL);

View File

@@ -22,6 +22,9 @@ class GitAPI : public EditorVCSInterface {
static GitAPI *singleton;
bool is_initialized;
bool can_commit;
Array staged_files;
PanelContainer *init_settings_panel_container;
@@ -30,7 +33,7 @@ class GitAPI : public EditorVCSInterface {
git_repository *repo;
void _commit(const String p_msg);
bool _get_is_vcs_intialized();
bool _is_vcs_initialized();
Dictionary _get_modified_files_data();
Array _get_file_diff(const String file_path);
String _get_project_name();
@@ -45,11 +48,10 @@ public:
static GitAPI *get_singleton() { return singleton; }
bool is_initialized;
Array diff_contents;
void create_gitignore_and_gitattributes();
void create_initial_commit();
bool create_initial_commit();
void _init();
void _process();

View File

@@ -55,8 +55,8 @@ extern "C" int diff_line_callback_function(const git_diff_delta *delta, const gi
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

@@ -42,8 +42,9 @@ INCLUDE(EnableWarnings)
# Build options
#
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
OPTION(SONAME "Set the (SO)VERSION of the target" ON)
OPTION(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
OPTION(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" OFF)
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)
@@ -61,7 +62,7 @@ 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)
OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib" ON)
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.")