diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-04-25 15:17:15 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-25 15:17:15 -0700 |
commit | f276cae18799ac8df2495b93cf0359a413789891 (patch) | |
tree | 88b4e119a06608fff800400d59dd4ee51a58c64a /builtin/merge.c | |
parent | 9058b8f043f5dd287b6587373f031d79694b6024 (diff) | |
parent | 40d71940b6a0dadb7873cce614992f1d71fcdfbd (diff) | |
download | git-f276cae18799ac8df2495b93cf0359a413789891.tar.gz |
Merge branch 'en/merge-trivial-fix'
When "git merge" notices that the merge can be resolved purely at
the tree level (without having to merge blobs) and the resulting
tree happens to already exist in the object store, it forgot to
update the index, which lead to an inconsistent state for later
operations.
* en/merge-trivial-fix:
builtin/merge.c: fix a bug with trivial merges
t7605: add a testcase demonstrating a bug with trivial merges
Diffstat (limited to 'builtin/merge.c')
-rw-r--r-- | builtin/merge.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/builtin/merge.c b/builtin/merge.c index 1ec44f0c1b..b555a1bf9c 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -822,6 +822,14 @@ static int merge_trivial(struct commit *head, struct commit_list *remoteheads) { unsigned char result_tree[20], result_commit[20]; struct commit_list *parents, **pptr = &parents; + static struct lock_file lock; + + hold_locked_index(&lock, 1); + refresh_cache(REFRESH_QUIET); + if (active_cache_changed && + write_locked_index(&the_index, &lock, COMMIT_LOCK)) + return error(_("Unable to write index.")); + rollback_lock_file(&lock); write_tree_trivial(result_tree); printf(_("Wonderful.\n")); |