From: Junio C Hamano Date: Thu, 7 Aug 2008 01:56:23 +0000 (-0700) Subject: Merge branch 'lt/config-fsync' into maint X-Git-Tag: v1.6.0-rc3~15^2~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/e19b92becaafb7bee6cab22234c1179af20c12fc?ds=inline;hp=-c 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 --- e19b92becaafb7bee6cab22234c1179af20c12fc diff --combined Documentation/config.txt index d4ca8b2712,2466ecfc6b..da2cb3f9f4 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@@ -92,7 -92,7 +92,7 @@@ Exampl # Our diff algorithm [diff] - external = "/usr/local/bin/gnu-diff -u" + external = /usr/local/bin/diff-wrapper renames = true [branch "devel"] @@@ -372,6 -372,14 +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 @@@ -554,11 -562,9 +562,11 @@@ diff.autorefreshindex: diff.external:: If this config variable is set, diff generation is not performed using the internal diff machinery, but using the - given command. Note: if you want to use an external diff - program only on a subset of your files, you might want to - use linkgit:gitattributes[5] instead. + given command. Can be overridden with the `GIT_EXTERNAL_DIFF' + environment variable. The command is called with parameters + as described under "git Diffs" in linkgit:git[1]. Note: if + you want to use an external diff program only on a subset of + your files, you might want to use linkgit:gitattributes[5] instead. diff.renameLimit:: The number of files to consider when performing the copy/rename diff --combined cache.h index 9735b66e5e,01c8502afb..8822651226 --- a/cache.h +++ b/cache.h @@@ -396,7 -396,7 +396,7 @@@ extern void fill_stat_cache_info(struc #define REFRESH_UNMERGED 0x0002 /* allow unmerged */ #define REFRESH_QUIET 0x0004 /* be quiet about it */ #define REFRESH_IGNORE_MISSING 0x0008 /* ignore non-existent */ -#define REFRESH_IGNORE_SUBMODULES 0x0008 /* ignore submodules */ +#define REFRESH_IGNORE_SUBMODULES 0x0010 /* ignore submodules */ extern int refresh_index(struct index_state *, unsigned int flags, const char **pathspec, char *seen); struct lock_file { @@@ -435,6 -435,7 +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, @@@ -518,7 -519,6 +519,7 @@@ enum sharedrepo int git_config_perm(const char *var, const char *value); int adjust_shared_perm(const char *path); int safe_create_leading_directories(char *path); +int safe_create_leading_directories_const(const char *path); char *enter_repo(char *path, int strict); static inline int is_absolute_path(const char *path) { @@@ -526,7 -526,6 +527,7 @@@ } const char *make_absolute_path(const char *path); const char *make_nonrelative_path(const char *path); +const char *make_relative_path(const char *abs, const char *base); /* Read and unpack a sha1 file into memory, write memory to a sha1 file */ extern int sha1_object_info(const unsigned char *, unsigned long *); diff --combined sha1_file.c index 10346b681e,fe4ee3ece5..ff3bb493f8 --- a/sha1_file.c +++ b/sha1_file.c @@@ -116,15 -116,6 +116,15 @@@ int safe_create_leading_directories(cha return 0; } +int safe_create_leading_directories_const(const char *path) +{ + /* path points to cache entries, so xstrdup before messing with it */ + char *buf = xstrdup(path); + int result = safe_create_leading_directories(buf); + free(buf); + return result; +} + char *sha1_to_hex(const unsigned char *sha1) { static int bufno; @@@ -1609,7 -1600,6 +1609,7 @@@ static void *unpack_delta_entry(struct off_t base_offset; base_offset = get_delta_base(p, w_curs, &curpos, *type, obj_offset); + unuse_pack(w_curs); base = cache_or_unpack_entry(p, base_offset, &base_size, type, 0); if (!base) die("failed to read delta base object" @@@ -2093,7 -2083,8 +2093,8 @@@ int hash_sha1_file(const void *buf, uns /* 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"); @@@ -2128,7 -2119,6 +2129,7 @@@ static int create_tmpfile(char *buffer fd = mkstemp(buffer); if (fd < 0 && dirlen) { /* Make sure the directory exists */ + memcpy(buffer, filename, dirlen); buffer[dirlen-1] = 0; if (mkdir(buffer, 0777) || adjust_shared_perm(buffer)) return -1;