Skip to content

Introduce a tempfile module

Michael Haggerty git 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest16 patches 11 repliesIn review
  2. v114 patches 11 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16Move lockfile documentation to lockfile.h and lockfile.cDocumentation/technical/api-lockfile.txt lockfile.c lockfile.h+283 -2801 reply
2/16create_bundle(): duplicate file descriptor to avoid closing it twicebundle.c+16 -100 replies
3/16lockfile: add accessors get_lock_file_fd() and get_lock_file_fp()credential-store.c lockfile.c lockfile.h +2 more+26 -71 reply
4/16lockfile: add accessor get_lock_file_path()builtin/commit.c config.c lockfile.c +3 more+34 -201 reply
5/16commit_lock_file(): use get_locked_file_path()lockfile.c+12 -160 replies
6/16tempfile: a new module for handling temporary filesMakefile lockfile.c lockfile.h +2 more+470 -2700 replies
7/16prepare_tempfile_object(): new function, extracted from create_tempfile()tempfile.c+13 -71 reply
8/16tempfile: add several functions for creating temporary filestempfile.c tempfile.h+149 -00 replies
9/16register_tempfile(): new function to handle an existing temporary filetempfile.c tempfile.h+16 -00 replies
10/16write_shared_index(): use tempfile moduleread-cache.c+6 -320 replies
11/16setup_temporary_shallow(): use tempfile moduleshallow.c+7 -280 replies
12/16diff: use tempfile modulediff.c+7 -223 replies
12/16diff: use tempfile modulediff.c+23 -230 replies
13/16lock_repo_for_gc(): compute the path to "gc.pid" only oncebuiltin/gc.c+6 -32 replies
14/16gc: use tempfile module to handle gc.pid filebuiltin/gc.c+5 -200 replies
15/16credential-cache--daemon: delete socket from main()credential-cache--daemon.c+2 -10 replies
16/16credential-cache--daemon: use tempfile modulecredential-cache--daemon.c+6 -200 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 00/16] Introduce a tempfile module

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
Signature · 1 line
2.5.0