vcs-svn: Eliminate node_ctx.mark global
The mark variable is only used in handle_node(). Its life is very short and simple: first, a new mark number is allocated if this node has text attached, then that mark is recorded in the in-core tree being built up, and lastly the mark is communicated to fast-import in the stream along with the associated text. A new reader may worry about interaction with other code, especially since mark is not initialized to zero in handle_node() itself. Disperse such worries by making it local. No functional change intended. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
Nov 19, 2010 at 18:46 UTC
da3e217447390d52363989474a5e33bd298ff3ad
1 file changed
+11
-12
vcs-svn/svndump.c
+11
-12
@@ -40,7 +40,7 @@ static char* log_copy(uint32_t length, char *log)
40
}
41
42
static struct {
43
- uint32_t action, propLength, textLength, srcRev, mark, type;
43
+ uint32_t action, propLength, textLength, srcRev, type;
44
uint32_t src[REPO_MAX_PATH_DEPTH], dst[REPO_MAX_PATH_DEPTH];
45
uint32_t text_delta, prop_delta;
46
} node_ctx;
@@ -73,7 +73,6 @@ static void reset_node_ctx(char *fname)
73
node_ctx.src[0] = ~0;
74
node_ctx.srcRev = 0;
75
pool_tok_seq(REPO_MAX_PATH_DEPTH, node_ctx.dst, "/", fname);
76
- node_ctx.mark = 0;
76
node_ctx.text_delta = 0;
77
node_ctx.prop_delta = 0;
78
}
@@ -151,7 +150,7 @@ static void read_props(void)
150
151
static void handle_node(void)
152
{
154
- uint32_t old_mode = 0;
153
+ uint32_t old_mode = 0, mark = 0;
154
155
if (node_ctx.text_delta || node_ctx.prop_delta)
156
die("text and property deltas not supported");
@@ -164,7 +163,7 @@ static void handle_node(void)
163
164
if (node_ctx.textLength != LENGTH_UNKNOWN &&
165
node_ctx.type != REPO_MODE_DIR)
167
- node_ctx.mark = next_blob_mark();
166
+ mark = next_blob_mark();
167
168
if (node_ctx.action == NODEACT_DELETE) {
169
repo_delete(node_ctx.dst);
@@ -172,26 +171,26 @@ static void handle_node(void)
171
node_ctx.action == NODEACT_REPLACE) {
172
if (node_ctx.action == NODEACT_REPLACE &&
173
node_ctx.type == REPO_MODE_DIR)
175
- repo_replace(node_ctx.dst, node_ctx.mark);
174
+ repo_replace(node_ctx.dst, mark);
175
else if (node_ctx.propLength != LENGTH_UNKNOWN)
177
- repo_modify(node_ctx.dst, node_ctx.type, node_ctx.mark);
176
+ repo_modify(node_ctx.dst, node_ctx.type, mark);
177
else if (node_ctx.textLength != LENGTH_UNKNOWN)
179
- old_mode = repo_replace(node_ctx.dst, node_ctx.mark);
178
+ old_mode = repo_replace(node_ctx.dst, mark);
179
} else if (node_ctx.action == NODEACT_ADD) {
180
if (node_ctx.srcRev && node_ctx.propLength != LENGTH_UNKNOWN)
182
- repo_modify(node_ctx.dst, node_ctx.type, node_ctx.mark);
181
+ repo_modify(node_ctx.dst, node_ctx.type, mark);
182
else if (node_ctx.srcRev && node_ctx.textLength != LENGTH_UNKNOWN)
184
- old_mode = repo_replace(node_ctx.dst, node_ctx.mark);
183
+ old_mode = repo_replace(node_ctx.dst, mark);
184
else if ((node_ctx.type == REPO_MODE_DIR && !node_ctx.srcRev) ||
185
node_ctx.textLength != LENGTH_UNKNOWN)
187
- repo_add(node_ctx.dst, node_ctx.type, node_ctx.mark);
186
+ repo_add(node_ctx.dst, node_ctx.type, mark);
187
}
188
189
if (node_ctx.propLength == LENGTH_UNKNOWN && old_mode)
190
node_ctx.type = old_mode;
191
193
- if (node_ctx.mark)
194
- fast_export_blob(node_ctx.type, node_ctx.mark, node_ctx.textLength);
192
+ if (mark)
193
+ fast_export_blob(node_ctx.type, mark, node_ctx.textLength);
194
else if (node_ctx.textLength != LENGTH_UNKNOWN)
195
buffer_skip_bytes(node_ctx.textLength);
196
}