summaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-05-31 12:40:53 -0700
committerJunio C Hamano <gitster@pobox.com>2016-05-31 12:40:53 -0700
commitbc4b9247df12e668b93cca85d6a5415e6b007368 (patch)
tree8fe06b21d28f00c5a1fdd0d3b95b937f396ef6c8 /fast-import.c
parentf3913c2d03abc660140678a9e14dac399f847647 (diff)
parentf4beed60d5ef3fdbd31ac5bd3162182fdf2bf0d3 (diff)
downloadgit-bc4b9247df12e668b93cca85d6a5415e6b007368.tar.gz
Merge branch 'fc/fast-import-broken-marks-file'
"git fast-import --export-marks" would overwrite the existing marks file even when it makes a dump from its custom die routine. Prevent it from doing so when we have an import-marks file but haven't finished reading it. * fc/fast-import-broken-marks-file: fast-import: do not truncate exported marks file
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fast-import.c b/fast-import.c
index 83558dcfe3..c504ef752d 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -329,6 +329,7 @@ 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 import_marks_file_done;
static int relative_marks_paths;
/* Our last blob */
@@ -1802,7 +1803,7 @@ static void dump_marks(void)
static struct lock_file mark_lock;
FILE *f;
- if (!export_marks_file)
+ if (!export_marks_file || (import_marks_file && !import_marks_file_done))
return;
if (hold_lock_file_for_update(&mark_lock, export_marks_file, 0) < 0) {
@@ -1835,7 +1836,7 @@ static void read_marks(void)
if (f)
;
else if (import_marks_file_ignore_missing && errno == ENOENT)
- return; /* Marks file does not exist */
+ goto done; /* Marks file does not exist */
else
die_errno("cannot read '%s'", import_marks_file);
while (fgets(line, sizeof(line), f)) {
@@ -1865,6 +1866,8 @@ static void read_marks(void)
insert_mark(mark, e);
}
fclose(f);
+done:
+ import_marks_file_done = 1;
}