summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f5b7495)
raw | patch | inline | side by side (parent: f5b7495)
author | Junio C Hamano <junkio@cox.net> | |
Sat, 6 Aug 2005 19:50:14 +0000 (12:50 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 6 Aug 2005 20:49:26 +0000 (13:49 -0700) |
Per discussion with people interested in binary packaging,
change the default template location from /etc/git-core to
/usr/share/git-core hierarchy. If a user wants to run git
before installing for whatever reason, in addition to adding
$src to the PATH environment variable, git-init-db can be run
with --template=$src/templates/blt/ parameter.
Signed-off-by: Junio C Hamano <junkio@cox.net>
change the default template location from /etc/git-core to
/usr/share/git-core hierarchy. If a user wants to run git
before installing for whatever reason, in addition to adding
$src to the PATH environment variable, git-init-db can be run
with --template=$src/templates/blt/ parameter.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Makefile | patch | blob | history | |
cache.h | patch | blob | history | |
init-db.c | patch | blob | history | |
templates/Makefile | patch | blob | history | |
templates/branches-- | [new file with mode: 0644] | patch | blob |
templates/info--exclude | [new file with mode: 0644] | patch | blob |
templates/this--description | [new file with mode: 0644] | patch | blob |
diff --git a/Makefile b/Makefile
index 425e9a4ace88efe3c90aea80f21ea0e38b5a28be..072d4267b6d9f0c2b46d75a15f935120b5b3bbec 100644 (file)
--- a/Makefile
+++ b/Makefile
prefix=$(HOME)
bindir=$(prefix)/bin
-etcdir=$(prefix)/etc
-etcgitdir=$(etcdir)/git-core
+template_dir=$(prefix)/share/git-core/templates/
# dest=
CC?=gcc
endif
CFLAGS += '-DSHA1_HEADER=$(SHA1_HEADER)'
-CFLAGS += '-DDEFAULT_GIT_TEMPLATE_ENVIRONMENT="$(etcgitdir)/templates"'
all: $(PROG)
+all:
+ $(MAKE) -C templates
.PRECIOUS: %.o
git-%: %.o $(LIB_FILE)
git-http-pull: LIBS += -lcurl
git-rev-list: LIBS += $(OPENSSL_LIBSSL)
+init-db.o: init-db.c
+ $(CC) -c $(CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
+
$(LIB_OBJS): $(LIB_H)
$(DIFF_OBJS): diffcore.h
index 6dbc32a7e60434647020672e677b7bf76a8b9f94..957e2ca7ca0d1a7209b8e1294286a1f641eb1338 100644 (file)
--- a/cache.h
+++ b/cache.h
#define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
#define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
#define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
-#define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIRECTORY"
-#ifndef DEFAULT_GIT_TEMPLATE_ENVIRONMENT
-#define DEFAULT_GIT_TEMPLATE_ENVIRONMENT "/etc/git-core/templates"
-#endif
extern char *get_object_directory(void);
extern char *get_refs_directory(void);
diff --git a/init-db.c b/init-db.c
index 3f53d6c77eaa2ebdc0f43f91d5d694a597185a70..1fb3f7fa79136f296ece9e04f6fdbf34bb40eeeb 100644 (file)
--- a/init-db.c
+++ b/init-db.c
*/
#include "cache.h"
+#ifndef DEFAULT_GIT_TEMPLATE_DIR
+#define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates/"
+#endif
+
static void safe_create_dir(const char *dir)
{
if (mkdir(dir, 0777) < 0) {
}
}
-static void copy_templates(const char *git_dir)
+static void copy_templates(const char *git_dir, int len, char *template_dir)
{
char path[PATH_MAX];
char template_path[PATH_MAX];
- char *template_dir;
- int len, template_len;
+ int template_len;
DIR *dir;
- strcpy(path, git_dir);
- len = strlen(path);
- template_dir = gitenv(TEMPLATE_DIR_ENVIRONMENT);
if (!template_dir)
- template_dir = DEFAULT_GIT_TEMPLATE_ENVIRONMENT;
+ template_dir = DEFAULT_GIT_TEMPLATE_DIR;
strcpy(template_path, template_dir);
template_len = strlen(template_path);
if (template_path[template_len-1] != '/') {
template_path[template_len++] = '/';
template_path[template_len] = 0;
}
-
dir = opendir(template_path);
- if (!dir)
+ if (!dir) {
+ fprintf(stderr, "warning: templates not found %s\n",
+ template_dir);
return;
+ }
+
+ memcpy(path, git_dir, len);
copy_templates_1(path, len,
template_path, template_len,
dir);
closedir(dir);
}
-static void create_default_files(const char *git_dir)
+static void create_default_files(const char *git_dir,
+ char *template_path)
{
unsigned len = strlen(git_dir);
static char path[PATH_MAX];
exit(1);
}
}
- path[len] = 0;
- copy_templates(path);
+ copy_templates(path, len, template_path);
}
+static const char init_db_usage[] =
+"git-init-db [--template=<template-directory>]";
+
/*
* If you want to, you can share the DB area with any number of branches.
* That has advantages: you can save space by sharing all the SHA1 objects.
{
const char *git_dir;
const char *sha1_dir;
- char *path;
+ char *path, *template_dir = NULL;
int len, i;
+ for (i = 1; i < argc; i++, argv++) {
+ char *arg = argv[1];
+ if (arg[0] != '-')
+ break;
+ else if (!strncmp(arg, "--template=", 11))
+ template_dir = arg+11;
+ else
+ die(init_db_usage);
+ }
+
/*
* Set up the default .git directory contents
*/
fprintf(stderr, "defaulting to local storage area\n");
}
safe_create_dir(git_dir);
- create_default_files(git_dir);
+ create_default_files(git_dir, template_dir);
/*
* And set up the object store.
diff --git a/templates/Makefile b/templates/Makefile
index 12433519eefef9bbef1c74729a1df11fa8ab34f4..6b2a90071bcf1fc8e494b08f3738a34f35bb9cd0 100644 (file)
--- a/templates/Makefile
+++ b/templates/Makefile
-# make
+# make and install sample templates
INSTALL=install
prefix=$(HOME)
-etcdir=$(prefix)/etc
-etcgitdir=$(etcdir)/git-core
-templatedir=$(etcgitdir)/templates
+template_dir=$(prefix)/share/git-core/templates/
# dest=
-all:
+all: boilerplates custom
+ find blt
+
+# Put templates that can be copied straight from the source
+# in a file direc--tory--file in the source. They will be
+# just copied to the destination.
+boilerplates:
+ ls *--* 2>/dev/null | \
+ while read boilerplate; \
+ do \
+ case "$$boilerplate" in *~) continue ;; esac && \
+ dst=`echo "$$boilerplate" | sed -e 's|^this|.|;s|--|/|g'` && \
+ dir=`expr "$$dst" : '\(.*\)/'` && \
+ mkdir -p blt/$$dir && \
+ case "$$boilerplate" in \
+ *--) ;; \
+ *) cp $$boilerplate blt/$$dst ;; \
+ esac || exit; \
+ done || exit
+
+# If you need build-tailored templates, build them into blt/
+# directory yourself here.
+custom:
+ : no custom templates yet
+
clean:
+ rm -rf blt
-install:
- $(INSTALL) -d -m755 $(dest)$(templatedir)/hooks/
- $(foreach s,$(wildcard hooks--*),\
- $(INSTALL) -m644 $s \
- $(dest)$(templatedir)/hooks/$(patsubst hooks--%,%,$s);)
- $(INSTALL) -d -m755 $(dest)$(templatedir)/info
- $(INSTALL) -d -m755 $(dest)$(templatedir)/branches
+install: all
+ $(INSTALL) -d -m755 $(dest)$(template_dir)
+ tar Ccf blt - . | tar Cxf $(dest)$(template_dir) -
diff --git a/templates/branches-- b/templates/branches--
--- /dev/null
+++ b/templates/branches--
@@ -0,0 +1 @@
+: this is just to ensure the directory exists.
diff --git a/templates/info--exclude b/templates/info--exclude
--- /dev/null
+++ b/templates/info--exclude
@@ -0,0 +1,6 @@
+# git-ls-files --others --exclude-from=.git/info/exclude
+# Lines that start with '#' are comments.
+# For a project mostly in C, the following would be a good set of
+# exclude patterns (uncomment them if you want to use them):
+# *.[oa]
+# *~
diff --git a/templates/this--description b/templates/this--description
--- /dev/null
@@ -0,0 +1 @@
+Unnamed repository; edit this file to name it for gitweb.