File tree Expand file tree Collapse file tree 4 files changed +14
-1
lines changed Expand file tree Collapse file tree 4 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,10 @@ advice.*::
126
126
Directions on how to stage/unstage/add shown in the
127
127
output of linkgit:git-status[1] and the template shown
128
128
when writing commit messages. Default: true.
129
+ commitBeforeMerge::
130
+ Advice shown when linkgit:git-merge[1] refuses to
131
+ merge to avoid overwritting local changes.
132
+ Default: true.
129
133
--
130
134
131
135
core.fileMode::
Original file line number Diff line number Diff line change 2
2
3
3
int advice_push_nonfastforward = 1 ;
4
4
int advice_status_hints = 1 ;
5
+ int advice_commit_before_merge = 1 ;
5
6
6
7
static struct {
7
8
const char * name ;
8
9
int * preference ;
9
10
} advice_config [] = {
10
11
{ "pushnonfastforward" , & advice_push_nonfastforward },
11
12
{ "statushints" , & advice_status_hints },
13
+ { "commitbeforemerge" , & advice_commit_before_merge },
12
14
};
13
15
14
16
int git_default_advice_config (const char * var , const char * value )
Original file line number Diff line number Diff line change 3
3
4
4
extern int advice_push_nonfastforward ;
5
5
extern int advice_status_hints ;
6
+ extern int advice_commit_before_merge ;
6
7
7
8
int git_default_advice_config (const char * var , const char * value );
8
9
Original file line number Diff line number Diff line change 3
3
* Fredrik Kuivinen.
4
4
* The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006
5
5
*/
6
+ #include "advice.h"
6
7
#include "cache.h"
7
8
#include "cache-tree.h"
8
9
#include "commit.h"
@@ -170,7 +171,7 @@ static int git_merge_trees(int index_only,
170
171
int rc ;
171
172
struct tree_desc t [3 ];
172
173
struct unpack_trees_options opts ;
173
- static const struct unpack_trees_error_msgs msgs = {
174
+ struct unpack_trees_error_msgs msgs = {
174
175
/* would_overwrite */
175
176
"Your local changes to '%s' would be overwritten by merge. Aborting." ,
176
177
/* not_uptodate_file */
@@ -182,6 +183,11 @@ static int git_merge_trees(int index_only,
182
183
/* bind_overlap -- will not happen here */
183
184
NULL ,
184
185
};
186
+ if (advice_commit_before_merge ) {
187
+ msgs .would_overwrite = msgs .not_uptodate_file =
188
+ "Your local changes to '%s' would be overwritten by merge. Aborting.\n"
189
+ "Please, commit your changes or stash them before you can merge." ;
190
+ }
185
191
186
192
memset (& opts , 0 , sizeof (opts ));
187
193
if (index_only )
You can’t perform that action at this time.
0 commit comments