This is a second attempt at renovating the lock file code. Thanks to Peff, Junio, Torsten, and Eric for their helpful reviews of v1.
v1 of this patch series  did some refactoring and then added a new feature to the lock_file API: the ability to activate a new version of a locked file while retaining the lock. But the review of v1 turned up even more correctness issues in the existing implementation of lock files. So this v2 dials back the scope of the changes (it omits the new feature) but does more work to fix problems with the current lock file implementation. The main theme of this patch series is to better define the state diagram for lock_file objects and to fix code that left them in incorrect, indeterminate, or unexpected states. There are also a few patches that convert several functions to use strbufs instead of limiting pathnames to a maximum length. I hope that submitting these patches separately will make it easier for them to be accepted without first having to decide wither the activate-file-while-retaining-lock feature is a good one.  http://thread.gmane.org/gmane.comp.version-control.git/245609 Michael Haggerty (25): api-lockfile: expand the documentation unable_to_lock_die(): rename function from unable_to_lock_index_die() rollback_lock_file(): do not clear filename redundantly rollback_lock_file(): set fd to -1 lockfile: unlock file if lockfile permissions cannot be adjusted hold_lock_file_for_append(): release lock on errors lock_file(): always add lock_file object to lock_file_list struct lock_file: replace on_list field with flags field lockfile.c: document the various states of lock_file objects lockfile: define a constant LOCK_SUFFIX_LEN delete_ref_loose(): don't muck around in the lock_file's filename prepare_index(): declare return value to be (const char *) write_packed_entry_fn(): convert cb_data into a (const int *) lock_file(): exit early if lockfile cannot be opened remove_lock_file(): call rollback_lock_file() commit_lock_file(): inline temporary variable commit_lock_file(): make committing an unlocked lockfile a NOP lockfile: avoid transitory invalid states try_merge_strategy(): remove redundant lock_file allocation try_merge_strategy(): use a statically-allocated lock_file object commit_lock_file(): use a strbuf to manage temporary space Change lock_file::filename into a strbuf resolve_symlink(): use a strbuf for internal scratch space resolve_symlink(): take a strbuf parameter trim_last_path_elm(): replace last_path_elm() Documentation/technical/api-lockfile.txt | 40 ++++- builtin/commit.c | 16 +- builtin/merge.c | 15 +- builtin/reflog.c | 2 +- builtin/update-index.c | 2 +- cache.h | 6 +- config.c | 6 +- lockfile.c | 282 +++++++++++++++++++------------ refs.c | 20 ++- shallow.c | 6 +- 10 files changed, 243 insertions(+), 152 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html