@@ -543,10 +543,24 @@ enum conflict_and_info_types {
543
543
CONFLICT_SUBMODULE_HISTORY_NOT_AVAILABLE ,
544
544
CONFLICT_SUBMODULE_MAY_HAVE_REWINDS ,
545
545
CONFLICT_SUBMODULE_NULL_MERGE_BASE ,
546
- CONFLICT_SUBMODULE_CORRUPT ,
546
+
547
+ /* INSERT NEW ENTRIES HERE */
548
+
549
+ /*
550
+ * Keep this entry after all regular conflict and info types; only
551
+ * errors (failures causing immediate abort of the merge) should
552
+ * come after this.
553
+ */
554
+ NB_REGULAR_CONFLICT_TYPES ,
555
+
556
+ /*
557
+ * Something is seriously wrong; cannot even perform merge;
558
+ * Keep this group _last_ other than NB_TOTAL_TYPES
559
+ */
560
+ ERROR_SUBMODULE_CORRUPT ,
547
561
548
562
/* Keep this entry _last_ in the list */
549
- NB_CONFLICT_TYPES ,
563
+ NB_TOTAL_TYPES ,
550
564
};
551
565
552
566
/*
@@ -597,8 +611,10 @@ static const char *type_short_descriptions[] = {
597
611
"CONFLICT (submodule may have rewinds)" ,
598
612
[CONFLICT_SUBMODULE_NULL_MERGE_BASE ] =
599
613
"CONFLICT (submodule lacks merge base)" ,
600
- [CONFLICT_SUBMODULE_CORRUPT ] =
601
- "CONFLICT (submodule corrupt)"
614
+
615
+ /* Something is seriously wrong; cannot even perform merge */
616
+ [ERROR_SUBMODULE_CORRUPT ] =
617
+ "ERROR (submodule corrupt)" ,
602
618
};
603
619
604
620
struct logical_conflict_info {
@@ -762,7 +778,8 @@ static void path_msg(struct merge_options *opt,
762
778
763
779
/* Sanity checks */
764
780
assert (omittable_hint ==
765
- !starts_with (type_short_descriptions [type ], "CONFLICT" ) ||
781
+ (!starts_with (type_short_descriptions [type ], "CONFLICT" ) &&
782
+ !starts_with (type_short_descriptions [type ], "ERROR" )) ||
766
783
type == CONFLICT_DIR_RENAME_SUGGESTED );
767
784
if (opt -> record_conflict_msgs_as_headers && omittable_hint )
768
785
return ; /* Do not record mere hints in headers */
@@ -1817,9 +1834,9 @@ static int merge_submodule(struct merge_options *opt,
1817
1834
/* check whether both changes are forward */
1818
1835
ret2 = repo_in_merge_bases (& subrepo , commit_o , commit_a );
1819
1836
if (ret2 < 0 ) {
1820
- path_msg (opt , CONFLICT_SUBMODULE_CORRUPT , 0 ,
1837
+ path_msg (opt , ERROR_SUBMODULE_CORRUPT , 0 ,
1821
1838
path , NULL , NULL , NULL ,
1822
- _ ("Failed to merge submodule %s "
1839
+ _ ("error: failed to merge submodule %s "
1823
1840
"(repository corrupt)" ),
1824
1841
path );
1825
1842
ret = -1 ;
@@ -1828,9 +1845,9 @@ static int merge_submodule(struct merge_options *opt,
1828
1845
if (ret2 > 0 )
1829
1846
ret2 = repo_in_merge_bases (& subrepo , commit_o , commit_b );
1830
1847
if (ret2 < 0 ) {
1831
- path_msg (opt , CONFLICT_SUBMODULE_CORRUPT , 0 ,
1848
+ path_msg (opt , ERROR_SUBMODULE_CORRUPT , 0 ,
1832
1849
path , NULL , NULL , NULL ,
1833
- _ ("Failed to merge submodule %s "
1850
+ _ ("error: failed to merge submodule %s "
1834
1851
"(repository corrupt)" ),
1835
1852
path );
1836
1853
ret = -1 ;
@@ -1848,9 +1865,9 @@ static int merge_submodule(struct merge_options *opt,
1848
1865
/* Case #1: a is contained in b or vice versa */
1849
1866
ret2 = repo_in_merge_bases (& subrepo , commit_a , commit_b );
1850
1867
if (ret2 < 0 ) {
1851
- path_msg (opt , CONFLICT_SUBMODULE_CORRUPT , 0 ,
1868
+ path_msg (opt , ERROR_SUBMODULE_CORRUPT , 0 ,
1852
1869
path , NULL , NULL , NULL ,
1853
- _ ("Failed to merge submodule %s "
1870
+ _ ("error: failed to merge submodule %s "
1854
1871
"(repository corrupt)" ),
1855
1872
path );
1856
1873
ret = -1 ;
@@ -1867,9 +1884,9 @@ static int merge_submodule(struct merge_options *opt,
1867
1884
}
1868
1885
ret2 = repo_in_merge_bases (& subrepo , commit_b , commit_a );
1869
1886
if (ret2 < 0 ) {
1870
- path_msg (opt , CONFLICT_SUBMODULE_CORRUPT , 0 ,
1887
+ path_msg (opt , ERROR_SUBMODULE_CORRUPT , 0 ,
1871
1888
path , NULL , NULL , NULL ,
1872
- _ ("Failed to merge submodule %s "
1889
+ _ ("error: failed to merge submodule %s "
1873
1890
"(repository corrupt)" ),
1874
1891
path );
1875
1892
ret = -1 ;
@@ -1901,9 +1918,9 @@ static int merge_submodule(struct merge_options *opt,
1901
1918
& merges );
1902
1919
switch (parent_count ) {
1903
1920
case -1 :
1904
- path_msg (opt , CONFLICT_SUBMODULE_CORRUPT , 0 ,
1921
+ path_msg (opt , ERROR_SUBMODULE_CORRUPT , 0 ,
1905
1922
path , NULL , NULL , NULL ,
1906
- _ ("Failed to merge submodule %s "
1923
+ _ ("error: failed to merge submodule %s "
1907
1924
"(repository corrupt)" ),
1908
1925
path );
1909
1926
ret = -1 ;
@@ -4646,6 +4663,7 @@ void merge_display_update_messages(struct merge_options *opt,
4646
4663
struct hashmap_iter iter ;
4647
4664
struct strmap_entry * e ;
4648
4665
struct string_list olist = STRING_LIST_INIT_NODUP ;
4666
+ FILE * o = stdout ;
4649
4667
4650
4668
if (opt -> record_conflict_msgs_as_headers )
4651
4669
BUG ("Either display conflict messages or record them as headers, not both" );
@@ -4662,32 +4680,42 @@ void merge_display_update_messages(struct merge_options *opt,
4662
4680
}
4663
4681
string_list_sort (& olist );
4664
4682
4683
+ /* Print to stderr if we hit errors rather than just conflicts */
4684
+ if (result -> clean < 0 )
4685
+ o = stderr ;
4686
+
4665
4687
/* Iterate over the items, printing them */
4666
4688
for (int path_nr = 0 ; path_nr < olist .nr ; ++ path_nr ) {
4667
4689
struct string_list * conflicts = olist .items [path_nr ].util ;
4668
4690
for (int i = 0 ; i < conflicts -> nr ; i ++ ) {
4669
4691
struct logical_conflict_info * info =
4670
4692
conflicts -> items [i ].util ;
4671
4693
4694
+ /* On failure, ignore regular conflict types */
4695
+ if (result -> clean < 0 &&
4696
+ info -> type < NB_REGULAR_CONFLICT_TYPES )
4697
+ continue ;
4698
+
4672
4699
if (detailed ) {
4673
- printf ( "%lu" , (unsigned long )info -> paths .nr );
4674
- putchar ('\0' );
4700
+ fprintf ( o , "%lu" , (unsigned long )info -> paths .nr );
4701
+ fputc ('\0' , o );
4675
4702
for (int n = 0 ; n < info -> paths .nr ; n ++ ) {
4676
- fputs (info -> paths .v [n ], stdout );
4677
- putchar ('\0' );
4703
+ fputs (info -> paths .v [n ], o );
4704
+ fputc ('\0' , o );
4678
4705
}
4679
- fputs (type_short_descriptions [info -> type ],
4680
- stdout );
4681
- putchar ('\0' );
4706
+ fputs (type_short_descriptions [info -> type ], o );
4707
+ fputc ('\0' , o );
4682
4708
}
4683
- puts (conflicts -> items [i ].string );
4709
+ fputs (conflicts -> items [i ].string , o );
4710
+ fputc ('\n' , o );
4684
4711
if (detailed )
4685
- putchar ('\0' );
4712
+ fputc ('\0' , o );
4686
4713
}
4687
4714
}
4688
4715
string_list_clear (& olist , 0 );
4689
4716
4690
- print_submodule_conflict_suggestion (& opti -> conflicted_submodules );
4717
+ if (result -> clean >= 0 )
4718
+ print_submodule_conflict_suggestion (& opti -> conflicted_submodules );
4691
4719
4692
4720
/* Also include needed rename limit adjustment now */
4693
4721
diff_warn_rename_limit ("merge.renamelimit" ,
0 commit comments