From 0980b64fd0d57fb5fea63baa61f4c9c990d660ef Mon Sep 17 00:00:00 2001 From: Jakub Bogusz Date: Sun, 7 Apr 2024 16:09:30 +0200 Subject: [PATCH] - updated to 1.66 --- cvs-fast-export-asan.patch | 40 +++---- cvs-fast-export-tsan.patch | 205 +++++++++++++++++++---------------- cvs-fast-export-ubsan.patch | 72 ++++++------ cvs-fast-export.spec | 4 +- hack-disable-cvsignore.patch | 26 ++--- 5 files changed, 182 insertions(+), 165 deletions(-) diff --git a/cvs-fast-export-asan.patch b/cvs-fast-export-asan.patch index 26b4721..c5f056f 100644 --- a/cvs-fast-export-asan.patch +++ b/cvs-fast-export-asan.patch @@ -1,20 +1,20 @@ ---- cvs-fast-export-1.62/export.c.orig 2023-12-10 22:08:38.039921414 +0100 -+++ cvs-fast-export-1.62/export.c 2023-12-11 06:17:08.424656665 +0100 -@@ -208,7 +208,7 @@ static void export_blob(node_t *node, - for (char *cp = cbuf; cp < cbuf + len; cp++) - if (*cp == ' ') - *cp = '\n'; -- if (strlen(cbuf) >= 2 && cbuf[0] == '!' && cbuf[1] == '\n') -+ if (strnlen(cbuf, len) >= 2 && cbuf[0] == '!' && cbuf[1] == '\n') - extralen = 0; - } - -@@ -697,7 +697,7 @@ static struct commit_seq *canonicalize(g - #define is_branchroot_of(x, y) ((x)->head == (y)->head && (x)->isbase) - #define is_older_than(x, y) (((struct commit_seq *)x)->commit->date < ((struct commit_seq *)y)->commit->date) - /* back up as far as we can */ -- while (!is_parent_of(bp-1, hp) && !is_branchroot_of(bp-1, hp) && !is_older_than(bp-1, hp)) -+ while ((bp > history) && !is_parent_of(bp-1, hp) && !is_branchroot_of(bp-1, hp) && !is_older_than(bp-1, hp)) - bp--; - if (bp < hp) { - /* shift commits up and put *hp where *bp was */ +--- cvs-fast-export-1.66/export.c.orig 2024-04-07 15:56:24.234143317 +0200 ++++ cvs-fast-export-1.66/export.c 2024-04-07 15:59:49.626363945 +0200 +@@ -182,7 +182,7 @@ static void export_blob(node_t *node, vo + *cp = '\n'; + } + } +- if (strlen(cbuf) >= 2 && cbuf[0] == '!' && cbuf[1] == '\n') { ++ if (strnlen(cbuf, len) >= 2 && cbuf[0] == '!' && cbuf[1] == '\n') { + extralen = 0; + cbuf += 2; + clen -= 2; +@@ -724,7 +724,7 @@ static struct commit_seq *canonicalize(g + (((struct commit_seq *)x)->commit->date < \ + ((struct commit_seq *)y)->commit->date) + /* back up as far as we can */ +- while (!is_parent_of(bp - 1, hp) && ++ while ((bp > history) && !is_parent_of(bp - 1, hp) && + !is_branchroot_of(bp - 1, hp) && + !is_older_than(bp - 1, hp)) { + bp--; diff --git a/cvs-fast-export-tsan.patch b/cvs-fast-export-tsan.patch index 48b831a..87b3294 100644 --- a/cvs-fast-export-tsan.patch +++ b/cvs-fast-export-tsan.patch @@ -1,67 +1,77 @@ ---- cvs-fast-export-1.62/atom.c.orig 2023-12-10 21:33:28.557717340 +0100 -+++ cvs-fast-export-1.62/atom.c 2023-12-10 21:33:33.707747222 +0100 -@@ -99,21 +99,22 @@ atom(const char *string) - hash_bucket_t *b; - int len; +--- cvs-fast-export-1.66/atom.c.orig 2024-04-07 15:44:05.728144147 +0200 ++++ cvs-fast-export-1.66/atom.c 2024-04-07 15:49:33.189703469 +0200 +@@ -100,24 +100,24 @@ const char *atom(const char *string) + hash_bucket_t *b; + int len; -- while ((b = *head)) { --collision: -- if (b->hash == hash && !strcmp(string, b->string)) -- return b->string; -- head = &(b->next); -- } - #ifdef THREADS - if (threads > 1) - pthread_mutex_lock(&bucket_mutex); - #endif /* THREADS */ -- if ((b = *head)) { -+ while ((b = *head)) { -+collision: -+ if (b->hash == hash && !strcmp(string, b->string)) { - #ifdef THREADS - if (threads > 1) - pthread_mutex_unlock(&bucket_mutex); - #endif /* THREADS */ -+ return b->string; ++#ifdef THREADS ++ if (threads > 1) { ++ pthread_mutex_lock(&bucket_mutex); + } -+ head = &(b->next); -+ } -+ if ((b = *head)) { - goto collision; - } ++#endif /* THREADS */ + while ((b = *head)) { + collision: + if (b->hash == hash && !strcmp(string, b->string)) { ++#ifdef THREADS ++ if (threads > 1) { ++ pthread_mutex_unlock(&bucket_mutex); ++ } ++#endif /* THREADS */ + return b->string; + } + head = &(b->next); + } +-#ifdef THREADS +- if (threads > 1) { +- pthread_mutex_lock(&bucket_mutex); +- } +-#endif /* THREADS */ + if ((b = *head)) { +-#ifdef THREADS +- if (threads > 1) { +- pthread_mutex_unlock(&bucket_mutex); +- } +-#endif /* THREADS */ + goto collision; + } -@@ -154,21 +155,22 @@ atom_cvs_number(const cvs_number n) - number_bucket_t **head = &number_buckets[bucket]; - number_bucket_t *b; +@@ -157,24 +157,24 @@ const cvs_number *atom_cvs_number(const + number_bucket_t **head = &number_buckets[bucket]; + number_bucket_t *b; -- while ((b = *head)) { -- collision: -- if (cvs_number_equal(&b->number, &n)) -- return &b->number; -- head = &(b->next); -- } - #ifdef THREADS - if (threads > 1) - pthread_mutex_lock(&number_bucket_mutex); - #endif /* THREADS */ -- if ((b = *head)) { -+ while ((b = *head)) { -+ collision: -+ if (cvs_number_equal(&b->number, &n)) { - #ifdef THREADS - if (threads > 1) - pthread_mutex_unlock(&number_bucket_mutex); - #endif /* THREADS */ -+ return &b->number; ++#ifdef THREADS ++ if (threads > 1) { ++ pthread_mutex_lock(&number_bucket_mutex); + } -+ head = &(b->next); -+ } -+ if ((b = *head)) { - goto collision; - } ++#endif /* THREADS */ + while ((b = *head)) { + collision: + if (cvs_number_equal(&b->number, &n)) { ++#ifdef THREADS ++ if (threads > 1) { ++ pthread_mutex_unlock(&number_bucket_mutex); ++ } ++#endif /* THREADS */ + return &b->number; + } + head = &(b->next); + } +-#ifdef THREADS +- if (threads > 1) { +- pthread_mutex_lock(&number_bucket_mutex); +- } +-#endif /* THREADS */ + if ((b = *head)) { +-#ifdef THREADS +- if (threads > 1) { +- pthread_mutex_unlock(&number_bucket_mutex); +- } +-#endif /* THREADS */ + goto collision; + } ---- cvs-fast-export-1.62/revcvs.c.orig 2023-05-13 19:35:07.000000000 +0200 -+++ cvs-fast-export-1.62/revcvs.c 2023-12-10 21:41:28.540502302 +0100 +--- cvs-fast-export-1.66/revcvs.c.orig 2024-04-07 15:44:05.731477463 +0200 ++++ cvs-fast-export-1.66/revcvs.c 2024-04-07 15:56:06.944236984 +0200 @@ -22,6 +22,9 @@ #endif @@ -70,51 +80,58 @@ +static pthread_mutex_t root_dir_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif - static const char * - fileop_name(const char *rectified) -@@ -86,21 +89,22 @@ atom_dir(const char* dirname) - dir_bucket **head = &dir_buckets[HASH_VALUE(dirname) % DIR_BUCKETS]; - dir_bucket *b; + static const char *fileop_name(const char *rectified) { + size_t rlen = strlen(rectified); +@@ -79,24 +82,24 @@ static const master_dir *atom_dir(const + dir_bucket **head = &dir_buckets[HASH_VALUE(dirname) % DIR_BUCKETS]; + dir_bucket *b; -- while ((b = *head)) { -- collision: -- if (b->dir.name == dirname) -- return &(b->dir); -- head = &(b->next); -- } - #ifdef THREADS - if (threads > 1) - pthread_mutex_lock(&dir_bucket_mutex); - #endif /* THREADS */ -- if ((b = *head)) { -+ while ((b = *head)) { -+ collision: -+ if (b->dir.name == dirname) { - #ifdef THREADS - if (threads > 1) - pthread_mutex_unlock(&dir_bucket_mutex); - #endif /* THREADS */ -+ return &(b->dir); ++#ifdef THREADS ++ if (threads > 1) { ++ pthread_mutex_lock(&dir_bucket_mutex); + } -+ head = &(b->next); -+ } -+ if ((b = *head)) { - goto collision; - } - b = xmalloc(sizeof(dir_bucket), __func__); -@@ -800,7 +803,15 @@ cvs_master_digest(cvs_file *cvs, cvs_mas - cvs_branch *cb; - cvs_version *ctrunk = NULL; ++#endif /* THREADS */ + while ((b = *head)) { + collision: + if (b->dir.name == dirname) { ++#ifdef THREADS ++ if (threads > 1) { ++ pthread_mutex_unlock(&dir_bucket_mutex); ++ } ++#endif /* THREADS */ + return &(b->dir); + } + head = &(b->next); + } +-#ifdef THREADS +- if (threads > 1) { +- pthread_mutex_lock(&dir_bucket_mutex); +- } +-#endif /* THREADS */ + if ((b = *head)) { +-#ifdef THREADS +- if (threads > 1) { +- pthread_mutex_unlock(&dir_bucket_mutex); +- } +-#endif /* THREADS */ + goto collision; + } + b = xmalloc(sizeof(dir_bucket), __func__); +@@ -859,9 +862,17 @@ cvs_commit *cvs_master_digest(cvs_file * + cvs_branch *cb; + cvs_version *ctrunk = NULL; +#ifdef THREADS + if (threads > 1) + pthread_mutex_lock(&root_dir_mutex); +#endif - if (!root_dir) root_dir = atom_dir(atom("\0")); + if (!root_dir) { + root_dir = atom_dir(atom("\0")); + } +#ifdef THREADS + if (threads > 1) + pthread_mutex_unlock(&root_dir_mutex); +#endif - build_rev_master(cvs, master); + build_rev_master(cvs, master); #if CVSDEBUG - char buf[CVS_MAX_REV_LEN]; + char buf[CVS_MAX_REV_LEN]; diff --git a/cvs-fast-export-ubsan.patch b/cvs-fast-export-ubsan.patch index ab61831..e2dd37a 100644 --- a/cvs-fast-export-ubsan.patch +++ b/cvs-fast-export-ubsan.patch @@ -1,39 +1,39 @@ ---- cvs-fast-export-1.62/treepack.c.orig 2019-04-26 16:03:34.000000000 +0200 -+++ cvs-fast-export-1.62/treepack.c 2023-12-11 20:26:03.515346763 +0100 -@@ -215,6 +215,7 @@ revdir_pack_init(void) - frame = frames; - nfiles = 0; - frames[0].dir = root_dir; -+ frames[0].dirs = xmalloc(0, __func__); - frames[0].ndirs = 0; - frames[0].hash = hash_init(); +--- cvs-fast-export-1.66/treepack.c.orig 2024-04-07 16:00:03.669621200 +0200 ++++ cvs-fast-export-1.66/treepack.c 2024-04-07 16:01:11.059256119 +0200 +@@ -210,6 +210,7 @@ void revdir_pack_init(void) { + frame = frames; + nfiles = 0; + frames[0].dir = root_dir; ++ frames[0].dirs = xmalloc(0, __func__); + frames[0].ndirs = 0; + frames[0].hash = hash_init(); } -@@ -257,6 +257,7 @@ revdir_pack_add(const cvs_commit *file, - - const master_dir *parent = frame++->dir; - frame->dir = first_subdir(dir, parent); -+ frame->dirs = xmalloc(0, __func__); - frame->ndirs = 0; - frame->hash = hash_init(); - continue; ---- cvs-fast-export-1.62/generate.c.orig 2023-12-16 09:25:49.122347160 +0100 -+++ cvs-fast-export-1.62/generate.c 2023-12-16 09:25:51.565694258 +0100 -@@ -1058,7 +1058,7 @@ static node_t *generate_setup(generator_ - eb->Gfilename = gen->master_name; - eb->Gexpand = gen->expand; - eb->Gabspath = NULL; -- Gline(eb) = NULL; Ggap(eb) = Ggapsize(eb) = Glinemax(eb) = 0; -+ Gline(eb) = xmalloc(0, __func__); Ggap(eb) = Ggapsize(eb) = Glinemax(eb) = 0; - } +@@ -253,6 +254,7 @@ void revdir_pack_add(const cvs_commit *f - return gen->nodehash.head_node; ---- cvs-fast-export-1.62/import.c.orig 2023-08-28 19:20:50.000000000 +0200 -+++ cvs-fast-export-1.62/import.c 2023-12-16 19:32:48.695246837 +0100 -@@ -322,6 +322,7 @@ void analyze_masters(int argc, const cha - striplen = analyzer->striplen; + const master_dir *parent = frame++->dir; + frame->dir = first_subdir(dir, parent); ++ frame->dirs = xmalloc(0, __func__); + frame->ndirs = 0; + frame->hash = hash_init(); + continue; +--- cvs-fast-export-1.66/generate.c.orig 2024-04-07 16:00:03.669621200 +0200 ++++ cvs-fast-export-1.66/generate.c 2024-04-07 16:02:04.075635571 +0200 +@@ -1158,7 +1158,7 @@ static node_t *generate_setup(generator_ + eb->Gfilename = gen->master_name; + eb->Gexpand = gen->expand; + eb->Gabspath = NULL; +- Gline(eb) = NULL; ++ Gline(eb) = xmalloc(0, __func__); + Ggap(eb) = Ggapsize(eb) = Glinemax(eb) = 0; + } - forest->textsize = forest->filecount = 0; -+ forest->cvsroot = false; - progress_begin("Reading file list...", NO_MAX); - for (;;) - { +--- cvs-fast-export-1.66/import.c.orig 2024-04-07 16:00:03.669621200 +0200 ++++ cvs-fast-export-1.66/import.c 2024-04-07 16:02:53.108703269 +0200 +@@ -347,6 +347,7 @@ void analyze_masters(int argc, const cha + striplen = analyzer->striplen; + + forest->textsize = forest->filecount = 0; ++ forest->is_cvs = false; + progress_begin("Reading file list...", NO_MAX); + for (;;) { + struct stat stb; diff --git a/cvs-fast-export.spec b/cvs-fast-export.spec index c49c67c..2649aab 100644 --- a/cvs-fast-export.spec +++ b/cvs-fast-export.spec @@ -5,12 +5,12 @@ Summary: Tool to export CVS history into a fast-import stream Summary(pl.UTF-8): Narzędzie eksportujące historię CVS w postaci strumienia fast-import Name: cvs-fast-export -Version: 1.62 +Version: 1.66 Release: 1 License: GPL v2 Group: Development/Version Control Source0: http://www.catb.org/~esr/cvs-fast-export/%{name}-%{version}.tar.gz -# Source0-md5: 8ed2dac4c7c1763d8351650d0bb2630c +# Source0-md5: b619c3dc9c72cc1b14f8b4fefdcb4f32 Patch0: hack-disable-cvsignore.patch Patch1: %{name}-tsan.patch Patch2: %{name}-asan.patch diff --git a/hack-disable-cvsignore.patch b/hack-disable-cvsignore.patch index 7d0db43..68cabe8 100644 --- a/hack-disable-cvsignore.patch +++ b/hack-disable-cvsignore.patch @@ -3,16 +3,16 @@ allow disabling .gitignore generation via env Upstream: https://gitlab.com/esr/cvs-fast-export/issues/13 ---- cvs-fast-export-1.62/export.c.orig 2023-12-10 13:22:44.800987007 +0100 -+++ cvs-fast-export-1.62/export.c 2023-12-10 13:24:03.297228423 +0100 -@@ -570,8 +570,10 @@ export_commit(git_commit *commit, const - } - if (need_ignores) { - need_ignores = false; -+ if (!getenv("DISABLE_GITIGNORE")) { - printf("M 100644 inline .gitignore\ndata %d\n%s\n", - (int)sizeof(CVS_IGNORES)-1, CVS_IGNORES); -+ } - } - if (revpairs != NULL && strlen(revpairs) > 0) - { +--- cvs-fast-export-1.66/export.c.orig 2024-04-07 15:42:44.128586210 +0200 ++++ cvs-fast-export-1.66/export.c 2024-04-07 15:43:38.798290039 +0200 +@@ -581,8 +581,10 @@ static void export_commit(git_commit *co + } + if (need_ignores) { + need_ignores = false; ++ if (!getenv("DISABLE_GITIGNORE")) { + printf("M 100644 inline .gitignore\ndata %d\n%s\n", + (int)sizeof(CVS_IGNORES) - 1, CVS_IGNORES); ++ } + } + if (revpairs != NULL && strlen(revpairs) > 0) { + if (opts->revision_map) { -- 2.43.0