@@ -258,6 +258,16 @@ static void create_base_index(void)
258258 exit (128 ); /* We've already reported the error, finish dying */
259259}
260260
261+ static void refresh_cache_or_die (int refresh_flags )
262+ {
263+ /*
264+ * refresh_flags contains REFRESH_QUIET, so the only errors
265+ * are for unmerged entries.
266+ */
267+ if (refresh_cache (refresh_flags | REFRESH_IN_PORCELAIN ))
268+ die_resolve_conflict ("commit" );
269+ }
270+
261271static char * prepare_index (int argc , const char * * argv , const char * prefix , int is_status )
262272{
263273 int fd ;
@@ -297,7 +307,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
297307 if (all || (also && pathspec && * pathspec )) {
298308 int fd = hold_locked_index (& index_lock , 1 );
299309 add_files_to_cache (also ? prefix : NULL , pathspec , 0 );
300- refresh_cache (refresh_flags );
310+ refresh_cache_or_die (refresh_flags );
301311 if (write_cache (fd , active_cache , active_nr ) ||
302312 close_lock_file (& index_lock ))
303313 die ("unable to write new_index file" );
@@ -316,7 +326,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
316326 */
317327 if (!pathspec || !* pathspec ) {
318328 fd = hold_locked_index (& index_lock , 1 );
319- refresh_cache (refresh_flags );
329+ refresh_cache_or_die (refresh_flags );
320330 if (write_cache (fd , active_cache , active_nr ) ||
321331 commit_locked_index (& index_lock ))
322332 die ("unable to write new_index file" );
0 commit comments