Skip to content

Commit 2a48afe

Browse files
jrngitster
authored andcommitted
vcs-svn: Split off function for handling of individual properties
The handle_property function is the part of read_props that would be interesting for most people: semantics of properties rather than the algorithm for parsing them. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3f3e676 commit 2a48afe

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

vcs-svn/svndump.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
/* Create memory pool for log messages */
3131
obj_pool_gen(log, char, 4096)
3232

33-
static char* log_copy(uint32_t length, char *log)
33+
static char *log_copy(uint32_t length, const char *log)
3434
{
3535
char *buffer;
3636
log_free(log_pool.size);
@@ -115,6 +115,23 @@ static void init_keys(void)
115115
keys.prop_delta = pool_intern("Prop-delta");
116116
}
117117

118+
static void handle_property(uint32_t key, const char *val, uint32_t len)
119+
{
120+
if (key == keys.svn_log) {
121+
/* Value length excludes terminating nul. */
122+
rev_ctx.log = log_copy(len + 1, val);
123+
} else if (key == keys.svn_author) {
124+
rev_ctx.author = pool_intern(val);
125+
} else if (key == keys.svn_date) {
126+
if (parse_date_basic(val, &rev_ctx.timestamp, NULL))
127+
fprintf(stderr, "Invalid timestamp: %s\n", val);
128+
} else if (key == keys.svn_executable) {
129+
node_ctx.type = REPO_MODE_EXE;
130+
} else if (key == keys.svn_special) {
131+
node_ctx.type = REPO_MODE_LNK;
132+
}
133+
}
134+
118135
static void read_props(void)
119136
{
120137
uint32_t len;
@@ -129,19 +146,7 @@ static void read_props(void)
129146
} else if (!strncmp(t, "V ", 2)) {
130147
len = atoi(&t[2]);
131148
val = buffer_read_string(len);
132-
if (key == keys.svn_log) {
133-
/* Value length excludes terminating nul. */
134-
rev_ctx.log = log_copy(len + 1, val);
135-
} else if (key == keys.svn_author) {
136-
rev_ctx.author = pool_intern(val);
137-
} else if (key == keys.svn_date) {
138-
if (parse_date_basic(val, &rev_ctx.timestamp, NULL))
139-
fprintf(stderr, "Invalid timestamp: %s\n", val);
140-
} else if (key == keys.svn_executable) {
141-
node_ctx.type = REPO_MODE_EXE;
142-
} else if (key == keys.svn_special) {
143-
node_ctx.type = REPO_MODE_LNK;
144-
}
149+
handle_property(key, val, len);
145150
key = ~0;
146151
buffer_read_line();
147152
}

0 commit comments

Comments
 (0)