Subject: Re: [PATCH v6 27/39] try_merge_strategy(): use a statically-allocated lock_file object

From: Junio C Hamano <[email-masked]>
Date: Fri, 26 Sep 2014 12:00:06 -0700

Michael Haggerty <[email-masked]> writes:

> Even the one lockfile object needn't be allocated each time the
> function is called.  Instead, define one statically-allocated
> lock_file object and reuse it for every call.
>
> Suggested-by: Jeff King <[email-masked]>
> Signed-off-by: Michael Haggerty <[email-masked]>
> ---
> ...
> -	hold_locked_index(lock, 1);
> +	hold_locked_index(&lock, 1);
>  	refresh_cache(REFRESH_QUIET);
>  	if (active_cache_changed &&
> -	    write_locked_index(&the_index, lock, COMMIT_LOCK))
> +	    write_locked_index(&the_index, &lock, COMMIT_LOCK))

I wondered if the next step would be to lose the "lock" parameter
from {hold,write}_locked_index() and have them work on a
process-global lock, but that would not work well.

The reason why this patch works is because we are only working with
a single destination (i.e. $GIT_INDEX_FILE typically .git/index),
right?

Interesting.