]> git.ipfire.org Git - thirdparty/git.git/commit - unpack-trees.c
unpack-trees: create working copy of merge entry in merged_entry
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>
Sun, 2 Jun 2013 15:46:54 +0000 (17:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 2 Jun 2013 22:31:13 +0000 (15:31 -0700)
commitf2fa35420511cc49e85413a2932a1a2bac88cc1b
treeb168a221fccdbb082dd9eb02958b085a99293129
parenta33bd4d34def15d12372aeb8c59a7465416f9f66
unpack-trees: create working copy of merge entry in merged_entry

Duplicate the merge entry right away and work with that instead of
modifying the entry we got and duplicating it only at the end of
the function.  Then mark that pointer const to document that we
don't modify the referenced cache_entry.

This change is safe because all existing merge functions call
merged_entry just before returning (or not at all), i.e. they don't
care about changes to the referenced cache_entry after the call.
unpack_nondirectories and unpack_index_entry, which call the merge
functions through call_unpack_fn, aren't interested in such changes
neither.

The change complicates merged_entry a bit because we have to free the
copy if we error out, but allows callers to pass a const pointer.

Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
unpack-trees.c