Merge branch 'mm/maint-hint-failed-merge'
[git.git] / merge-recursive.c
index baabe2c35647d65716d1b82473846e80cc02957b..a91208f295d00d73b8fc0f5cd6a92ac422d9eeb4 100644 (file)
@@ -3,6 +3,7 @@
  * Fredrik Kuivinen.
  * The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006
  */
+#include "advice.h"
 #include "cache.h"
 #include "cache-tree.h"
 #include "commit.h"
@@ -171,7 +172,7 @@ static int git_merge_trees(int index_only,
        int rc;
        struct tree_desc t[3];
        struct unpack_trees_options opts;
-       static const struct unpack_trees_error_msgs msgs = {
+       struct unpack_trees_error_msgs msgs = {
                /* would_overwrite */
                "Your local changes to '%s' would be overwritten by merge.  Aborting.",
                /* not_uptodate_file */
@@ -183,6 +184,11 @@ static int git_merge_trees(int index_only,
                /* bind_overlap -- will not happen here */
                NULL,
        };
+       if (advice_commit_before_merge) {
+               msgs.would_overwrite = msgs.not_uptodate_file =
+                       "Your local changes to '%s' would be overwritten by merge.  Aborting.\n"
+                       "Please, commit your changes or stash them before you can merge.";
+       }
 
        memset(&opts, 0, sizeof(opts));
        if (index_only)