{"thread":{"id":"715","subject":"[PATCH] Make cvs2git support remote CVS repos","startedAt":"2005-05-25T18:11:32Z","lastAt":"2005-05-26T02:42:06Z","messageCount":2,"participants":["Mark Allen","Linus Torvalds"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"3938","messageId":"20050525181132.75705.qmail@web41204.mail.yahoo.com","threadId":"715","inReplyTo":null,"subject":"[PATCH] Make cvs2git support remote CVS repos","fromName":"Mark Allen","fromEmail":"mrallen1@yahoo.com","sentAt":"2005-05-25T18:11:32Z","receivedAt":"2005-05-25T18:11:32Z","isPatch":true,"sender":{"key":"mrallen1@yahoo.com","avatar":null},"body":"Added a \"--module=cvsmodule\" command line option and (since we're going to process argv\nanyway) made \"-v\" for verbose mode a command line option too, instead of a compile time\noption.\n\nI've tested it on some (small) private CVS repos and it *seems* to work, although some of\nthe initial commit ordering is wrong, but I think this is due to the commit time being\nwrong within my CVS repo itself.\n\nI didn't make author and email prettyprint, but I really want to make it a command line\noption, the discussion from yesterday about whether prettyprinting should be at the\nplumbing or porcelain layer notwithstanding.\n\nRegards,\n\n--Mark\n\nIndex: cvs2git.c\n===================================================================\n--- a0e0d3940c350f14545a481b179217f626c93440/cvs2git.c  (mode:100644)\n+++ uncommitted/cvs2git.c  (mode:100644)\n@@ -32,6 +32,8 @@\n };\n \n static char *rcsdir;\n+static char *cvsroot;\n+static char *cvsmodule;\n \n static char date[100];\n static char author[100];\n@@ -194,9 +196,13 @@\n \tif (dir)\n \t\tprintf(\"mkdir -p %.*s\\n\", (int)(dir - name), name);\n \n-\tget_rcs_name(rcspathname, name, dir);\n-\t\t\n-\tprintf(\"co -q -p -r%s '%s' > '%s'\\n\", version, rcspathname, name);\n+\tif ( !cvsmodule ) {\n+\t\tget_rcs_name(rcspathname, name, dir);\n+\t\tprintf(\"co -q -p -r%s '%s' > '%s'\\n\", version, rcspathname, name);\n+\t} else {\n+\t\tprintf(\"cvs -d %s checkout -r%s -p '%s/%s' > '%s'\\n\", cvsroot, version, cvsmodule, name, name);\n+\t}\n+\n \tprintf(\"git-update-cache --add -- '%s'\\n\", name);\n }\n \n@@ -217,13 +223,34 @@\n {\n \tstatic char line[1000];\n \tenum state state = Header;\n+\tint i;\n+\n+\tfor (i = 1; i < argc; i++) {\n+\t\tconst char *arg = argv[i];\n+\t\tif (!memcmp(arg, \"--module=\", 9)) {\n+\t\t\tcvsroot = getenv(\"CVSROOT\");\n+\t\t\tcvsmodule = (char *)arg+9;\n+\t\t\tcontinue;\n+\t\t} \n+\t\tif (!strcmp(arg, \"-v\")) {\n+\t\t\tverbose = 1;\n+\t\t\tcontinue;\n+\t\t}\n+\t}\n+\n+\tif (!cvsmodule)\n+\t\trcsdir = getenv(\"RCSDIR\");\n \n-\trcsdir = getenv(\"RCSDIR\");\n-\tif (!rcsdir) {\n+\tif (!cvsmodule && !rcsdir) {\n \t\tfprintf(stderr, \"I need an $RCSDIR\\n\");\n \t\texit(1);\n \t}\n \n+\tif (cvsmodule && !cvsroot) {\n+\t\tfprintf(stderr, \"I need a $CVSROOT\\n\");\n+\t\texit(1);\n+\t}\n+\n \tprintf(\"[ -d .git ] && exit 1\\n\");\n \tprintf(\"git-init-db\\n\");\n \tprintf(\"mkdir -p .git/refs/heads\\n\");\n"},{"id":"3965","messageId":"Pine.LNX.4.58.0505251938580.2307@ppc970.osdl.org","threadId":"715","inReplyTo":"20050525181132.75705.qmail@web41204.mail.yahoo.com","subject":"Re: [PATCH] Make cvs2git support remote CVS repos","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-05-26T02:42:06Z","receivedAt":"2005-05-26T02:42:06Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 25 May 2005, Mark Allen wrote:\n>\n> Added a \"--module=cvsmodule\" command line option and (since we're going to process argv\n> anyway) made \"-v\" for verbose mode a command line option too, instead of a compile time\n> option.\n\nAhh.. You found out how to get CVS to check out individual files. \n\nThe reason I use RCS \"co\" directly is because I couldn't figure out how\nCVS can be made to do it. Of course, the raw RCS possibly also performs\nbetter, but somebody should check that. If the overhead of using CVS to do\nthis is low enough, we should drop the raw RCS access, which should\nsimplify your patch and get rid of the need for \"RCSDIR\".\n\nAnybody up for some performance testing?\n\n\t\t\tLinus\n"}]}