Skip to content

Commit

Permalink
Add config variable core.symrefsonly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Nov 15, 2005
1 parent 4a4e6fd commit f8348be
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions symbolic-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit f8348be

Please sign in to comment.