merge-recursive: clean up get_renamed_dir_portion()
commitd3eebaad5ef02284c86d6c4b80199eac58c6729b
authorElijah Newren <newren@gmail.com>
Tue, 22 Oct 2019 21:22:49 +0000 (22 21:22 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Oct 2019 02:32:48 +0000 (23 11:32 +0900)
treec7011e7a5f8a7a7476d25451173554dd5d9e224b
parent08da6496b61341ec45eac36afcc8f94242763468
merge-recursive: clean up get_renamed_dir_portion()

Dscho noted a few things making this function hard to follow.
Restructure it a bit and add comments to make it easier to follow.  The
restructurings include:

  * There was a special case if-check at the end of the function
    checking whether someone just renamed a file within its original
    directory, meaning that there could be no directory rename involved.
    That check was slightly convoluted; it could be done in a more
    straightforward fashion earlier in the function, and can be done
    more cheaply too (no call to strncmp).

  * The conditions for advancing end_of_old and end_of_new before
    calling strchr were both confusing and unnecessary.  If either
    points at a '/', then they need to be advanced in order to find the
    next '/'.  If either doesn't point at a '/', then advancing them one
    char before calling strchr() doesn't hurt.  So, just rip out the
    if conditions and advance both before calling strchr().

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-recursive.c