[PATCH 14/16] commit_tree(): rewriting/replacing new commits
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
commit.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/commit.c b/commit.c
index 7121631..258d3fb 100644
--- a/commit.c
+++ b/commit.c
@@ -6,6 +6,7 @@
#include "diff.h"
#include "revision.h"
#include "notes.h"
+#include "subtree.h"
int save_commit_buffer = 1;
@@ -858,5 +859,12 @@ int commit_tree(const char *msg, unsigned char *tree, unsigned char *base_tree,
result = write_sha1_file(buffer.buf, buffer.len, commit_type, ret);
strbuf_release(&buffer);
+
+ if (core_subtree && !result) {
+ unsigned char subtree_commit[20];
+ memcpy(subtree_commit, ret, 20);
+ result = subtree_export(subtree_commit, base_tree, ret);
+ }
+
return result;
}
--
1.7.1.rc1.69.g24c2f7