In subtree mode, you work on a narrowed trees. You make narrowed commits. If you want to push upstream, you would need to put your updated subtree back to the full tree again. Otherwise upstream would complain you delete all trees but your subtree, not good. In order to do that, commit_tree() now takes the base tree SHA-1. With that, it can create upstream-compatible commits. It does not now, though. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- builtin/commit-tree.c | 2 +- builtin/commit.c | 2 +- builtin/merge.c | 4 ++-- builtin/notes.c | 2 +- commit.c | 2 +- commit.h | 2 +- notes-cache.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c index 87f0591..88a6833 100644 --- a/builtin/commit-tree.c +++ b/builtin/commit-tree.c @@ -56,7 +56,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) if (strbuf_read(&buffer, 0, 0) < 0) die_errno("git commit-tree: failed to read"); - if (!commit_tree(buffer.buf, tree_sha1, parents, commit_sha1, NULL)) { + if (!commit_tree(buffer.buf, tree_sha1, NULL, parents, commit_sha1, NULL)) { printf("%s\n", sha1_to_hex(commit_sha1)); return 0; } diff --git a/builtin/commit.c b/builtin/commit.c index 2bb30c0..6b4c678 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1350,7 +1350,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) exit(1); } - if (commit_tree(sb.buf, active_cache_tree->sha1, parents, commit_sha1, + if (commit_tree(sb.buf, active_cache_tree->sha1, NULL, parents, commit_sha1, fmt_ident(author_name, author_email, author_date, IDENT_ERROR_ON_NO_NAME))) { rollback_index_files(); diff --git a/builtin/merge.c b/builtin/merge.c index 37ce4f5..8745b54 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -779,7 +779,7 @@ static int merge_trivial(void) parent->next = xmalloc(sizeof(*parent->next)); parent->next->item = remoteheads->item; parent->next->next = NULL; - commit_tree(merge_msg.buf, result_tree, parent, result_commit, NULL); + commit_tree(merge_msg.buf, result_tree, NULL, parent, result_commit, NULL); finish(result_commit, "In-index merge"); drop_save(); return 0; @@ -808,7 +808,7 @@ static int finish_automerge(struct commit_list *common, } free_commit_list(remoteheads); strbuf_addch(&merge_msg, '\n'); - commit_tree(merge_msg.buf, result_tree, parents, result_commit, NULL); + commit_tree(merge_msg.buf, result_tree, NULL, parents, result_commit, NULL); strbuf_addf(&buf, "Merge made by %s.", wt_strategy); finish(result_commit, buf.buf); strbuf_release(&buf); diff --git a/builtin/notes.c b/builtin/notes.c index 190005f..8d574eb 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -303,7 +303,7 @@ int commit_notes(struct notes_tree *t, const char *msg) hashclr(prev_commit); parent = NULL; } - if (commit_tree(buf.buf + 7, tree_sha1, parent, new_commit, NULL)) + if (commit_tree(buf.buf + 7, tree_sha1, NULL, parent, new_commit, NULL)) die("Failed to commit notes tree to database"); /* Update notes ref with new commit */ diff --git a/commit.c b/commit.c index d1e30b2..7121631 100644 --- a/commit.c +++ b/commit.c @@ -811,7 +811,7 @@ static const char commit_utf8_warn[] = "You may want to amend it after fixing the message, or set the config\n" "variable i18n.commitencoding to the encoding your project uses.\n"; -int commit_tree(const char *msg, unsigned char *tree, +int commit_tree(const char *msg, unsigned char *tree, unsigned char *base_tree, struct commit_list *parents, unsigned char *ret, const char *author) { diff --git a/commit.h b/commit.h index d8c01ea..7c34368 100644 --- a/commit.h +++ b/commit.h @@ -166,7 +166,7 @@ static inline int single_parent(struct commit *commit) struct commit_list *reduce_heads(struct commit_list *heads); -extern int commit_tree(const char *msg, unsigned char *tree, +extern int commit_tree(const char *msg, unsigned char *tree, unsigned char *base_tree, struct commit_list *parents, unsigned char *ret, const char *author); diff --git a/notes-cache.c b/notes-cache.c index dee6d62..96afb25 100644 --- a/notes-cache.c +++ b/notes-cache.c @@ -56,7 +56,7 @@ int notes_cache_write(struct notes_cache *c) if (write_notes_tree(&c->tree, tree_sha1)) return -1; - if (commit_tree(c->validity, tree_sha1, NULL, commit_sha1, NULL) < 0) + if (commit_tree(c->validity, tree_sha1, NULL, NULL, commit_sha1, NULL) < 0) return -1; if (update_ref("update notes cache", c->tree.ref, commit_sha1, NULL, 0, QUIET_ON_ERR) < 0) -- 1.7.1.rc1.69.g24c2f7 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html