@matheusbsbs / matheus-bagliano / commits / f8348be3be
Fork 0

Add config variable core.symrefsonly

This allows you to force git to avoid symlinks for refs. Just add something like [core] symrefsonly = true to .git/config. Don´t forget to "git checkout your_branch", or it does not do anything... Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Nov 15, 2005 at 19:24 UTC f8348be3be8493a62110a09ab0343213990b416b
5 files changed +14 -4
cache.h
+1
@@ -179,6 +179,7 @@ extern int commit_index_file(struct cache_file *);
179 extern void rollback_index_file(struct cache_file *);
180
181 extern int trust_executable_bit;
182 +extern int only_use_symrefs;
183
184 #define MTIME_CHANGED 0x0001
185 #define CTIME_CHANGED 0x0002
config.c
+5
@@ -214,6 +214,11 @@ int git_default_config(const char *var, const char *value)
214 return 0;
215 }
216
217 + if (!strcmp(var, "core.symrefsonly")) {
218 + only_use_symrefs = git_config_bool(var, value);
219 + return 0;
220 + }
221 +
222 if (!strcmp(var, "user.name")) {
223 strncpy(git_default_name, value, sizeof(git_default_name));
224 return 0;
environment.c
+1
@@ -12,6 +12,7 @@
12 char git_default_email[MAX_GITNAME];
13 char git_default_name[MAX_GITNAME];
14 int trust_executable_bit = 1;
15 +int only_use_symrefs = 0;
16
17 static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir,
18 *git_graft_file;
refs.c
+6 -4
@@ -121,10 +121,12 @@ int create_symref(const char *git_HEAD, const char *refs_heads_master)
121 int fd, len, written;
122
123 #if USE_SYMLINK_HEAD
124 - unlink(git_HEAD);
125 - if (!symlink(refs_heads_master, git_HEAD))
126 - return 0;
127 - fprintf(stderr, "no symlink - falling back to symbolic ref\n");
124 + if (!only_use_symrefs) {
125 + unlink(git_HEAD);
126 + if (!symlink(refs_heads_master, git_HEAD))
127 + return 0;
128 + fprintf(stderr, "no symlink - falling back to symbolic ref\n");
129 + }
130 #endif
131
132 len = snprintf(ref, sizeof(ref), "ref: %s\n", refs_heads_master);
symbolic-ref.c
+1
@@ -20,6 +20,7 @@ static void check_symref(const char *HEAD)
20 int main(int argc, const char **argv)
21 {
22 setup_git_directory();
23 + git_config(git_default_config);
24 switch (argc) {
25 case 2:
26 check_symref(argv[1]);