37
37
#include "packfile.h"
38
38
#include "tag.h"
39
39
#include "alias.h"
40
+ #include "branch.h"
40
41
#include "commit-reach.h"
41
42
#include "wt-status.h"
42
43
@@ -73,6 +74,7 @@ static int option_renormalize;
73
74
static int verbosity ;
74
75
static int allow_rerere_auto ;
75
76
static int abort_current_merge ;
77
+ static int quit_current_merge ;
76
78
static int continue_current_merge ;
77
79
static int allow_unrelated_histories ;
78
80
static int show_progress = -1 ;
@@ -274,6 +276,8 @@ static struct option builtin_merge_options[] = {
274
276
OPT__VERBOSITY (& verbosity ),
275
277
OPT_BOOL (0 , "abort" , & abort_current_merge ,
276
278
N_ ("abort the current in-progress merge" )),
279
+ OPT_BOOL (0 , "quit" , & quit_current_merge ,
280
+ N_ ("--abort but leave index and working tree alone" )),
277
281
OPT_BOOL (0 , "continue" , & continue_current_merge ,
278
282
N_ ("continue the current in-progress merge" )),
279
283
OPT_BOOL (0 , "allow-unrelated-histories" , & allow_unrelated_histories ,
@@ -287,14 +291,6 @@ static struct option builtin_merge_options[] = {
287
291
OPT_END ()
288
292
};
289
293
290
- /* Cleans up metadata that is uninteresting after a succeeded merge. */
291
- static void drop_save (void )
292
- {
293
- unlink (git_path_merge_head (the_repository ));
294
- unlink (git_path_merge_msg (the_repository ));
295
- unlink (git_path_merge_mode (the_repository ));
296
- }
297
-
298
294
static int save_state (struct object_id * stash )
299
295
{
300
296
int len ;
@@ -388,7 +384,7 @@ static void finish_up_to_date(const char *msg)
388
384
{
389
385
if (verbosity >= 0 )
390
386
printf ("%s%s\n" , squash ? _ (" (nothing to squash)" ) : "" , msg );
391
- drop_save ( );
387
+ remove_merge_branch_state ( the_repository );
392
388
}
393
389
394
390
static void squash_message (struct commit * commit , struct commit_list * remoteheads )
@@ -881,7 +877,7 @@ static int merge_trivial(struct commit *head, struct commit_list *remoteheads)
881
877
& result_commit , NULL , sign_commit ))
882
878
die (_ ("failed to write commit object" ));
883
879
finish (head , remoteheads , & result_commit , "In-index merge" );
884
- drop_save ( );
880
+ remove_merge_branch_state ( the_repository );
885
881
return 0 ;
886
882
}
887
883
@@ -907,7 +903,7 @@ static int finish_automerge(struct commit *head,
907
903
strbuf_addf (& buf , "Merge made by the '%s' strategy." , wt_strategy );
908
904
finish (head , remoteheads , & result_commit , buf .buf );
909
905
strbuf_release (& buf );
910
- drop_save ( );
906
+ remove_merge_branch_state ( the_repository );
911
907
return 0 ;
912
908
}
913
909
@@ -1289,6 +1285,16 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1289
1285
goto done ;
1290
1286
}
1291
1287
1288
+ if (quit_current_merge ) {
1289
+ if (orig_argc != 2 )
1290
+ usage_msg_opt (_ ("--quit expects no arguments" ),
1291
+ builtin_merge_usage ,
1292
+ builtin_merge_options );
1293
+
1294
+ remove_merge_branch_state (the_repository );
1295
+ goto done ;
1296
+ }
1297
+
1292
1298
if (continue_current_merge ) {
1293
1299
int nargc = 1 ;
1294
1300
const char * nargv [] = {"commit" , NULL };
@@ -1495,7 +1501,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1495
1501
}
1496
1502
1497
1503
finish (head_commit , remoteheads , & commit -> object .oid , msg .buf );
1498
- drop_save ( );
1504
+ remove_merge_branch_state ( the_repository );
1499
1505
goto done ;
1500
1506
} else if (!remoteheads -> next && common -> next )
1501
1507
;
0 commit comments