@@ -68,6 +68,12 @@ enum patch_format {
68
68
PATCH_FORMAT_MBOX
69
69
};
70
70
71
+ enum keep_type {
72
+ KEEP_FALSE = 0 ,
73
+ KEEP_TRUE , /* pass -k flag to git-mailinfo */
74
+ KEEP_NON_PATCH /* pass -b flag to git-mailinfo */
75
+ };
76
+
71
77
struct am_state {
72
78
/* state directory path */
73
79
char * dir ;
@@ -91,6 +97,7 @@ struct am_state {
91
97
int quiet ;
92
98
int signoff ;
93
99
int utf8 ;
100
+ int keep ; /* enum keep_type */
94
101
const char * resolvemsg ;
95
102
int rebasing ;
96
103
};
@@ -373,6 +380,14 @@ static void am_load(struct am_state *state)
373
380
read_state_file (& sb , state , "utf8" , 1 );
374
381
state -> utf8 = !strcmp (sb .buf , "t" );
375
382
383
+ read_state_file (& sb , state , "keep" , 1 );
384
+ if (!strcmp (sb .buf , "t" ))
385
+ state -> keep = KEEP_TRUE ;
386
+ else if (!strcmp (sb .buf , "b" ))
387
+ state -> keep = KEEP_NON_PATCH ;
388
+ else
389
+ state -> keep = KEEP_FALSE ;
390
+
376
391
state -> rebasing = !!file_exists (am_path (state , "rebasing" ));
377
392
378
393
strbuf_release (& sb );
@@ -536,6 +551,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
536
551
const char * * paths )
537
552
{
538
553
unsigned char curr_head [GIT_SHA1_RAWSZ ];
554
+ const char * str ;
539
555
540
556
if (!patch_format )
541
557
patch_format = detect_patch_format (paths );
@@ -564,6 +580,22 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
564
580
565
581
write_file (am_path (state , "utf8" ), 1 , state -> utf8 ? "t" : "f" );
566
582
583
+ switch (state -> keep ) {
584
+ case KEEP_FALSE :
585
+ str = "f" ;
586
+ break ;
587
+ case KEEP_TRUE :
588
+ str = "t" ;
589
+ break ;
590
+ case KEEP_NON_PATCH :
591
+ str = "b" ;
592
+ break ;
593
+ default :
594
+ die ("BUG: invalid value for state->keep" );
595
+ }
596
+
597
+ write_file (am_path (state , "keep" ), 1 , "%s" , str );
598
+
567
599
if (state -> rebasing )
568
600
write_file (am_path (state , "rebasing" ), 1 , "%s" , "" );
569
601
else
@@ -731,6 +763,20 @@ static int parse_mail(struct am_state *state, const char *mail)
731
763
732
764
argv_array_push (& cp .args , "mailinfo" );
733
765
argv_array_push (& cp .args , state -> utf8 ? "-u" : "-n" );
766
+
767
+ switch (state -> keep ) {
768
+ case KEEP_FALSE :
769
+ break ;
770
+ case KEEP_TRUE :
771
+ argv_array_push (& cp .args , "-k" );
772
+ break ;
773
+ case KEEP_NON_PATCH :
774
+ argv_array_push (& cp .args , "-b" );
775
+ break ;
776
+ default :
777
+ die ("BUG: invalid value for state->keep" );
778
+ }
779
+
734
780
argv_array_push (& cp .args , am_path (state , "msg" ));
735
781
argv_array_push (& cp .args , am_path (state , "patch" ));
736
782
@@ -1471,6 +1517,10 @@ int cmd_am(int argc, const char **argv, const char *prefix)
1471
1517
N_ ("add a Signed-off-by line to the commit message" )),
1472
1518
OPT_BOOL ('u' , "utf8" , & state .utf8 ,
1473
1519
N_ ("recode into utf8 (default)" )),
1520
+ OPT_SET_INT ('k' , "keep" , & state .keep ,
1521
+ N_ ("pass -k flag to git-mailinfo" ), KEEP_TRUE ),
1522
+ OPT_SET_INT (0 , "keep-non-patch" , & state .keep ,
1523
+ N_ ("pass -b flag to git-mailinfo" ), KEEP_NON_PATCH ),
1474
1524
OPT_CALLBACK (0 , "patch-format" , & patch_format , N_ ("format" ),
1475
1525
N_ ("format the patch(es) are in" ),
1476
1526
parse_opt_patchformat ),
0 commit comments