summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2008-08-06 18:56:23 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2008-08-07 11:40:29 -0700
commite19b92becaafb7bee6cab22234c1179af20c12fc (patch)
tree5fa4698965a6c8aaf95d535c2e9d2bcdcffb8911
parentMerge branch 'jc/reflog-expire' into maint (diff)
parentAdd config option to enable 'fsync()' of object files (diff)
downloadtgif-e19b92becaafb7bee6cab22234c1179af20c12fc.tar.xz
Merge branch 'lt/config-fsync' into maint
* lt/config-fsync: Add config option to enable 'fsync()' of object files Split up default "i18n" and "branch" config parsing into helper routines Split up default "user" config parsing into helper routine Split up default "core" config parsing into helper routine
-rw-r--r--Documentation/config.txt8
-rw-r--r--cache.h1
-rw-r--r--config.c82
-rw-r--r--environment.c1
-rw-r--r--sha1_file.c3
5 files changed, 74 insertions, 21 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt
index d4ca8b2712..da2cb3f9f4 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -372,6 +372,14 @@ core.whitespace::
does not trigger if the character before such a carriage-return
is not a whitespace (not enabled by default).
+core.fsyncobjectfiles::
+ This boolean will enable 'fsync()' when writing object files.
++
+This is a total waste of time and effort on a filesystem that orders
+data writes properly, but can be useful for filesystems that do not use
+journalling (traditional UNIX filesystems) or that only journal metadata
+and not file contents (OS X's HFS+, or Linux ext3 with "data=writeback").
+
alias.*::
Command aliases for the linkgit:git[1] command wrapper - e.g.
after defining "alias.last = cat-file commit HEAD", the invocation
diff --git a/cache.h b/cache.h
index 9735b66e5e..8822651226 100644
--- a/cache.h
+++ b/cache.h
@@ -435,6 +435,7 @@ extern size_t packed_git_window_size;
extern size_t packed_git_limit;
extern size_t delta_base_cache_limit;
extern int auto_crlf;
+extern int fsync_object_files;
enum safe_crlf {
SAFE_CRLF_FALSE = 0,
diff --git a/config.c b/config.c
index c2f2bbb000..b2d5b4e4e3 100644
--- a/config.c
+++ b/config.c
@@ -332,7 +332,7 @@ int git_config_string(const char **dest, const char *var, const char *value)
return 0;
}
-int git_default_config(const char *var, const char *value, void *dummy)
+static int git_default_core_config(const char *var, const char *value)
{
/* This needs a better name */
if (!strcmp(var, "core.filemode")) {
@@ -444,6 +444,33 @@ int git_default_config(const char *var, const char *value, void *dummy)
return 0;
}
+ if (!strcmp(var, "core.pager"))
+ return git_config_string(&pager_program, var, value);
+
+ if (!strcmp(var, "core.editor"))
+ return git_config_string(&editor_program, var, value);
+
+ if (!strcmp(var, "core.excludesfile"))
+ return git_config_string(&excludes_file, var, value);
+
+ if (!strcmp(var, "core.whitespace")) {
+ if (!value)
+ return config_error_nonbool(var);
+ whitespace_rule_cfg = parse_whitespace_rule(value);
+ return 0;
+ }
+
+ if (!strcmp(var, "core.fsyncobjectfiles")) {
+ fsync_object_files = git_config_bool(var, value);
+ return 0;
+ }
+
+ /* Add other config variables here and to Documentation/config.txt. */
+ return 0;
+}
+
+static int git_default_user_config(const char *var, const char *value)
+{
if (!strcmp(var, "user.name")) {
if (!value)
return config_error_nonbool(var);
@@ -462,32 +489,24 @@ int git_default_config(const char *var, const char *value, void *dummy)
return 0;
}
+ /* Add other config variables here and to Documentation/config.txt. */
+ return 0;
+}
+
+static int git_default_i18n_config(const char *var, const char *value)
+{
if (!strcmp(var, "i18n.commitencoding"))
return git_config_string(&git_commit_encoding, var, value);
if (!strcmp(var, "i18n.logoutputencoding"))
return git_config_string(&git_log_output_encoding, var, value);
- if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) {
- pager_use_color = git_config_bool(var,value);
- return 0;
- }
-
- if (!strcmp(var, "core.pager"))
- return git_config_string(&pager_program, var, value);
-
- if (!strcmp(var, "core.editor"))
- return git_config_string(&editor_program, var, value);
-
- if (!strcmp(var, "core.excludesfile"))
- return git_config_string(&excludes_file, var, value);
+ /* Add other config variables here and to Documentation/config.txt. */
+ return 0;
+}
- if (!strcmp(var, "core.whitespace")) {
- if (!value)
- return config_error_nonbool(var);
- whitespace_rule_cfg = parse_whitespace_rule(value);
- return 0;
- }
+static int git_default_branch_config(const char *var, const char *value)
+{
if (!strcmp(var, "branch.autosetupmerge")) {
if (value && !strcasecmp(value, "always")) {
git_branch_track = BRANCH_TRACK_ALWAYS;
@@ -516,6 +535,29 @@ int git_default_config(const char *var, const char *value, void *dummy)
return 0;
}
+int git_default_config(const char *var, const char *value, void *dummy)
+{
+ if (!prefixcmp(var, "core."))
+ return git_default_core_config(var, value);
+
+ if (!prefixcmp(var, "user."))
+ return git_default_user_config(var, value);
+
+ if (!prefixcmp(var, "i18n."))
+ return git_default_i18n_config(var, value);
+
+ if (!prefixcmp(var, "branch."))
+ return git_default_branch_config(var, value);
+
+ if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) {
+ pager_use_color = git_config_bool(var,value);
+ return 0;
+ }
+
+ /* Add other config variables here and to Documentation/config.txt. */
+ return 0;
+}
+
int git_config_from_file(config_fn_t fn, const char *filename, void *data)
{
int ret;
diff --git a/environment.c b/environment.c
index 73feb2d03a..d5c3e29e97 100644
--- a/environment.c
+++ b/environment.c
@@ -29,6 +29,7 @@ const char *apply_default_whitespace;
int zlib_compression_level = Z_BEST_SPEED;
int core_compression_level;
int core_compression_seen;
+int fsync_object_files;
size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
size_t delta_base_cache_limit = 16 * 1024 * 1024;
diff --git a/sha1_file.c b/sha1_file.c
index 10346b681e..ff3bb493f8 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2093,7 +2093,8 @@ int hash_sha1_file(const void *buf, unsigned long len, const char *type,
/* Finalize a file on disk, and close it. */
static void close_sha1_file(int fd)
{
- /* For safe-mode, we could fsync_or_die(fd, "sha1 file") here */
+ if (fsync_object_files)
+ fsync_or_die(fd, "sha1 file");
fchmod(fd, 0444);
if (close(fd) != 0)
die("unable to write sha1 file");