diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-01-20 14:42:59 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-01-20 14:42:59 -0800 |
commit | 71b3ef11fa0aade4a514c51b83438858a4a3c03b (patch) | |
tree | 6cea8215ecc0e70c8f19e04c51327deda93672d3 /builtin-commit.c | |
parent | f922df8655675aafaea96f3715c9473c63d2ca47 (diff) | |
parent | d38a30df7dd54c5c6883af1de1a03ec7d523cee5 (diff) | |
download | git-71b3ef11fa0aade4a514c51b83438858a4a3c03b.tar.gz |
Merge branch 'mm/conflict-advice'
* mm/conflict-advice:
Be more user-friendly when refusing to do something because of conflict.
Conflicts:
Documentation/config.txt
advice.c
advice.h
Diffstat (limited to 'builtin-commit.c')
-rw-r--r-- | builtin-commit.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/builtin-commit.c b/builtin-commit.c index 42f11c30ca..fedcda09d0 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -258,6 +258,16 @@ static void create_base_index(void) exit(128); /* We've already reported the error, finish dying */ } +static void refresh_cache_or_die(int refresh_flags) +{ + /* + * refresh_flags contains REFRESH_QUIET, so the only errors + * are for unmerged entries. + */ + if (refresh_cache(refresh_flags | REFRESH_IN_PORCELAIN)) + die_resolve_conflict("commit"); +} + static char *prepare_index(int argc, const char **argv, const char *prefix, int is_status) { int fd; @@ -297,7 +307,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int if (all || (also && pathspec && *pathspec)) { int fd = hold_locked_index(&index_lock, 1); add_files_to_cache(also ? prefix : NULL, pathspec, 0); - refresh_cache(refresh_flags); + refresh_cache_or_die(refresh_flags); if (write_cache(fd, active_cache, active_nr) || close_lock_file(&index_lock)) die("unable to write new_index file"); @@ -316,7 +326,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int */ if (!pathspec || !*pathspec) { fd = hold_locked_index(&index_lock, 1); - refresh_cache(refresh_flags); + refresh_cache_or_die(refresh_flags); if (write_cache(fd, active_cache, active_nr) || commit_locked_index(&index_lock)) die("unable to write new_index file"); |