Make index file locking code reusable to others.

The framework to create lockfiles that are removed at exit is
first used to reliably write the index file, but it is
applicable to other things, so stop calling it "cache_file".

This also rewords a few remaining error message that called the
index file "cache file".

Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Junio C Hamano
2006-06-06 12:51:49 -07:00
parent dd8239f997
commit 021b6e4549
11 changed files with 98 additions and 95 deletions

View File

@ -11,7 +11,7 @@ static int missing_ok = 0;
static const char write_tree_usage[] = "git-write-tree [--missing-ok]";
static struct cache_file cache_file;
static struct lock_file lock_file;
int main(int argc, char **argv)
{
@ -19,7 +19,7 @@ int main(int argc, char **argv)
setup_git_directory();
newfd = hold_index_file_for_update(&cache_file, get_index_file());
newfd = hold_lock_file_for_update(&lock_file, get_index_file());
entries = read_cache();
if (argc == 2) {
if (!strcmp(argv[1], "--missing-ok"))
@ -45,7 +45,7 @@ int main(int argc, char **argv)
die("git-write-tree: error building trees");
if (0 <= newfd) {
if (!write_cache(newfd, active_cache, active_nr))
commit_index_file(&cache_file);
commit_lock_file(&lock_file);
}
/* Not being able to write is fine -- we are only interested
* in updating the cache-tree part, and if the next caller