vcs-svn: remove custom mode constants

In the rest of Git, these modes are spelled as S_IFDIR, S_IFREG | 0644, S_IFREG | 0755, and S_IFLNK. Use the same constants in svn-fe for simplicity and consistency. No functional change intended. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Aug 22, 2017 at 17:01 UTC 21c7c2d92d4b107ca854d84d4cd4d86c7993089c
4 files changed +16 -21
vcs-svn/fast_export.c
+3 -3
@@ -210,7 +210,7 @@ static long apply_delta(off_t len, struct line_buffer *input,
210 die("invalid cat-blob response: %s", response);
211 check_preimage_overflow(preimage.max_off, 1);
212 }
213 - if (old_mode == REPO_MODE_LNK) {
213 + if (old_mode == S_IFLNK) {
214 strbuf_addstr(&preimage.buf, "link ");
215 check_preimage_overflow(preimage.max_off, strlen("link "));
216 preimage.max_off += strlen("link ");
@@ -244,7 +244,7 @@ void fast_export_buf_to_data(const struct strbuf *data)
244 void fast_export_data(uint32_t mode, off_t len, struct line_buffer *input)
245 {
246 assert(len >= 0);
247 - if (mode == REPO_MODE_LNK) {
247 + if (mode == S_IFLNK) {
248 /* svn symlink blobs start with "link " */
249 if (len < 5)
250 die("invalid dump: symlink too short for \"link\" prefix");
@@ -320,7 +320,7 @@ void fast_export_blob_delta(uint32_t mode,
320
321 assert(len >= 0);
322 postimage_len = apply_delta(len, input, old_data, old_mode);
323 - if (mode == REPO_MODE_LNK) {
323 + if (mode == S_IFLNK) {
324 buffer_skip_bytes(&postimage, strlen("link "));
325 postimage_len -= strlen("link ");
326 }
vcs-svn/repo_tree.c
+1 -1
@@ -19,7 +19,7 @@ const char *svn_repo_read_path(const char *path, uint32_t *mode_out)
19 if (errno != ENOENT)
20 die_errno("BUG: unexpected fast_export_ls error");
21 /* Treat missing paths as directories. */
22 - *mode_out = REPO_MODE_DIR;
22 + *mode_out = S_IFDIR;
23 return NULL;
24 }
25 return buf.buf;
vcs-svn/repo_tree.h
-5
@@ -1,11 +1,6 @@
1 #ifndef REPO_TREE_H_
2 #define REPO_TREE_H_
3
4 -#define REPO_MODE_DIR 0040000
5 -#define REPO_MODE_BLB 0100644
6 -#define REPO_MODE_EXE 0100755
7 -#define REPO_MODE_LNK 0120000
8 -
4 void svn_repo_copy(uint32_t revision, const char *src, const char *dst);
5 const char *svn_repo_read_path(const char *path, uint32_t *mode_out);
6 void svn_repo_delete(const char *path);
vcs-svn/svndump.c
+12 -12
@@ -134,13 +134,13 @@ static void handle_property(const struct strbuf *key_buf,
134 die("invalid dump: sets type twice");
135 }
136 if (!val) {
137 - node_ctx.type = REPO_MODE_BLB;
137 + node_ctx.type = S_IFREG | 0644;
138 return;
139 }
140 *type_set = 1;
141 node_ctx.type = keylen == strlen("svn:executable") ?
142 - REPO_MODE_EXE :
143 - REPO_MODE_LNK;
142 + (S_IFREG | 0755) :
143 + S_IFLNK;
144 }
145 }
146
@@ -219,7 +219,7 @@ static void handle_node(void)
219 */
220 static const char *const empty_blob = "::empty::";
221 const char *old_data = NULL;
222 - uint32_t old_mode = REPO_MODE_BLB;
222 + uint32_t old_mode = S_IFREG | 0644;
223
224 if (node_ctx.action == NODEACT_DELETE) {
225 if (have_text || have_props || node_ctx.srcRev)
@@ -237,27 +237,27 @@ static void handle_node(void)
237 if (node_ctx.action == NODEACT_ADD)
238 node_ctx.action = NODEACT_CHANGE;
239 }
240 - if (have_text && type == REPO_MODE_DIR)
240 + if (have_text && type == S_IFDIR)
241 die("invalid dump: directories cannot have text attached");
242
243 /*
244 * Find old content (old_data) and decide on the new mode.
245 */
246 if (node_ctx.action == NODEACT_CHANGE && !*node_ctx.dst.buf) {
247 - if (type != REPO_MODE_DIR)
247 + if (type != S_IFDIR)
248 die("invalid dump: root of tree is not a regular file");
249 old_data = NULL;
250 } else if (node_ctx.action == NODEACT_CHANGE) {
251 uint32_t mode;
252 old_data = svn_repo_read_path(node_ctx.dst.buf, &mode);
253 - if (mode == REPO_MODE_DIR && type != REPO_MODE_DIR)
253 + if (mode == S_IFDIR && type != S_IFDIR)
254 die("invalid dump: cannot modify a directory into a file");
255 - if (mode != REPO_MODE_DIR && type == REPO_MODE_DIR)
255 + if (mode != S_IFDIR && type == S_IFDIR)
256 die("invalid dump: cannot modify a file into a directory");
257 node_ctx.type = mode;
258 old_mode = mode;
259 } else if (node_ctx.action == NODEACT_ADD) {
260 - if (type == REPO_MODE_DIR)
260 + if (type == S_IFDIR)
261 old_data = NULL;
262 else if (have_text)
263 old_data = empty_blob;
@@ -280,7 +280,7 @@ static void handle_node(void)
280 /*
281 * Save the result.
282 */
283 - if (type == REPO_MODE_DIR) /* directories are not tracked. */
283 + if (type == S_IFDIR) /* directories are not tracked. */
284 return;
285 assert(old_data);
286 if (old_data == empty_blob)
@@ -385,9 +385,9 @@ void svndump_read(const char *url, const char *local_ref, const char *notes_ref)
385 continue;
386 strbuf_addf(&rev_ctx.note, "%s\n", t);
387 if (!strcmp(val, "dir"))
388 - node_ctx.type = REPO_MODE_DIR;
388 + node_ctx.type = S_IFDIR;
389 else if (!strcmp(val, "file"))
390 - node_ctx.type = REPO_MODE_BLB;
390 + node_ctx.type = S_IFREG | 0644;
391 else
392 fprintf(stderr, "Unknown node-kind: %s\n", val);
393 break;