summaryrefslogtreecommitdiff
path: root/checkout-cache.c
diff options
context:
space:
mode:
authorLibravatar Linus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 22:26:31 -0700
committerLibravatar Linus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 22:26:31 -0700
commite44794706eeb57f2ee38ed1604821aa38b8ad9d2 (patch)
treec49cd3e4f1dfe4ccbf2b8d00188beaa251fee028 /checkout-cache.c
parent[PATCH] Do not run useless show-diff on unmerged paths repeatedly. (diff)
downloadtgif-e44794706eeb57f2ee38ed1604821aa38b8ad9d2.tar.xz
Be much more liberal about the file mode bits.
We only really care about the difference between a file being executable or not (by its owner). Everything else we leave for the user umask to decide.
Diffstat (limited to 'checkout-cache.c')
-rw-r--r--checkout-cache.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/checkout-cache.c b/checkout-cache.c
index 8d5e4cd148..09b36b9c77 100644
--- a/checkout-cache.c
+++ b/checkout-cache.c
@@ -52,11 +52,14 @@ static void create_directories(const char *path)
static int create_file(const char *path, unsigned int mode)
{
- int fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, 0600);
+ int fd;
+
+ mode = (mode & 0100) ? 777 : 666;
+ fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode);
if (fd < 0) {
if (errno == ENOENT) {
create_directories(path);
- fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, 0600);
+ fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode);
}
}
if (fd >= 0)
@@ -104,6 +107,14 @@ static int checkout_entry(struct cache_entry *ce)
fprintf(stderr, "checkout-cache: %s already exists\n", ce->name);
return 0;
}
+
+ /*
+ * We unlink the old file, to get the new one with the
+ * right permissions (including umask, which is nasty
+ * to emulate by hand - much easier to let the system
+ * just do the right thing)
+ */
+ unlink(ce->name);
}
return write_entry(ce);
}