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 filemaint
commit
bc4b9247df
|
@ -329,6 +329,7 @@ static const char *export_marks_file;
|
||||||
static const char *import_marks_file;
|
static const char *import_marks_file;
|
||||||
static int import_marks_file_from_stream;
|
static int import_marks_file_from_stream;
|
||||||
static int import_marks_file_ignore_missing;
|
static int import_marks_file_ignore_missing;
|
||||||
|
static int import_marks_file_done;
|
||||||
static int relative_marks_paths;
|
static int relative_marks_paths;
|
||||||
|
|
||||||
/* Our last blob */
|
/* Our last blob */
|
||||||
|
@ -1802,7 +1803,7 @@ static void dump_marks(void)
|
||||||
static struct lock_file mark_lock;
|
static struct lock_file mark_lock;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if (!export_marks_file)
|
if (!export_marks_file || (import_marks_file && !import_marks_file_done))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (hold_lock_file_for_update(&mark_lock, export_marks_file, 0) < 0) {
|
if (hold_lock_file_for_update(&mark_lock, export_marks_file, 0) < 0) {
|
||||||
|
@ -1835,7 +1836,7 @@ static void read_marks(void)
|
||||||
if (f)
|
if (f)
|
||||||
;
|
;
|
||||||
else if (import_marks_file_ignore_missing && errno == ENOENT)
|
else if (import_marks_file_ignore_missing && errno == ENOENT)
|
||||||
return; /* Marks file does not exist */
|
goto done; /* Marks file does not exist */
|
||||||
else
|
else
|
||||||
die_errno("cannot read '%s'", import_marks_file);
|
die_errno("cannot read '%s'", import_marks_file);
|
||||||
while (fgets(line, sizeof(line), f)) {
|
while (fgets(line, sizeof(line), f)) {
|
||||||
|
@ -1865,6 +1866,8 @@ static void read_marks(void)
|
||||||
insert_mark(mark, e);
|
insert_mark(mark, e);
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
done:
|
||||||
|
import_marks_file_done = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2650,6 +2650,21 @@ test_expect_success 'R: ignore non-git options' '
|
||||||
git fast-import <input
|
git fast-import <input
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'R: corrupt lines do not mess marks file' '
|
||||||
|
rm -f io.marks &&
|
||||||
|
blob=$(echo hi | git hash-object --stdin) &&
|
||||||
|
cat >expect <<-EOF &&
|
||||||
|
:3 0000000000000000000000000000000000000000
|
||||||
|
:1 $blob
|
||||||
|
:2 $blob
|
||||||
|
EOF
|
||||||
|
cp expect io.marks &&
|
||||||
|
test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
|
||||||
|
|
||||||
|
EOF
|
||||||
|
test_cmp expect io.marks
|
||||||
|
'
|
||||||
|
|
||||||
##
|
##
|
||||||
## R: very large blobs
|
## R: very large blobs
|
||||||
##
|
##
|
||||||
|
|
Loading…
Reference in New Issue