aboutsummaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-02-09 16:41:16 -0800
committerJunio C Hamano <gitster@pobox.com>2011-02-09 16:41:16 -0800
commitfc180d98a20b6270ec25ca19c8d18a0a1286fe15 (patch)
treeb6adc1fc09968b5cd087d6c08ec197a0ea312438 /fast-import.c
parent5bb20ece6bdb31d395667855990dc540f2940a41 (diff)
parentdded4f12a46274753439e3a8fa4eb756c5d14ae1 (diff)
downloadgit-fc180d98a20b6270ec25ca19c8d18a0a1286fe15.tar.gz
git-fc180d98a20b6270ec25ca19c8d18a0a1286fe15.tar.xz
Merge branch 'rr/fi-import-marks-if-exists'
* rr/fi-import-marks-if-exists: fast-import: Introduce --import-marks-if-exists
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/fast-import.c b/fast-import.c
index 970d8470e..3886a1b46 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -329,6 +329,7 @@ static struct mark_set *marks;
static const char *export_marks_file;
static const char *import_marks_file;
static int import_marks_file_from_stream;
+static int import_marks_file_ignore_missing;
static int relative_marks_paths;
/* Our last blob */
@@ -1795,7 +1796,11 @@ static void read_marks(void)
{
char line[512];
FILE *f = fopen(import_marks_file, "r");
- if (!f)
+ if (f)
+ ;
+ else if (import_marks_file_ignore_missing && errno == ENOENT)
+ return; /* Marks file does not exist */
+ else
die_errno("cannot read '%s'", import_marks_file);
while (fgets(line, sizeof(line), f)) {
uintmax_t mark;
@@ -2867,7 +2872,8 @@ static char* make_fast_import_path(const char *path)
return strbuf_detach(&abs_path, NULL);
}
-static void option_import_marks(const char *marks, int from_stream)
+static void option_import_marks(const char *marks,
+ int from_stream, int ignore_missing)
{
if (import_marks_file) {
if (from_stream)
@@ -2881,6 +2887,7 @@ static void option_import_marks(const char *marks, int from_stream)
import_marks_file = make_fast_import_path(marks);
safe_create_leading_directories_const(import_marks_file);
import_marks_file_from_stream = from_stream;
+ import_marks_file_ignore_missing = ignore_missing;
}
static void option_date_format(const char *fmt)
@@ -2980,7 +2987,10 @@ static int parse_one_feature(const char *feature, int from_stream)
if (!prefixcmp(feature, "date-format=")) {
option_date_format(feature + 12);
} else if (!prefixcmp(feature, "import-marks=")) {
- option_import_marks(feature + 13, from_stream);
+ option_import_marks(feature + 13, from_stream, 0);
+ } else if (!prefixcmp(feature, "import-marks-if-exists=")) {
+ option_import_marks(feature + strlen("import-marks-if-exists="),
+ from_stream, 1);
} else if (!prefixcmp(feature, "export-marks=")) {
option_export_marks(feature + 13);
} else if (!strcmp(feature, "cat-blob")) {