git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 00/16] Introduce a tempfile module

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Aug 10, 2015, 09:47 UTC
Message-ID
<cover.1439198011.git.mhagger@alum.mit.edu>

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
Next: Michael Haggerty
Message 1 of 29 in “Introduce a tempfile module”
  1. 00/16 Introduce a tempfile moduleMichael Haggerty, Aug 10, 2015
  2. 01/16 Move lockfile documentation to lockfile.h and lockfile.cMichael Haggerty, Aug 10, 2015
  3. Junio C HamanoAug 11, 2015
  4. 02/16 create_bundle(): duplicate file descriptor to avoid closing it twiceMichael Haggerty, Aug 10, 2015
  5. 03/16 lockfile: add accessors get_lock_file_fd() and get_lock_file_fp()Michael Haggerty, Aug 10, 2015
  6. Junio C HamanoAug 11, 2015
  7. 04/16 lockfile: add accessor get_lock_file_path()Michael Haggerty, Aug 10, 2015
  8. Junio C HamanoAug 11, 2015
  9. 05/16 commit_lock_file(): use get_locked_file_path()Michael Haggerty, Aug 10, 2015
  10. 06/16 tempfile: a new module for handling temporary filesMichael Haggerty, Aug 10, 2015
  11. 07/16 prepare_tempfile_object(): new function, extracted from create_tempfile()Michael Haggerty, Aug 10, 2015
  12. Junio C HamanoAug 11, 2015
  13. 08/16 tempfile: add several functions for creating temporary filesMichael Haggerty, Aug 10, 2015
  14. 09/16 register_tempfile(): new function to handle an existing temporary fileMichael Haggerty, Aug 10, 2015
  15. 10/16 write_shared_index(): use tempfile moduleMichael Haggerty, Aug 10, 2015
  16. 11/16 setup_temporary_shallow(): use tempfile moduleMichael Haggerty, Aug 10, 2015
  17. 12/16 diff: use tempfile moduleMichael Haggerty, Aug 10, 2015
  18. Junio C HamanoAug 11, 2015
  19. Michael HaggertyAug 12, 2015
  20. Junio C HamanoAug 12, 2015
  21. 12/16 diff: use tempfile moduleMichael Haggerty, Aug 12, 2015
  22. 13/16 lock_repo_for_gc(): compute the path to "gc.pid" only onceMichael Haggerty, Aug 10, 2015
  23. Junio C HamanoAug 11, 2015
  24. Junio C HamanoAug 11, 2015
  25. 14/16 gc: use tempfile module to handle gc.pid fileMichael Haggerty, Aug 10, 2015
  26. 15/16 credential-cache--daemon: delete socket from main()Michael Haggerty, Aug 10, 2015
  27. 16/16 credential-cache--daemon: use tempfile moduleMichael Haggerty, Aug 10, 2015
  28. Junio C HamanoAug 11, 2015
  29. Michael HaggertyAug 12, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.