Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: git@vger.kernel.org
Subject: [PATCH] Use the template mechanism to set up refs/ hierarchy as well.
Date: Tue, 02 Aug 2005 23:28:35 -0700	[thread overview]
Message-ID: <7v3bprjzzg.fsf@assigned-by-dhcp.cox.net> (raw)

This may be controversial from the robustness standpoint, so I
am placing it in the proposed update queue first.  Discussions
on the list very welcomed.

Once the alternate object pool mechanism is taught to use
$GIT_DIR/info/alt file (instead of/in addition to the
environment variable), this would help people setting up
repositories for underling developers.  They can prepare a
standard template info/alt that points at the project-wide base
object pool that is shared, and have people point
GIT_TEMPLATE_DIRECTORY at the project standard template
directory.

------------
This removes the hardcoded set of refs/ directory structure that
is created by git-init-db and move it to the template
mechanism.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

 init-db.c            |   22 ----------------------
 t/t5400-send-pack.sh |   16 +++++++++++++++-
 templates/Makefile   |    4 ++++
 3 files changed, 19 insertions(+), 23 deletions(-)

de8b5bf5605274d29b835947932b9b6c109f5d9f
diff --git a/init-db.c b/init-db.c
--- a/init-db.c
+++ b/init-db.c
@@ -167,28 +167,6 @@ static void create_default_files(const c
 
 	if (len && path[len-1] != '/')
 		path[len++] = '/';
-
-	/*
-	 * Create .git/refs/{heads,tags}
-	 */
-	strcpy(path + len, "refs");
-	safe_create_dir(path);
-	strcpy(path + len, "refs/heads");
-	safe_create_dir(path);
-	strcpy(path + len, "refs/tags");
-	safe_create_dir(path);
-
-	/*
-	 * Create the default symlink from ".git/HEAD" to the "master"
-	 * branch
-	 */
-	strcpy(path + len, "HEAD");
-	if (symlink("refs/heads/master", path) < 0) {
-		if (errno != EEXIST) {
-			perror(path);
-			exit(1);
-		}
-	}
 	copy_templates(path);
 }
 
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -8,6 +8,18 @@ test_description='See why rewinding head
 '
 . ./test-lib.sh
 
+# This part is needed to test before installing templates.
+mkdir -p templates/refs/heads
+ln -s refs/heads/master templates/HEAD
+mkdir -p templates/hooks
+echo '#!/bin/sh
+echo we are here >$GIT_DIR/we-are-here' >templates/hooks/post-update
+chmod +x templates/hooks/post-update
+
+GIT_TEMPLATE_DIRECTORY=`pwd`/templates/
+export GIT_TEMPLATE_DIRECTORY
+git-init-db
+
 cnt='1'
 test_expect_success setup '
 	tree=$(git-write-tree) &&
@@ -50,5 +62,7 @@ test_expect_success \
 	fi &&
 	# this should update
 	git-send-pack --force ./victim/.git/ master &&
-	cmp victim/.git/refs/heads/master .git/refs/heads/master
+	cmp victim/.git/refs/heads/master .git/refs/heads/master &&
+	# and post-update should have run
+	test -f victim/.git/we-are-here
 '
diff --git a/templates/Makefile b/templates/Makefile
--- a/templates/Makefile
+++ b/templates/Makefile
@@ -17,3 +17,7 @@ install:
 		$(dest)$(templatedir)/hooks/$(patsubst hooks--%,%,$s);)
 	$(INSTALL) -d -m755 $(dest)$(templatedir)/info
 	$(INSTALL) -d -m755 $(dest)$(templatedir)/branches
+	$(INSTALL) -d -m755 $(dest)$(templatedir)/refs/heads
+	$(INSTALL) -d -m755 $(dest)$(templatedir)/refs/tags
+	rm -f $(dest)$(templatedir)/HEAD && \
+	ln -s refs/heads/master $(dest)$(templatedir)/HEAD

             reply	other threads:[~2005-08-03  6:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-03  6:28 Junio C Hamano [this message]
2005-08-04 18:41 ` [PATCH] Use the template mechanism to set up refs/ hierarchy as well Johannes Schindelin
2005-08-04 19:59   ` Junio C Hamano
2005-08-04 20:19     ` Johannes Schindelin
2005-08-04 20:50       ` Junio C Hamano
2005-08-04 21:13         ` Johannes Schindelin
2005-08-04 21:35           ` Junio C Hamano
2005-08-05  0:35             ` Johannes Schindelin
2005-08-04 22:08       ` barkalow
2005-08-05  0:20         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v3bprjzzg.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox