From: Junio C Hamano Date: Tue, 31 May 2016 19:40:53 +0000 (-0700) Subject: Merge branch 'fc/fast-import-broken-marks-file' X-Git-Tag: v2.9.0-rc1~4 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/bc4b9247df12e668b93cca85d6a5415e6b007368?ds=inline;hp=-c 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 --- bc4b9247df12e668b93cca85d6a5415e6b007368 diff --combined fast-import.c index 83558dcfe3,a975c348d8..c504ef752d --- a/fast-import.c +++ b/fast-import.c @@@ -329,6 -329,7 +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 */ @@@ -414,7 -415,7 +415,7 @@@ static void write_crash_report(const ch struct recent_command *rc; if (!rpt) { - error("can't write crash report %s: %s", loc, strerror(errno)); + error_errno("can't write crash report %s", loc); free(loc); return; } @@@ -1512,7 -1513,7 +1513,7 @@@ static int tree_content_set t = root->tree; for (i = 0; i < t->entry_count; i++) { e = t->entries[i]; - if (e->name->str_len == n && !strncmp_icase(p, e->name->str_dat, n)) { + if (e->name->str_len == n && !fspathncmp(p, e->name->str_dat, n)) { if (!*slash1) { if (!S_ISDIR(mode) && e->versions[1].mode == mode @@@ -1602,7 -1603,7 +1603,7 @@@ static int tree_content_remove t = root->tree; for (i = 0; i < t->entry_count; i++) { e = t->entries[i]; - if (e->name->str_len == n && !strncmp_icase(p, e->name->str_dat, n)) { + if (e->name->str_len == n && !fspathncmp(p, e->name->str_dat, n)) { if (*slash1 && !S_ISDIR(e->versions[1].mode)) /* * If p names a file in some subdirectory, and a @@@ -1669,7 -1670,7 +1670,7 @@@ static int tree_content_get t = root->tree; for (i = 0; i < t->entry_count; i++) { e = t->entries[i]; - if (e->name->str_len == n && !strncmp_icase(p, e->name->str_dat, n)) { + if (e->name->str_len == n && !fspathncmp(p, e->name->str_dat, n)) { if (!*slash1) goto found_entry; if (!S_ISDIR(e->versions[1].mode)) @@@ -1802,12 -1803,12 +1803,12 @@@ 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) { - failure |= error("Unable to write marks file %s: %s", - export_marks_file, strerror(errno)); + failure |= error_errno("Unable to write marks file %s", + export_marks_file); return; } @@@ -1822,8 -1823,8 +1823,8 @@@ dump_marks_helper(f, 0, marks); if (commit_lock_file(&mark_lock)) { - failure |= error("Unable to write file %s: %s", - export_marks_file, strerror(errno)); + failure |= error_errno("Unable to write file %s", + export_marks_file); return; } } @@@ -1835,7 -1836,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 +1866,8 @@@ insert_mark(mark, e); } fclose(f); + done: + import_marks_file_done = 1; }