fast-import: do less work when given "from" matches current branch head
authorMike Hommey <mh@glandium.org>
Thu, 9 Jul 2015 06:50:09 +0000 (15:50 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Jul 2015 16:36:05 +0000 (09:36 -0700)
commit0df3245721580a3d48c9766a311dd0e3367844b8
tree185fe8c41e487da319169f0e9a9e2237718291a3
parent7ecec52d42a964c4a8e9f6ca41bb0b5ce00049b4
fast-import: do less work when given "from" matches current branch head

When building a fast-import stream, it's easy to forget the fact
that for non-merge commits happening on top of the current branch
head, there is no need for a "from" command. That is corroborated by
the fact that at least git-p4, hg-fast-export and felipec's
git-remote-hg all unconditionally use a "from" command.

Unfortunately, giving a "from" command always resets the branch
tree, forcing it to be re-read, and in many cases, the pack is also
closed and reopened through gfi_unpack_entry.  Both are unnecessary
overhead, and the latter is particularly slow at least on OSX.

Avoid resetting the tree when it's unmodified, and avoid calling
gfi_unpack_entry when the given mark points to the same commit as
the current branch head.

Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fast-import.c