Code

Merge branch 'lt/config-fsync' into maint
authorJunio C Hamano <gitster@pobox.com>
Thu, 7 Aug 2008 01:56:23 +0000 (18:56 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 7 Aug 2008 18:40:29 +0000 (11:40 -0700)
* 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

1  2 
Documentation/config.txt
cache.h
sha1_file.c

diff --combined Documentation/config.txt
index d4ca8b2712f9ca148db642ea50f94f3f9acf2a2c,2466ecfc6b2be075e88c1b1a48e814c726e228f5..da2cb3f9f45899b780785b18512a5af4c3fbf263
@@@ -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 9735b66e5ed47a0006c5b1036eff90847eeb3818,01c8502afb3afe19b59ea2dad8cf64e154aa3612..882265122665fe2a876e8b23e3ec6899cd0faa23
+++ 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)
  {
  }
  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 10346b681e3575d17945f64513e2b0fecbcc01fc,fe4ee3ece57ae8627572554c1e9af9f292c67ac6..ff3bb493f8950918f9471b1402781f48f1e038ee
@@@ -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;