@@ -329,6 +329,7 @@ static struct mark_set *marks;
329329static const char * export_marks_file ;
330330static const char * import_marks_file ;
331331static int import_marks_file_from_stream ;
332+ static int import_marks_file_ignore_missing ;
332333static int relative_marks_paths ;
333334
334335/* Our last blob */
@@ -1795,7 +1796,11 @@ static void read_marks(void)
17951796{
17961797 char line [512 ];
17971798 FILE * f = fopen (import_marks_file , "r" );
1798- if (!f )
1799+ if (f )
1800+ ;
1801+ else if (import_marks_file_ignore_missing && errno == ENOENT )
1802+ return ; /* Marks file does not exist */
1803+ else
17991804 die_errno ("cannot read '%s'" , import_marks_file );
18001805 while (fgets (line , sizeof (line ), f )) {
18011806 uintmax_t mark ;
@@ -2867,7 +2872,8 @@ static char* make_fast_import_path(const char *path)
28672872 return strbuf_detach (& abs_path , NULL );
28682873}
28692874
2870- static void option_import_marks (const char * marks , int from_stream )
2875+ static void option_import_marks (const char * marks ,
2876+ int from_stream , int ignore_missing )
28712877{
28722878 if (import_marks_file ) {
28732879 if (from_stream )
@@ -2881,6 +2887,7 @@ static void option_import_marks(const char *marks, int from_stream)
28812887 import_marks_file = make_fast_import_path (marks );
28822888 safe_create_leading_directories_const (import_marks_file );
28832889 import_marks_file_from_stream = from_stream ;
2890+ import_marks_file_ignore_missing = ignore_missing ;
28842891}
28852892
28862893static void option_date_format (const char * fmt )
@@ -2980,7 +2987,10 @@ static int parse_one_feature(const char *feature, int from_stream)
29802987 if (!prefixcmp (feature , "date-format=" )) {
29812988 option_date_format (feature + 12 );
29822989 } else if (!prefixcmp (feature , "import-marks=" )) {
2983- option_import_marks (feature + 13 , from_stream );
2990+ option_import_marks (feature + 13 , from_stream , 0 );
2991+ } else if (!prefixcmp (feature , "import-marks-if-exists=" )) {
2992+ option_import_marks (feature + strlen ("import-marks-if-exists=" ),
2993+ from_stream , 1 );
29842994 } else if (!prefixcmp (feature , "export-marks=" )) {
29852995 option_export_marks (feature + 13 );
29862996 } else if (!strcmp (feature , "cat-blob" )) {
0 commit comments