# [PATCH] Add config variable core.symrefsonly

3 messages from 2005-11-15 to 2005-11-15. Participants: Johannes Schindelin, Linus Torvalds.
Thread: https://gitlist.dev/t/2530

## Johannes Schindelin, 2005-11-15 18:24

Subject: [PATCH] Add config variable core.symrefsonly
Message-ID: <Pine.LNX.4.63.0511151923120.1103@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0511151923120.1103%40wbgn013.biozentrum.uni-wuerzburg.de

```

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>

---

	Linus, is there any reason you don´t allow spaces, underscores
	and dashes in the config variables?

	Petr, happy?

 cache.h        |    1 +
 config.c       |    5 +++++
 environment.c  |    1 +
 refs.c         |   10 ++++++----
 symbolic-ref.c |    1 +
 5 files changed, 14 insertions(+), 4 deletions(-)

applies-to: 4b6dbe856a3e63699b299c76f4f1fc5cb34cbe26
b12e60607e70f01de9dc65b88f15c9b17f7be4c5
diff --git a/cache.h b/cache.h
index 677c6ac..9a6bfb9 100644
--- a/cache.h
+++ b/cache.h
@@ -179,6 +179,7 @@ extern int commit_index_file(struct cach
 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
diff --git a/config.c b/config.c
index e89bab2..bd35138 100644
--- a/config.c
+++ b/config.c
@@ -214,6 +214,11 @@ int git_default_config(const char *var, 
 		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;
diff --git a/environment.c b/environment.c
index 1dc7af5..b5026f1 100644
--- a/environment.c
+++ b/environment.c
@@ -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 a52b038..f324be5 100644
--- a/refs.c
+++ b/refs.c
@@ -121,10 +121,12 @@ int create_symref(const char *git_HEAD, 
 	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);
diff --git a/symbolic-ref.c b/symbolic-ref.c
index a72d7ac..193c87c 100644
--- a/symbolic-ref.c
+++ b/symbolic-ref.c
@@ -20,6 +20,7 @@ static void check_symref(const char *HEA
 int main(int argc, const char **argv)
 {
 	setup_git_directory();
+	git_config(git_default_config);
 	switch (argc) {
 	case 2:
 		check_symref(argv[1]);
---
0.99.9.GIT
```

## Linus Torvalds, 2005-11-15 18:39

Subject: Re: [PATCH] Add config variable core.symrefsonly
Message-ID: <Pine.LNX.4.64.0511151028540.3945@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0511151028540.3945%40g5.osdl.org
In-Reply-To: <Pine.LNX.4.63.0511151923120.1103@wbgn013.biozentrum.uni-wuerzburg.de>

```


On Tue, 15 Nov 2005, Johannes Schindelin wrote:
> 
> 	Linus, is there any reason you don´t allow spaces, underscores
> 	and dashes in the config variables?

I much preferred being anal and maybe relaxing the rules later than being 
permissive and accepting horrible crap.

Spaces are definitely out, since we are trying to igore whitespace 
everywhere, but underscores and dashes might be ok.

However, the traditional way to do these kinds of things in ini files is 
with PrettyCaps(tm), ie you'd do

	[core]
		SymRefsOnly = true

rather than the C way.

Let's face it, the C way is the only true way for a programming language, 
but having case matter in something unimportant and human-readable like a 
"ini" file is just bothersome, so PrettyCase(tm) actually makes sense 
there.

PrettyCase is for toys - unimportant things where it's more important to 
say "we don't care" over saying "we need to be precise". So Pascal is PC. 
It's a toy language. FAT is PC - it's a toy filesystem. And ini files are 
PC: it's more important that a config file is human-readable than it is 
that it's very precise and strict.

Put another way: real programmers want strict rules, because they know 
they'll be hurt without them. But _users_ need to be coddled. And ini 
files aren't for programmers, they are for users.

		Linus
```

## Johannes Schindelin, 2005-11-15 18:54

Subject: Re: [PATCH] Add config variable core.symrefsonly
Message-ID: <Pine.LNX.4.63.0511151953001.1427@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0511151953001.1427%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <Pine.LNX.4.64.0511151028540.3945@g5.osdl.org>

```
Hi,

On Tue, 15 Nov 2005, Linus Torvalds wrote:

> On Tue, 15 Nov 2005, Johannes Schindelin wrote:
> > 
> > 	Linus, is there any reason you don´t allow spaces, underscores
> > 	and dashes in the config variables?
> 
> [...]
>
> PrettyCase is for toys [...] And ini files are PC: it's more important 
> that a config file is human-readable than it is that it's very precise 
> and strict.

Thanks for the explanation. Makes sense.

Ciao,
Dscho
```
