Skip to content

Commit

Permalink
Merge branch 'mh/tempfile' into pu
Browse files Browse the repository at this point in the history
Rebuild "lockfile" API on top of a new "tempfile" API.
This needs rerolling, to include "tempfile.h" in "lockfile.h", at
least.

($gmane/271353)

* mh/tempfile:
  credential-cache--daemon: use tempfile module
  credential-cache--daemon: delete socket from main()
  gc: use tempfile module to handle gc.pid file
  lock_repo_for_gc(): compute the path to "gc.pid" only once
  diff: use tempfile module
  setup_temporary_shallow(): use tempfile module
  write_shared_index(): use tempfile module
  register_tempfile(): new function to handle an existing temporary file
  tempfile: add several functions for creating temporary files
  register_tempfile_object(): new function, extracted from create_tempfile()
  commit_lock_file(): use get_locked_file_path()
  lockfile: remove some redundant functions
  tempfile: a new module for handling temporary files
  Move lockfile API documentation to lockfile.h
  • Loading branch information
gitster committed Aug 3, 2015
2 parents 8e58a1a + f133675 commit 6b962ed
Show file tree
Hide file tree
Showing 42 changed files with 859 additions and 617 deletions.
220 changes: 0 additions & 220 deletions Documentation/technical/api-lockfile.txt

This file was deleted.

1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ LIB_OBJS += submodule.o
LIB_OBJS += submodule-config.o
LIB_OBJS += symlinks.o
LIB_OBJS += tag.o
LIB_OBJS += tempfile.o
LIB_OBJS += trace.o
LIB_OBJS += trailer.o
LIB_OBJS += transport.o
Expand Down
1 change: 1 addition & 0 deletions builtin/add.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
#include "cache.h"
#include "builtin.h"
#include "tempfile.h"
#include "lockfile.h"
#include "dir.h"
#include "pathspec.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/am.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "dir.h"
#include "run-command.h"
#include "quote.h"
#include "tempfile.h"
#include "lockfile.h"
#include "cache-tree.h"
#include "refs.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
*/
#include "cache.h"
#include "tempfile.h"
#include "lockfile.h"
#include "cache-tree.h"
#include "quote.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/checkout-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*
*/
#include "builtin.h"
#include "tempfile.h"
#include "lockfile.h"
#include "quote.h"
#include "cache-tree.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/checkout.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "builtin.h"
#include "tempfile.h"
#include "lockfile.h"
#include "parse-options.h"
#include "refs.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

#include "builtin.h"
#include "tempfile.h"
#include "lockfile.h"
#include "parse-options.h"
#include "fetch-pack.h"
Expand Down
15 changes: 8 additions & 7 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include "cache.h"
#include "tempfile.h"
#include "lockfile.h"
#include "cache-tree.h"
#include "color.h"
Expand Down Expand Up @@ -345,7 +346,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
die(_("unable to write temporary index file"));

old_index_env = getenv(INDEX_ENVIRONMENT);
setenv(INDEX_ENVIRONMENT, index_lock.filename.buf, 1);
setenv(INDEX_ENVIRONMENT, index_lock.tempfile.filename.buf, 1);

if (interactive_add(argc, argv, prefix, patch_interactive) != 0)
die(_("interactive add failed"));
Expand All @@ -356,17 +357,17 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
unsetenv(INDEX_ENVIRONMENT);

discard_cache();
read_cache_from(index_lock.filename.buf);
read_cache_from(index_lock.tempfile.filename.buf);
if (update_main_cache_tree(WRITE_TREE_SILENT) == 0) {
if (reopen_lock_file(&index_lock) < 0)
if (reopen_tempfile(&index_lock.tempfile) < 0)
die(_("unable to write index file"));
if (write_locked_index(&the_index, &index_lock, CLOSE_LOCK))
die(_("unable to write temporary index file"));
} else
warning(_("Failed to update main cache tree"));

commit_style = COMMIT_NORMAL;
return index_lock.filename.buf;
return index_lock.tempfile.filename.buf;
}

/*
Expand All @@ -389,7 +390,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
if (write_locked_index(&the_index, &index_lock, CLOSE_LOCK))
die(_("unable to write index file"));
commit_style = COMMIT_NORMAL;
return index_lock.filename.buf;
return index_lock.tempfile.filename.buf;
}

/*
Expand Down Expand Up @@ -477,9 +478,9 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
die(_("unable to write temporary index file"));

discard_cache();
read_cache_from(false_lock.filename.buf);
read_cache_from(false_lock.tempfile.filename.buf);

return false_lock.filename.buf;
return false_lock.tempfile.filename.buf;
}

static int run_status(FILE *fp, const char *index_file, const char *prefix, int nowarn,
Expand Down
1 change: 1 addition & 0 deletions builtin/describe.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "cache.h"
#include "tempfile.h"
#include "lockfile.h"
#include "commit.h"
#include "tag.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright (c) 2006 Junio C Hamano
*/
#include "cache.h"
#include "tempfile.h"
#include "lockfile.h"
#include "color.h"
#include "commit.h"
Expand Down
Loading

0 comments on commit 6b962ed

Please sign in to comment.