Rename core.unreliableHardlinks to core.createObject
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Mon, 27 Apr 2009 22:32:25 +0000 (00:32 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 Apr 2009 23:50:07 +0000 (16:50 -0700)
"Unreliable hardlinks" is a misleading description for what is happening.
So rename it to something less misleading.

Suggested by Linus Torvalds.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config.txt
Makefile
cache.h
config.c
environment.c
sha1_file.c
index d31adb6719eeff3009a2799b89d5ae6d343d3e88..5dcad94f841c395beb21961ebdacd341d76b25c9 100644 (file)
@@ -429,10 +429,14 @@ relatively high IO latencies.  With this set to 'true', git will do the
 index comparison to the filesystem data in parallel, allowing
 overlapping IO's.
 
 index comparison to the filesystem data in parallel, allowing
 overlapping IO's.
 
-core.unreliableHardlinks::
-       Some filesystem drivers cannot properly handle hardlinking a file
-       and deleting the source right away.  In such a case, you need to
-       set this config variable to 'true'.
+core.createObject::
+       You can set this to 'link', in which case a hardlink followed by
+       a delete of the source are used to make sure that object creation
+       will not overwrite existing objects.
++
+On some file system/operating system combinations, this is unreliable.
+Set this config setting to 'rename' there; However, This will remove the
+check that makes sure that existing object files will not get overwritten.
 
 alias.*::
        Command aliases for the linkgit:git[1] command wrapper - e.g.
 
 alias.*::
        Command aliases for the linkgit:git[1] command wrapper - e.g.
index 6b80f81d6005a5ef47cf29c1b92312a445ab8162..6e216436c36f4dcbe1121d02a291e9f568ca6071 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -172,8 +172,8 @@ all::
 # information on a not yet closed file that lstat would return for the same
 # file after it was closed.
 #
 # information on a not yet closed file that lstat would return for the same
 # file after it was closed.
 #
-# Define UNRELIABLE_HARDLINKS if your operating systems has problems when
-# hardlinking a file to another name and unlinking the original file right
+# Define OBJECT_CREATION_USES_RENAMES if your operating systems has problems
+# when hardlinking a file to another name and unlinking the original file right
 # away (some NTFS drivers seem to zero the contents in that scenario).
 
 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
 # away (some NTFS drivers seem to zero the contents in that scenario).
 
 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
@@ -837,7 +837,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
        NO_NSEC = YesPlease
        USE_WIN32_MMAP = YesPlease
        UNRELIABLE_FSTAT = UnfortunatelyYes
        NO_NSEC = YesPlease
        USE_WIN32_MMAP = YesPlease
        UNRELIABLE_FSTAT = UnfortunatelyYes
-       UNRELIABLE_HARDLINKS = UnfortunatelySometimes
+       OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
        COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/regex -Icompat/fnmatch
        COMPAT_CFLAGS += -DSNPRINTF_SIZE_CORR=1
        COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
        COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/regex -Icompat/fnmatch
        COMPAT_CFLAGS += -DSNPRINTF_SIZE_CORR=1
        COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
@@ -1021,8 +1021,8 @@ else
                COMPAT_OBJS += compat/win32mmap.o
        endif
 endif
                COMPAT_OBJS += compat/win32mmap.o
        endif
 endif
-ifdef UNRELIABLE_HARDLINKS
-       COMPAT_CFLAGS += -DUNRELIABLE_HARDLINKS=1
+ifdef OBJECT_CREATION_USES_RENAMES
+       COMPAT_CFLAGS += -DOBJECT_CREATION_MODE=1
 endif
 ifdef NO_PREAD
        COMPAT_CFLAGS += -DNO_PREAD
 endif
 ifdef NO_PREAD
        COMPAT_CFLAGS += -DNO_PREAD
diff --git a/cache.h b/cache.h
index ff9e145be0a869546d309fb16db651f6b30a70e9..d0d48b4c88b8f359be7c271dbe7ef8f816999960 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -554,7 +554,12 @@ extern enum branch_track git_branch_track;
 extern enum rebase_setup_type autorebase;
 extern enum push_default_type push_default;
 
 extern enum rebase_setup_type autorebase;
 extern enum push_default_type push_default;
 
-extern int unreliable_hardlinks;
+enum object_creation_mode {
+       OBJECT_CREATION_USES_HARDLINKS = 0,
+       OBJECT_CREATION_USES_RENAMES = 1,
+};
+
+extern enum object_creation_mode object_creation_mode;
 
 #define GIT_REPO_VERSION 0
 extern int repository_format_version;
 
 #define GIT_REPO_VERSION 0
 extern int repository_format_version;
index 1750cfb85e34214533af13069853b7159cead2e8..563a91594dd7f0a801ade8b7ac4587aad481679e 100644 (file)
--- a/config.c
+++ b/config.c
@@ -495,8 +495,13 @@ static int git_default_core_config(const char *var, const char *value)
                return 0;
        }
 
                return 0;
        }
 
-       if (!strcmp(var, "core.unreliablehardlinks")) {
-               unreliable_hardlinks = git_config_bool(var, value);
+       if (!strcmp(var, "core.createobject")) {
+               if (!strcmp(value, "rename"))
+                       object_creation_mode = OBJECT_CREATION_USES_RENAMES;
+               else if (!strcmp(value, "link"))
+                       object_creation_mode = OBJECT_CREATION_USES_HARDLINKS;
+               else
+                       die("Invalid mode for object creation: %s", value);
                return 0;
        }
 
                return 0;
        }
 
index 10578d24d77de08bde2cbda7616d14f1705d490d..801a005ef1b23ef13cfa9ece676c550fe35dedc0 100644 (file)
@@ -43,10 +43,10 @@ unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
 enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
 enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
 enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
 enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
 enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
 enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
-#ifndef UNRELIABLE_HARDLINKS
-#define UNRELIABLE_HARDLINKS 0
+#ifndef OBJECT_CREATION_MODE
+#define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS
 #endif
 #endif
-int unreliable_hardlinks = UNRELIABLE_HARDLINKS;
+enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
 
 /* Parallel index stat data preload? */
 int core_preload_index = 0;
 
 /* Parallel index stat data preload? */
 int core_preload_index = 0;
index 11969fc161bb56af410a76f0791dc9cb3bec0e1b..f708cf4f674fdf393044d6c36c7d97f1fa7dcd0c 100644 (file)
@@ -2225,7 +2225,7 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
 {
        int ret = 0;
 
 {
        int ret = 0;
 
-       if (unreliable_hardlinks)
+       if (object_creation_mode == OBJECT_CREATION_USES_RENAMES)
                goto try_rename;
        else if (link(tmpfile, filename))
                ret = errno;
                goto try_rename;
        else if (link(tmpfile, filename))
                ret = errno;