Re: [PATCH v8 4/4] cache-tree: Write updated cache-tree after commit
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Jul 13, 2014, 05:09 UTC
- Message-ID
- <CACsJy8D0CdS5B5xNSSCk+LToXV9FnHFLkPzJ5f-7NTWiw9yn5w@mail.gmail.com>
- In-Reply-To
- <1405140276-32162-4-git-send-email-dturner@twitter.com>
On Sat, Jul 12, 2014 at 11:44 AM, David Turner <dturner@twopensource.com> wrote:
Show 9 quoted lines
> @@ -342,6 +342,15 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
>
> discard_cache();
> read_cache_from(index_lock.filename);
> + if (update_main_cache_tree(WRITE_TREE_SILENT) == 0) {
> + fd = open(index_lock.filename, O_WRONLY);
> + if (fd >= 0)
> + if (write_cache(fd, active_cache, active_nr) == 0) {
> + close_lock_file(&index_lock);If write_cache() returns a negative value, index.lock is probably corrupted. Should we die() instead of moving on and returning index_lock.filename to the caller? The caller may move index.lock to index later on and officially ruin "index".
> + } > + } > + else > + fprintf(stderr, "FAiled to update main cache tree\n");
make the above line something like this for i18n support:
fprintf_ln(stderr, _("Failed to update main cache tree"));> > commit_style = COMMIT_NORMAL; > return index_lock.filename;
-- Duy