Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Make "git-checkout" create files with O_EXCL
author
Linus Torvalds
<torvalds@g5.osdl.org>
Thu, 14 Jul 2005 00:27:48 +0000
(17:27 -0700)
committer
Linus Torvalds
<torvalds@g5.osdl.org>
Thu, 14 Jul 2005 00:27:48 +0000
(17:27 -0700)
We should always have unlinked any old ones before, but this just makes
sure that we never over-write any old file.
A quick "grep" now shows that all the core tools that open files for
writing use O_EXCL, ie we never overwrite an existing file in place.
entry.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (from parent 1:
1b66834
)
diff --git
a/entry.c
b/entry.c
index ded83103a9d8f16333d941e1e5410e0a12822ae7..792ea733e851a3d288cad1e34ea89478503e71be 100644
(file)
--- a/
entry.c
+++ b/
entry.c
@@
-62,11
+62,11
@@
static int create_file(const char *path, unsigned int mode, int force)
int fd;
mode = (mode & 0100) ? 0777 : 0666;
int fd;
mode = (mode & 0100) ? 0777 : 0666;
- fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode);
+ fd = open(path, O_WRONLY | O_TRUNC | O_CREAT
| O_EXCL
, mode);
if (fd < 0) {
if (errno == EISDIR && force) {
remove_subtree(path);
if (fd < 0) {
if (errno == EISDIR && force) {
remove_subtree(path);
- fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode);
+ fd = open(path, O_WRONLY | O_TRUNC | O_CREAT
| O_EXCL
, mode);
}
}
return fd;
}
}
return fd;