refs.c: rename log_ref_setup to create_reflog
commit8f78d5d7a1e62f04c75524bb3e87aaad24372250
authorRonnie Sahlberg <sahlberg@google.com>
Wed, 23 Jul 2014 17:03:52 +0000 (23 10:03 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Jul 2014 23:08:07 +0000 (23 16:08 -0700)
tree7b1fecc48cf04421ab9d9feeb339c98cd1322f0d
parent5ac378cd8fad09a836d17fec379780854838bde5
refs.c: rename log_ref_setup to create_reflog

log_ref_setup is used to do several semi-related things :
* sometimes it will create a new reflog including missing parent directories
  and cleaning up any conflicting stale directories in the path.
* fill in a filename buffer for the full path to the reflog.
* unconditionally re-adjust the permissions for the file.

This function is only called from two places: checkout.c where it is always
used to create a reflog and refs.c:log_ref_write where it sometimes are
used to create a reflog and sometimes just used to fill in the filename.

Rename log_ref_setup to create_reflog and change it to only take the
refname as argument to make its signature similar to delete_reflog and
reflog_exists. Change create_reflog to ignore log_all_ref_updates and
"unconditionally" create the reflog when called. Since checkout.c always
wants to create a reflog we can call create_reflog directly and avoid the
temp-and-log_all_ref_update dance.

In log_ref_write, only call create_reflog iff we want to create a reflog
and if the reflog does not yet exist. This means that for the common case
where the log already exists we now only need to perform a single lstat()
instead of a open(O_CREAT)+lstat()+close().

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c
refs.c
refs.h