Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion godot-cpp
Submodule godot-cpp updated 193 files
46 changes: 32 additions & 14 deletions godot-git-plugin/src/git_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void GitPlugin::_discard_file(const godot::String &file_path) {
GIT2_CALL(git_checkout_index(repo.get(), nullptr, &opts), "Could not checkout index");
}

void GitPlugin::_commit(const godot::String &msg) {
void GitPlugin::_commit(const godot::String &msg, bool amend) {
git_index_ptr repo_index;
GIT2_CALL(git_repository_index(Capture(repo_index), repo.get()), "Could not get repository index");

Expand All @@ -112,19 +112,33 @@ void GitPlugin::_commit(const godot::String &msg) {

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");
if (amend) {
GIT2_CALL(
git_commit_amend(
&new_commit_id,
parent_commit.get(),
"HEAD",
default_sign.get(),
default_sign.get(),
"UTF-8",
CString(msg).data,
tree.get()),
"Could not create amend commit");
} else {
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");
Expand All @@ -148,6 +162,10 @@ void GitPlugin::_commit(const godot::String &msg) {
}
}

bool GitPlugin::_allow_amends() {
return true;
}

void GitPlugin::_stage_file(const godot::String &file_path) {
CString c_path(file_path);
char *paths[] = { c_path.data };
Expand Down
4 changes: 3 additions & 1 deletion godot-git-plugin/src/git_plugin.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <unordered_map>
#include <vector>

#include "git_callbacks.h"
#include "git_wrappers.h"
Expand Down Expand Up @@ -39,7 +40,8 @@ class GitPlugin : public godot::EditorVCSInterface {
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;
void _commit(const godot::String &msg, bool amend) override;
bool _allow_amends() 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;
Expand Down
Loading