Skip to content

Commit 21c7c2d

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4022279 commit 21c7c2d

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

vcs-svn/fast_export.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static long apply_delta(off_t len, struct line_buffer *input,
210210
die("invalid cat-blob response: %s", response);
211211
check_preimage_overflow(preimage.max_off, 1);
212212
}
213-
if (old_mode == REPO_MODE_LNK) {
213+
if (old_mode == S_IFLNK) {
214214
strbuf_addstr(&preimage.buf, "link ");
215215
check_preimage_overflow(preimage.max_off, strlen("link "));
216216
preimage.max_off += strlen("link ");
@@ -244,7 +244,7 @@ void fast_export_buf_to_data(const struct strbuf *data)
244244
void fast_export_data(uint32_t mode, off_t len, struct line_buffer *input)
245245
{
246246
assert(len >= 0);
247-
if (mode == REPO_MODE_LNK) {
247+
if (mode == S_IFLNK) {
248248
/* svn symlink blobs start with "link " */
249249
if (len < 5)
250250
die("invalid dump: symlink too short for \"link\" prefix");
@@ -320,7 +320,7 @@ void fast_export_blob_delta(uint32_t mode,
320320

321321
assert(len >= 0);
322322
postimage_len = apply_delta(len, input, old_data, old_mode);
323-
if (mode == REPO_MODE_LNK) {
323+
if (mode == S_IFLNK) {
324324
buffer_skip_bytes(&postimage, strlen("link "));
325325
postimage_len -= strlen("link ");
326326
}

vcs-svn/repo_tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const char *svn_repo_read_path(const char *path, uint32_t *mode_out)
1919
if (errno != ENOENT)
2020
die_errno("BUG: unexpected fast_export_ls error");
2121
/* Treat missing paths as directories. */
22-
*mode_out = REPO_MODE_DIR;
22+
*mode_out = S_IFDIR;
2323
return NULL;
2424
}
2525
return buf.buf;

vcs-svn/repo_tree.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
#ifndef REPO_TREE_H_
22
#define REPO_TREE_H_
33

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-
94
void svn_repo_copy(uint32_t revision, const char *src, const char *dst);
105
const char *svn_repo_read_path(const char *path, uint32_t *mode_out);
116
void svn_repo_delete(const char *path);

vcs-svn/svndump.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ static void handle_property(const struct strbuf *key_buf,
134134
die("invalid dump: sets type twice");
135135
}
136136
if (!val) {
137-
node_ctx.type = REPO_MODE_BLB;
137+
node_ctx.type = S_IFREG | 0644;
138138
return;
139139
}
140140
*type_set = 1;
141141
node_ctx.type = keylen == strlen("svn:executable") ?
142-
REPO_MODE_EXE :
143-
REPO_MODE_LNK;
142+
(S_IFREG | 0755) :
143+
S_IFLNK;
144144
}
145145
}
146146

@@ -219,7 +219,7 @@ static void handle_node(void)
219219
*/
220220
static const char *const empty_blob = "::empty::";
221221
const char *old_data = NULL;
222-
uint32_t old_mode = REPO_MODE_BLB;
222+
uint32_t old_mode = S_IFREG | 0644;
223223

224224
if (node_ctx.action == NODEACT_DELETE) {
225225
if (have_text || have_props || node_ctx.srcRev)
@@ -237,27 +237,27 @@ static void handle_node(void)
237237
if (node_ctx.action == NODEACT_ADD)
238238
node_ctx.action = NODEACT_CHANGE;
239239
}
240-
if (have_text && type == REPO_MODE_DIR)
240+
if (have_text && type == S_IFDIR)
241241
die("invalid dump: directories cannot have text attached");
242242

243243
/*
244244
* Find old content (old_data) and decide on the new mode.
245245
*/
246246
if (node_ctx.action == NODEACT_CHANGE && !*node_ctx.dst.buf) {
247-
if (type != REPO_MODE_DIR)
247+
if (type != S_IFDIR)
248248
die("invalid dump: root of tree is not a regular file");
249249
old_data = NULL;
250250
} else if (node_ctx.action == NODEACT_CHANGE) {
251251
uint32_t mode;
252252
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)
254254
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)
256256
die("invalid dump: cannot modify a file into a directory");
257257
node_ctx.type = mode;
258258
old_mode = mode;
259259
} else if (node_ctx.action == NODEACT_ADD) {
260-
if (type == REPO_MODE_DIR)
260+
if (type == S_IFDIR)
261261
old_data = NULL;
262262
else if (have_text)
263263
old_data = empty_blob;
@@ -280,7 +280,7 @@ static void handle_node(void)
280280
/*
281281
* Save the result.
282282
*/
283-
if (type == REPO_MODE_DIR) /* directories are not tracked. */
283+
if (type == S_IFDIR) /* directories are not tracked. */
284284
return;
285285
assert(old_data);
286286
if (old_data == empty_blob)
@@ -385,9 +385,9 @@ void svndump_read(const char *url, const char *local_ref, const char *notes_ref)
385385
continue;
386386
strbuf_addf(&rev_ctx.note, "%s\n", t);
387387
if (!strcmp(val, "dir"))
388-
node_ctx.type = REPO_MODE_DIR;
388+
node_ctx.type = S_IFDIR;
389389
else if (!strcmp(val, "file"))
390-
node_ctx.type = REPO_MODE_BLB;
390+
node_ctx.type = S_IFREG | 0644;
391391
else
392392
fprintf(stderr, "Unknown node-kind: %s\n", val);
393393
break;

0 commit comments

Comments
 (0)