Skip to content

Commit 348df16

Browse files
dschogitster
authored andcommitted
Rename core.unreliableHardlinks to core.createObject
"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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 26e47f2 commit 348df16

File tree

6 files changed

+30
-16
lines changed

6 files changed

+30
-16
lines changed

Documentation/config.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,14 @@ relatively high IO latencies. With this set to 'true', git will do the
429429
index comparison to the filesystem data in parallel, allowing
430430
overlapping IO's.
431431

432-
core.unreliableHardlinks::
433-
Some filesystem drivers cannot properly handle hardlinking a file
434-
and deleting the source right away. In such a case, you need to
435-
set this config variable to 'true'.
432+
core.createObject::
433+
You can set this to 'link', in which case a hardlink followed by
434+
a delete of the source are used to make sure that object creation
435+
will not overwrite existing objects.
436+
+
437+
On some file system/operating system combinations, this is unreliable.
438+
Set this config setting to 'rename' there; However, This will remove the
439+
check that makes sure that existing object files will not get overwritten.
436440

437441
alias.*::
438442
Command aliases for the linkgit:git[1] command wrapper - e.g.

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ all::
172172
# information on a not yet closed file that lstat would return for the same
173173
# file after it was closed.
174174
#
175-
# Define UNRELIABLE_HARDLINKS if your operating systems has problems when
176-
# hardlinking a file to another name and unlinking the original file right
175+
# Define OBJECT_CREATION_USES_RENAMES if your operating systems has problems
176+
# when hardlinking a file to another name and unlinking the original file right
177177
# away (some NTFS drivers seem to zero the contents in that scenario).
178178

179179
GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
@@ -837,7 +837,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
837837
NO_NSEC = YesPlease
838838
USE_WIN32_MMAP = YesPlease
839839
UNRELIABLE_FSTAT = UnfortunatelyYes
840-
UNRELIABLE_HARDLINKS = UnfortunatelySometimes
840+
OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
841841
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/regex -Icompat/fnmatch
842842
COMPAT_CFLAGS += -DSNPRINTF_SIZE_CORR=1
843843
COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
@@ -1021,8 +1021,8 @@ else
10211021
COMPAT_OBJS += compat/win32mmap.o
10221022
endif
10231023
endif
1024-
ifdef UNRELIABLE_HARDLINKS
1025-
COMPAT_CFLAGS += -DUNRELIABLE_HARDLINKS=1
1024+
ifdef OBJECT_CREATION_USES_RENAMES
1025+
COMPAT_CFLAGS += -DOBJECT_CREATION_MODE=1
10261026
endif
10271027
ifdef NO_PREAD
10281028
COMPAT_CFLAGS += -DNO_PREAD

cache.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,12 @@ extern enum branch_track git_branch_track;
554554
extern enum rebase_setup_type autorebase;
555555
extern enum push_default_type push_default;
556556

557-
extern int unreliable_hardlinks;
557+
enum object_creation_mode {
558+
OBJECT_CREATION_USES_HARDLINKS = 0,
559+
OBJECT_CREATION_USES_RENAMES = 1,
560+
};
561+
562+
extern enum object_creation_mode object_creation_mode;
558563

559564
#define GIT_REPO_VERSION 0
560565
extern int repository_format_version;

config.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,13 @@ static int git_default_core_config(const char *var, const char *value)
495495
return 0;
496496
}
497497

498-
if (!strcmp(var, "core.unreliablehardlinks")) {
499-
unreliable_hardlinks = git_config_bool(var, value);
498+
if (!strcmp(var, "core.createobject")) {
499+
if (!strcmp(value, "rename"))
500+
object_creation_mode = OBJECT_CREATION_USES_RENAMES;
501+
else if (!strcmp(value, "link"))
502+
object_creation_mode = OBJECT_CREATION_USES_HARDLINKS;
503+
else
504+
die("Invalid mode for object creation: %s", value);
500505
return 0;
501506
}
502507

environment.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
4343
enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
4444
enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
4545
enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
46-
#ifndef UNRELIABLE_HARDLINKS
47-
#define UNRELIABLE_HARDLINKS 0
46+
#ifndef OBJECT_CREATION_MODE
47+
#define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS
4848
#endif
49-
int unreliable_hardlinks = UNRELIABLE_HARDLINKS;
49+
enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
5050

5151
/* Parallel index stat data preload? */
5252
int core_preload_index = 0;

sha1_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2225,7 +2225,7 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
22252225
{
22262226
int ret = 0;
22272227

2228-
if (unreliable_hardlinks)
2228+
if (object_creation_mode == OBJECT_CREATION_USES_RENAMES)
22292229
goto try_rename;
22302230
else if (link(tmpfile, filename))
22312231
ret = errno;

0 commit comments

Comments
 (0)