Subject: [PATCH v2 00/16] Introduce a tempfile module

From: Michael Haggerty <[email-masked]>
Date: Mon, 10 Aug 2015 11:47:35 +0200

This is a re-roll of the tempfile patch series [1]. I'm sorry for the
long delay getting v2 out. Thanks to Junio and Johannes Sixt for their
feedback about v1. I think I have addressed all of their points.

This version is very similar to v1 in spirit, though quite a few
details have changed. The main difference is that I add some more
wrapper functions for both lockfile and tempfile (a) to add some
abstraction and (b) so that users of the former don't need to know
that it is based on the latter:

* Add new lockfile wrappers around the corresponding tempfile
  functions:

  * lockfile:
    * fdopen_lock_file()
    * close_lock_file()
    * reopen_lock_file()

* Add accessors:

  * lockfile:
    * get_lock_file_path()
    * get_lock_file_fd()
    * get_lock_file_fp()

  * tempfile:
    * is_tempfile_active()
    * get_tempfile_path()
    * get_tempfile_fd()
    * get_tempfile_fp()

Other changes in this version:

* Make some trivial wrapper functions inline.

* Change create_bundle() to dup() the file descriptor that it passes
  to write_pack_data() so that it doesn't have to tinker with
  lock->tempfile.fd to prevent the file from being closed twice.

* Move some docs about the implementation from tempfile.h to
  tempfile.c.

* Rename register_tempfile_object() to prepare_tempfile_object() to
  reduce confusion with register_tempfile(). Remove its "path"
  parameter and add a docstring.

* Simplify some `die("BUG:...")` error messages.

This series applies to the same commit as v1, namely
v2.4.3-368-g7974889. There is one small conflict when merging to
master or next or (pu minus gitster/mh/tempfile).

This patch series is also available from my GitHub fork [2] as branch
"tempfile".

[1] http://thread.gmane.org/gmane.comp.version-control.git/270998
[2] https://github.com/mhagger/git

Michael Haggerty (16):
  Move lockfile documentation to lockfile.h and lockfile.c
  create_bundle(): duplicate file descriptor to avoid closing it twice
  lockfile: add accessors get_lock_file_fd() and get_lock_file_fp()
  lockfile: add accessor get_lock_file_path()
  commit_lock_file(): use get_locked_file_path()
  tempfile: a new module for handling temporary files
  prepare_tempfile_object(): new function, extracted from
    create_tempfile()
  tempfile: add several functions for creating temporary files
  register_tempfile(): new function to handle an existing temporary file
  write_shared_index(): use tempfile module
  setup_temporary_shallow(): use tempfile module
  diff: use tempfile module
  lock_repo_for_gc(): compute the path to "gc.pid" only once
  gc: use tempfile module to handle gc.pid file
  credential-cache--daemon: delete socket from main()
  credential-cache--daemon: use tempfile module

 Documentation/technical/api-lockfile.txt | 220 --------------------
 Makefile                                 |   1 +
 builtin/commit.c                         |  15 +-
 builtin/gc.c                             |  32 +--
 bundle.c                                 |  26 ++-
 config.c                                 |  14 +-
 credential-cache--daemon.c               |  25 +--
 credential-store.c                       |   2 +-
 diff.c                                   |  29 +--
 lockfile.c                               | 205 +++----------------
 lockfile.h                               | 336 +++++++++++++++++++++++++------
 read-cache.c                             |  40 +---
 refs.c                                   |  18 +-
 shallow.c                                |  41 +---
 tempfile.c                               | 305 ++++++++++++++++++++++++++++
 tempfile.h                               | 271 +++++++++++++++++++++++++
 16 files changed, 951 insertions(+), 629 deletions(-)
 delete mode 100644 Documentation/technical/api-lockfile.txt
 create mode 100644 tempfile.c
 create mode 100644 tempfile.h

-- 
2.5.0