Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Commits on Oct 27, 2007
  1. @torvalds @gitster

    copy vs rename detection: avoid unnecessary O(n*m) loops

    torvalds authored gitster committed
    The core rename detection had some rather stupid code to check if a
    pathname was used by a later modification or rename, which basically
    walked the whole pathname space for all renames for each rename, in
    order to tell whether it was a pure rename (no remaining users) or
    should be considered a copy (other users of the source file remaining).
    That's really silly, since we can just keep a count of users around, and
    replace all those complex and expensive loops with just testing that
    simple counter (but this all depends on the previous commit that shared
    the diff_filespec data structure by using a separate reference count).
    Note that the reference count is not the same as the rename count: they
    behave otherwise rather similarly, but the reference count is tied to
    the allocation (and decremented at de-allocation, so that when it turns
    zero we can get rid of the memory), while the rename count is tied to
    the renames and is decremented when we find a rename (so that when it
    turns zero we know that it was a rename, not a copy).
    Signed-off-by: Linus Torvalds <>
    Signed-off-by: Junio C Hamano <>
  2. @torvalds @gitster

    Ref-count the filespecs used by diffcore

    torvalds authored gitster committed
    Rather than copy the filespecs when introducing new versions of them
    (for rename or copy detection), use a refcount and increment the count
    when reusing the diff_filespec.
    This avoids unnecessary allocations, but the real reason behind this is
    a future enhancement: we will want to track shared data across the
    copy/rename detection.  In order to efficiently notice when a filespec
    is used by a rename, the rename machinery wants to keep track of a
    rename usage count which is shared across all different users of the
    Signed-off-by: Linus Torvalds <>
    Signed-off-by: Junio C Hamano <>
Something went wrong with that request. Please try again.