Round v3. Thanks to Johannes Sixt and Peff for feedback on v2. This version addresses all issues raised for v1 [1] and v2 [2]. Changes since v2: * Instead of keeping track of whether a lock_file object is active via a new bit in a flags bitmask, store it in a separate volatile sig_atomic_t struct member. This makes it a little less undefined when this field is accessed by the signal handler. * Add some other "volatile" qualifiers to values used by the signal handler. * Define constants LOCK_SUFFIX and LOCK_SUFFIX_LEN in cache.h and use them both inside and outside lockfile.c. (In v2, only LOCK_SUFFIX_LEN was defined and it was only used within lockfile.c, because the other potential users in refs.c were rewritten anyway. But that rewriting is no longer included in the patch series, so it makes sense to define these constants as part of the public lockfile API.) * Swap order of first two patches because the documentation lists unable_to_lock_die() under its new name. * die() (instead of NOP) if commit_lock_file() is called for an unlocked lock_file object. * Rebase to current master (there were no conflicts). [1] http://thread.gmane.org/gmane.comp.version-control.git/245609 [2] http://thread.gmane.org/gmane.comp.version-control.git/245801 Michael Haggerty (25): unable_to_lock_die(): rename function from unable_to_lock_index_die() api-lockfile: expand the documentation 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 lockfile.c: document the various states of lock_file objects cache.h: define constants LOCK_SUFFIX and 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(): die() if called for unlocked lockfile object lockfile: avoid transitory invalid states struct lock_file: declare some fields volatile 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 | 15 +- config.c | 6 +- lockfile.c | 275 ++++++++++++++++++------------- refs.c | 29 ++-- shallow.c | 6 +- 10 files changed, 247 insertions(+), 159 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html