grep/pcre: support utf-8
[gitweb.git] / entry.c
diff --git a/entry.c b/entry.c
index 77c688262477e783b4bcbc237ef281eecab0661d..582c40071a3034af9a391cf438dd74ddb34e15ff 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -96,8 +96,8 @@ static int open_output_fd(char *path, const struct cache_entry *ce, int to_tempf
 {
        int symlink = (ce->ce_mode & S_IFMT) != S_IFREG;
        if (to_tempfile) {
-               strcpy(path, symlink
-                      ? ".merge_link_XXXXXX" : ".merge_file_XXXXXX");
+               xsnprintf(path, TEMPORARY_FILENAME_LENGTH, "%s",
+                         symlink ? ".merge_link_XXXXXX" : ".merge_file_XXXXXX");
                return mkstemp(path);
        } else {
                return create_file(path, !symlink ? ce->ce_mode : 0666);
@@ -210,9 +210,12 @@ static int write_entry(struct cache_entry *ce,
 
 finish:
        if (state->refresh_cache) {
+               assert(state->istate);
                if (!fstat_done)
                        lstat(ce->name, &st);
                fill_stat_cache_info(ce, &st);
+               ce->ce_flags |= CE_UPDATE_IN_BASE;
+               state->istate->cache_changed |= CE_ENTRY_CHANGED;
        }
        return 0;
 }