From: Dmitry Ivankov <divanorama@gmail.com>
To: git@vger.kernel.org
Cc: Jonathan Nieder <jrnieder@gmail.com>,
David Barr <davidbarr@google.com>,
Ramkumar Ramachandra <artagnon@gmail.com>,
Dmitry Ivankov <divanorama@gmail.com>
Subject: [PATCH v2 05/11] vcs-svn: move url parameter from _read to _init
Date: Wed, 13 Jul 2011 18:21:07 +0600 [thread overview]
Message-ID: <1310559673-5026-6-git-send-email-divanorama@gmail.com> (raw)
In-Reply-To: <1310559673-5026-1-git-send-email-divanorama@gmail.com>
svndump_read takes a url parameter that is used in git-svn-id: lines
generation. Internally it is stored in dump_ctx which is initialized
in svndump_init with reset_dump_ctx and then is reinitialized again
in svndump_read.
Move url parameter to svndump_init so that reset_dump_ctx is done
once per dump and in the same place as other resets. Wrap all _init
parameters to a struct svndump_args. More parameters will arise and
all will go to this struct to setup the module for dumping. Having
a struct reduces a chance to confuse one parameter with another a
bit, if they are filled via named assignments or common defines.
Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
---
contrib/svn-fe/svn-fe.c | 12 ++++++------
test-svn-fe.c | 7 +++++--
vcs-svn/svndump.c | 12 ++++++------
vcs-svn/svndump.h | 8 ++++++--
4 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/contrib/svn-fe/svn-fe.c b/contrib/svn-fe/svn-fe.c
index 7e829b9..59141d6 100644
--- a/contrib/svn-fe/svn-fe.c
+++ b/contrib/svn-fe/svn-fe.c
@@ -12,10 +12,10 @@ static const char * const svn_fe_usage[] = {
NULL
};
-static const char *url;
+static struct svndump_args args;
static struct option svn_fe_options[] = {
- OPT_STRING(0, "git-svn-id-url", &url, "url",
+ OPT_STRING(0, "git-svn-id-url", &args.url, "url",
"append git-svn metadata line to commit messages"),
OPT_END()
};
@@ -25,16 +25,16 @@ int main(int argc, const char **argv)
argc = parse_options(argc, argv, NULL, svn_fe_options,
svn_fe_usage, 0);
if (argc == 1) {
- if (url)
+ if (args.url)
usage_msg_opt("git-svn-id-url is set twice: as a "
"--parameter and as a [parameter]",
svn_fe_usage, svn_fe_options);
- url = argv[0];
+ args.url = argv[0];
} else if (argc)
usage_with_options(svn_fe_usage, svn_fe_options);
- if (svndump_init(NULL))
+ if (svndump_init(&args))
return 1;
- svndump_read(url);
+ svndump_read();
svndump_deinit();
svndump_reset();
return 0;
diff --git a/test-svn-fe.c b/test-svn-fe.c
index 0aab245..9e5b1a6 100644
--- a/test-svn-fe.c
+++ b/test-svn-fe.c
@@ -14,6 +14,8 @@ static const char * const test_svnfe_usage[] = {
NULL
};
+static struct svndump_args args;
+
static int d;
static struct option test_svnfe_options[] = {
@@ -56,9 +58,10 @@ int main(int argc, const char *argv[])
return apply_delta(argc, argv);
if (argc == 1) {
- if (svndump_init(argv[0]))
+ args.filename = argv[0];
+ if (svndump_init(&args))
return 1;
- svndump_read(NULL);
+ svndump_read();
svndump_deinit();
svndump_reset();
return 0;
diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c
index b1f4161..60cccad 100644
--- a/vcs-svn/svndump.c
+++ b/vcs-svn/svndump.c
@@ -12,6 +12,7 @@
#include "fast_export.h"
#include "line_buffer.h"
#include "strbuf.h"
+#include "svndump.h"
/*
* Compare start of string to literal of equal length;
@@ -313,14 +314,13 @@ static void end_revision(void)
fast_export_end_commit(rev_ctx.revision);
}
-void svndump_read(const char *url)
+void svndump_read(void)
{
char *val;
char *t;
uint32_t active_ctx = DUMP_CTX;
uint32_t len;
- reset_dump_ctx(url);
while ((t = buffer_read_line(&input))) {
val = strchr(t, ':');
if (!val)
@@ -455,10 +455,10 @@ void svndump_read(const char *url)
end_revision();
}
-int svndump_init(const char *filename)
+int svndump_init(const struct svndump_args *args)
{
- if (buffer_init(&input, filename))
- return error("cannot open %s: %s", filename, strerror(errno));
+ if (buffer_init(&input, args->filename))
+ return error("cannot open %s: %s", args->filename, strerror(errno));
fast_export_init(REPORT_FILENO);
strbuf_init(&dump_ctx.uuid, 4096);
strbuf_init(&dump_ctx.url, 4096);
@@ -466,7 +466,7 @@ int svndump_init(const char *filename)
strbuf_init(&rev_ctx.author, 4096);
strbuf_init(&node_ctx.src, 4096);
strbuf_init(&node_ctx.dst, 4096);
- reset_dump_ctx(NULL);
+ reset_dump_ctx(args->url);
reset_rev_ctx(0);
reset_node_ctx(NULL);
return 0;
diff --git a/vcs-svn/svndump.h b/vcs-svn/svndump.h
index df9ceb0..b3dbf24 100644
--- a/vcs-svn/svndump.h
+++ b/vcs-svn/svndump.h
@@ -1,8 +1,12 @@
#ifndef SVNDUMP_H_
#define SVNDUMP_H_
-int svndump_init(const char *filename);
-void svndump_read(const char *url);
+struct svndump_args {
+ const char *filename, *url;
+};
+
+int svndump_init(const struct svndump_args *args);
+void svndump_read(void);
void svndump_deinit(void);
void svndump_reset(void);
--
1.7.3.4
next prev parent reply other threads:[~2011-07-13 12:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-13 12:21 [PATCH v2 00/11] vcs-svn,svn-fe add a couple of options Dmitry Ivankov
2011-07-13 12:21 ` [PATCH v2 01/11] svn-fe: add man target to Makefile Dmitry Ivankov
2011-07-24 12:52 ` Jonathan Nieder
2011-07-13 12:21 ` [PATCH v2 02/11] test-svn-fe: use parse-options Dmitry Ivankov
2011-07-24 13:04 ` Jonathan Nieder
2011-07-13 12:21 ` [PATCH v2 03/11] svn-fe: add EXTLIBS needed for parse-options Dmitry Ivankov
2011-07-24 13:14 ` Jonathan Nieder
2011-07-13 12:21 ` [PATCH v2 04/11] svn-fe: add usage and unpositional arguments versions Dmitry Ivankov
2011-07-24 13:25 ` Jonathan Nieder
2011-07-13 12:21 ` Dmitry Ivankov [this message]
2011-07-24 13:40 ` [PATCH v2 05/11] vcs-svn: move url parameter from _read to _init Jonathan Nieder
2011-07-13 12:21 ` [PATCH v2 06/11] vcs-svn: move commit parameters logic to svndump.c Dmitry Ivankov
2011-07-24 13:58 ` Jonathan Nieder
2011-07-13 12:21 ` [PATCH v2 07/11] vcs-svn,svn-fe: allow to specify dump destination ref Dmitry Ivankov
2011-07-25 8:57 ` Jonathan Nieder
2011-07-13 12:21 ` [PATCH v2 08/11] vcs-svn,svn-fe: convert REPORT_FILENO to an option Dmitry Ivankov
2011-07-25 21:26 ` Jonathan Nieder
2011-07-13 12:21 ` [PATCH v2 09/11] vcs-svn,svn-fe: allow to disable 'progress' lines Dmitry Ivankov
2011-07-13 12:21 ` [PATCH v2 10/11] vcs-svn,svn-fe: add --incremental option Dmitry Ivankov
2011-07-25 21:35 ` Jonathan Nieder
2011-07-13 12:21 ` [PATCH v2 11/11] vcs-svn,svn-fe: add an option to write svnrev notes Dmitry Ivankov
2011-07-25 21:39 ` Jonathan Nieder
2011-07-28 6:03 ` Dmitry Ivankov
2011-07-28 10:27 ` Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1310559673-5026-6-git-send-email-divanorama@gmail.com \
--to=divanorama@gmail.com \
--cc=artagnon@gmail.com \
--cc=davidbarr@google.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).