Code

Add config variable core.symrefsonly
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Tue, 15 Nov 2005 18:24:19 +0000 (19:24 +0100)
committerJunio C Hamano <junkio@cox.net>
Tue, 15 Nov 2005 19:42:29 +0000 (11:42 -0800)
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>
cache.h
config.c
environment.c
refs.c
symbolic-ref.c

diff --git a/cache.h b/cache.h
index 677c6acc350155d606e2ba05a9bbf5eb28637a31..9a6bfb96d9d0f4e8316dbbe60469988cf48f197b 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -179,6 +179,7 @@ extern int commit_index_file(struct cache_file *);
 extern void rollback_index_file(struct cache_file *);
 
 extern int trust_executable_bit;
+extern int only_use_symrefs;
 
 #define MTIME_CHANGED  0x0001
 #define CTIME_CHANGED  0x0002
index e89bab26c99f95e6bb7d3346343ab0c623843c42..bd35138daec12366193bf6e2b95399ef8287d205 100644 (file)
--- a/config.c
+++ b/config.c
@@ -214,6 +214,11 @@ int git_default_config(const char *var, const char *value)
                return 0;
        }
 
+       if (!strcmp(var, "core.symrefsonly")) {
+               only_use_symrefs = git_config_bool(var, value);
+               return 0;
+       }
+
        if (!strcmp(var, "user.name")) {
                strncpy(git_default_name, value, sizeof(git_default_name));
                return 0;
index 1dc7af56cf93e46c456eaa13f8f8150258abe43c..b5026f1265b771bc3f9906507b015fbd1d68f8fb 100644 (file)
@@ -12,6 +12,7 @@
 char git_default_email[MAX_GITNAME];
 char git_default_name[MAX_GITNAME];
 int trust_executable_bit = 1;
+int only_use_symrefs = 0;
 
 static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir,
        *git_graft_file;
diff --git a/refs.c b/refs.c
index a52b038eefdf22fce20d1a81180c97def0613cdb..f324be50325d1ba765fbbb823937bf68ef91c0aa 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -121,10 +121,12 @@ int create_symref(const char *git_HEAD, const char *refs_heads_master)
        int fd, len, written;
 
 #if USE_SYMLINK_HEAD
-       unlink(git_HEAD);
-       if (!symlink(refs_heads_master, git_HEAD))
-               return 0;
-       fprintf(stderr, "no symlink - falling back to symbolic ref\n");
+       if (!only_use_symrefs) {
+               unlink(git_HEAD);
+               if (!symlink(refs_heads_master, git_HEAD))
+                       return 0;
+               fprintf(stderr, "no symlink - falling back to symbolic ref\n");
+       }
 #endif
 
        len = snprintf(ref, sizeof(ref), "ref: %s\n", refs_heads_master);
index a72d7accb18092231c608a6ae7db4a4ce9dc8b73..193c87c174706710b346e58c42a9651dbb5e671f 100644 (file)
@@ -20,6 +20,7 @@ static void check_symref(const char *HEAD)
 int main(int argc, const char **argv)
 {
        setup_git_directory();
+       git_config(git_default_config);
        switch (argc) {
        case 2:
                check_symref(argv[1]);