diff options
context:
space:
mode:
-rw-r--r--.gitignore14
-rw-r--r--.gitmodules2
-rw-r--r--Makefile141
-rw-r--r--assets/cgit.css (renamed from cgit.css)0
-rw-r--r--assets/cgit.js (renamed from cgit.js)0
-rw-r--r--assets/cgit.png (renamed from cgit.png)bin1366 -> 1366 bytes
-rw-r--r--assets/favicon.ico (renamed from favicon.ico)bin1078 -> 1078 bytes
-rw-r--r--assets/robots.txt (renamed from robots.txt)0
-rw-r--r--cgitrc.5.txt2
-rwxr-xr-xexamples/hooks/post-receive.agefile (renamed from contrib/hooks/post-receive.agefile)0
-rwxr-xr-xextensions/about-formatting.sh (renamed from filters/about-formatting.sh)0
-rwxr-xr-xextensions/commit-links.sh (renamed from filters/commit-links.sh)0
-rw-r--r--extensions/email-gravatar.lua (renamed from filters/email-gravatar.lua)0
-rwxr-xr-xextensions/email-gravatar.py (renamed from filters/email-gravatar.py)0
-rw-r--r--extensions/email-libravatar.lua (renamed from filters/email-libravatar.lua)0
-rw-r--r--extensions/file-authentication.lua (renamed from filters/file-authentication.lua)0
-rw-r--r--extensions/gentoo-ldap-authentication.lua (renamed from filters/gentoo-ldap-authentication.lua)0
-rwxr-xr-xextensions/html-converters/man2html (renamed from filters/html-converters/man2html)0
-rwxr-xr-xextensions/html-converters/md2html (renamed from filters/html-converters/md2html)0
-rwxr-xr-xextensions/html-converters/rst2html (renamed from filters/html-converters/rst2html)0
-rwxr-xr-xextensions/html-converters/txt2html (renamed from filters/html-converters/txt2html)0
-rw-r--r--extensions/owner-example.lua (renamed from filters/owner-example.lua)0
-rw-r--r--extensions/simple-authentication.lua (renamed from filters/simple-authentication.lua)0
-rwxr-xr-xextensions/syntax-highlighting.py (renamed from filters/syntax-highlighting.py)0
-rwxr-xr-xextensions/syntax-highlighting.sh (renamed from filters/syntax-highlighting.sh)0
-rwxr-xr-xgen-version.sh20
m---------libraries/git (renamed from git)0
-rw-r--r--source/cache.c (renamed from cache.c)0
-rw-r--r--source/cache.h (renamed from cache.h)0
-rw-r--r--source/cgit.c (renamed from cgit.c)0
-rw-r--r--source/cgit.h (renamed from cgit.h)0
-rw-r--r--source/cgit.mk (renamed from cgit.mk)61
-rw-r--r--source/cmd.c (renamed from cmd.c)0
-rw-r--r--source/cmd.h (renamed from cmd.h)0
-rw-r--r--source/configfile.c (renamed from configfile.c)0
-rw-r--r--source/configfile.h (renamed from configfile.h)0
-rw-r--r--source/filter.c (renamed from filter.c)0
-rwxr-xr-xsource/gen-version.sh25
-rw-r--r--source/html.c (renamed from html.c)0
-rw-r--r--source/html.h (renamed from html.h)0
-rw-r--r--source/parsing.c (renamed from parsing.c)0
-rw-r--r--source/scan-tree.c (renamed from scan-tree.c)0
-rw-r--r--source/scan-tree.h (renamed from scan-tree.h)0
-rw-r--r--source/shared.c (renamed from shared.c)0
-rw-r--r--source/ui-atom.c (renamed from ui-atom.c)0
-rw-r--r--source/ui-atom.h (renamed from ui-atom.h)0
-rw-r--r--source/ui-blame.c (renamed from ui-blame.c)0
-rw-r--r--source/ui-blame.h (renamed from ui-blame.h)0
-rw-r--r--source/ui-blob.c (renamed from ui-blob.c)0
-rw-r--r--source/ui-blob.h (renamed from ui-blob.h)0
-rw-r--r--source/ui-clone.c (renamed from ui-clone.c)0
-rw-r--r--source/ui-clone.h (renamed from ui-clone.h)0
-rw-r--r--source/ui-commit.c (renamed from ui-commit.c)0
-rw-r--r--source/ui-commit.h (renamed from ui-commit.h)0
-rw-r--r--source/ui-diff.c (renamed from ui-diff.c)0
-rw-r--r--source/ui-diff.h (renamed from ui-diff.h)0
-rw-r--r--source/ui-log.c (renamed from ui-log.c)0
-rw-r--r--source/ui-log.h (renamed from ui-log.h)0
-rw-r--r--source/ui-patch.c (renamed from ui-patch.c)0
-rw-r--r--source/ui-patch.h (renamed from ui-patch.h)0
-rw-r--r--source/ui-plain.c (renamed from ui-plain.c)0
-rw-r--r--source/ui-plain.h (renamed from ui-plain.h)0
-rw-r--r--source/ui-refs.c (renamed from ui-refs.c)0
-rw-r--r--source/ui-refs.h (renamed from ui-refs.h)0
-rw-r--r--source/ui-repolist.c (renamed from ui-repolist.c)0
-rw-r--r--source/ui-repolist.h (renamed from ui-repolist.h)0
-rw-r--r--source/ui-shared.c (renamed from ui-shared.c)0
-rw-r--r--source/ui-shared.h (renamed from ui-shared.h)0
-rw-r--r--source/ui-snapshot.c (renamed from ui-snapshot.c)0
-rw-r--r--source/ui-snapshot.h (renamed from ui-snapshot.h)0
-rw-r--r--source/ui-ssdiff.c (renamed from ui-ssdiff.c)0
-rw-r--r--source/ui-ssdiff.h (renamed from ui-ssdiff.h)0
-rw-r--r--source/ui-stats.c (renamed from ui-stats.c)0
-rw-r--r--source/ui-stats.h (renamed from ui-stats.h)0
-rw-r--r--source/ui-summary.c (renamed from ui-summary.c)0
-rw-r--r--source/ui-summary.h (renamed from ui-summary.h)0
-rw-r--r--source/ui-tag.c (renamed from ui-tag.c)0
-rw-r--r--source/ui-tag.h (renamed from ui-tag.h)0
-rw-r--r--source/ui-tree.c (renamed from ui-tree.c)0
-rw-r--r--source/ui-tree.h (renamed from ui-tree.h)0
-rw-r--r--tests/Makefile2
-rwxr-xr-xtests/setup.sh4
-rwxr-xr-xtests/t0001-validate-git-versions.sh10
-rwxr-xr-xtests/t0108-patch.sh4
-rwxr-xr-xtests/valgrind/bin/cgit2
85 files changed, 144 insertions, 143 deletions
diff --git a/.gitignore b/.gitignore
index 661df34..1d37751 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,12 +1,4 @@
-# Files I don't care to see in git-status/commit
-/cgit
+/build/
cgit.conf
-CGIT-CFLAGS
-VERSION
-cgitrc.5
-cgitrc.5.fo
-cgitrc.5.html
-cgitrc.5.pdf
-cgitrc.5.xml
-*.o
-*.d
+__pycache__/
+*.pyc
diff --git a/.gitmodules b/.gitmodules
index 5c6ecb4..a7ed44a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
[submodule "git"]
url = https://git.kernel.org/pub/scm/git/git.git
- path = git
+ path = libraries/git
diff --git a/Makefile b/Makefile
index 9d39bf4..efb6dc2 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
CGIT_CONFIG = /etc/cgitrc
CACHE_ROOT = /var/cache/cgit
+
prefix = /usr/local
libdir = $(prefix)/lib
filterdir = $(libdir)/cgit/filters
@@ -13,16 +14,32 @@ docdir = $(prefix)/share/doc/cgit
htmldir = $(docdir)
pdfdir = $(docdir)
mandir = $(prefix)/share/man
+
SHA1_HEADER = <openssl/sha.h>
GIT_VER = 2.54.0
GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz
+
INSTALL = install
COPYTREE = cp -r
+
+# Project layout. Sources live in source/, web assets in assets/, the bundled
+# Git tree in libraries/git, and every generated file lands in build/.
+SRCDIR = source
+ASSETDIR = assets
+GITDIR = libraries/git
+BUILDDIR = build
+
+# The bundled Git tree is two levels down, so the sub-make reaches back to the
+# project root with "../../".
+TO_ROOT = ../../
+
+# Documentation. The man-page source (*.5.txt) sits at the project root and is
+# rendered into build/.
MAN5_TXT = $(wildcard *.5.txt)
MAN_TXT = $(MAN5_TXT)
-DOC_MAN5 = $(patsubst %.txt,%,$(MAN5_TXT))
-DOC_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
-DOC_PDF = $(patsubst %.txt,%.pdf,$(MAN_TXT))
+DOC_MAN5 = $(patsubst %.txt,$(BUILDDIR)/%,$(MAN5_TXT))
+DOC_HTML = $(patsubst %.txt,$(BUILDDIR)/%.html,$(MAN_TXT))
+DOC_PDF = $(patsubst %.txt,$(BUILDDIR)/%.pdf,$(MAN_TXT))
ASCIIDOC = asciidoc
ASCIIDOC_EXTRA =
@@ -30,69 +47,46 @@ ASCIIDOC_HTML = xhtml11
ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA)
TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
-# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
-# do not support the 'size specifiers' introduced by C99, namely ll, hh,
-# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
-# some C compilers supported these specifiers prior to C99 as an extension.
-#
-# Define HAVE_LINUX_SENDFILE to use sendfile()
-
-#-include config.mak
-
--include git/config.mak.uname
-#
-# Let the user override the above settings.
-#
+# Reuse Git's platform detection, then let the user override the settings
+# above through cgit.conf.
+-include $(GITDIR)/config.mak.uname
-include cgit.conf
export CGIT_VERSION CGIT_SCRIPT_NAME CGIT_SCRIPT_PATH CGIT_DATA_PATH CGIT_CONFIG CACHE_ROOT
-#
-# Define a way to invoke make in subdirs quietly, shamelessly ripped
-# from git.git
-#
-QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
-QUIET_SUBDIR1 =
-
-ifneq ($(findstring w,$(MAKEFLAGS)),w)
-PRINT_DIR = --no-print-directory
-else # "make -w"
-NO_SUBDIR = :
-endif
-
-ifndef V
- QUIET_SUBDIR0 = +@subdir=
- QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
- $(MAKE) $(PRINT_DIR) -C $$subdir
- QUIET_TAGS = @echo ' ' TAGS $@;
- export V
-endif
-
.SUFFIXES:
all:: cgit
+# cgit is compiled inside the bundled Git tree so it can reuse Git's build
+# machinery (see source/cgit.mk). Objects and the binary go to build/.
cgit:
- $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) -f ../cgit.mk ../cgit $(EXTRA_GIT_TARGETS) NO_CURL=1
+ +@$(MAKE) -C $(GITDIR) -f $(TO_ROOT)$(SRCDIR)/cgit.mk \
+ $(TO_ROOT)$(BUILDDIR)/cgit $(EXTRA_GIT_TARGETS) NO_CURL=1
sparse:
- $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) -f ../cgit.mk NO_CURL=1 cgit-sparse
+ +@$(MAKE) -C $(GITDIR) -f $(TO_ROOT)$(SRCDIR)/cgit.mk \
+ NO_CURL=1 cgit-sparse
+
+# Building the test suite needs a fully built Git tree for its helpers, hence
+# EXTRA_GIT_TARGETS=all.
+test: cgit-with-git
+ +@$(MAKE) -C tests all
-test:
- @$(MAKE) --no-print-directory cgit EXTRA_GIT_TARGETS=all
- $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all
+cgit-with-git:
+ +@$(MAKE) cgit EXTRA_GIT_TARGETS=all
install: all
$(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_SCRIPT_PATH)
- $(INSTALL) -m 0755 cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
+ $(INSTALL) -m 0755 $(BUILDDIR)/cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
$(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_DATA_PATH)
- $(INSTALL) -m 0644 cgit.css $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css
- $(INSTALL) -m 0644 cgit.js $(DESTDIR)$(CGIT_DATA_PATH)/cgit.js
- $(INSTALL) -m 0644 cgit.png $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png
- $(INSTALL) -m 0644 favicon.ico $(DESTDIR)$(CGIT_DATA_PATH)/favicon.ico
- $(INSTALL) -m 0644 robots.txt $(DESTDIR)$(CGIT_DATA_PATH)/robots.txt
+ $(INSTALL) -m 0644 $(ASSETDIR)/cgit.css $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css
+ $(INSTALL) -m 0644 $(ASSETDIR)/cgit.js $(DESTDIR)$(CGIT_DATA_PATH)/cgit.js
+ $(INSTALL) -m 0644 $(ASSETDIR)/cgit.png $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png
+ $(INSTALL) -m 0644 $(ASSETDIR)/favicon.ico $(DESTDIR)$(CGIT_DATA_PATH)/favicon.ico
+ $(INSTALL) -m 0644 $(ASSETDIR)/robots.txt $(DESTDIR)$(CGIT_DATA_PATH)/robots.txt
$(INSTALL) -m 0755 -d $(DESTDIR)$(filterdir)
- $(COPYTREE) filters/* $(DESTDIR)$(filterdir)
+ $(COPYTREE) extensions/* $(DESTDIR)$(filterdir)
install-doc: install-man install-html install-pdf
@@ -120,23 +114,23 @@ uninstall:
rm -f $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png
rm -f $(DESTDIR)$(CGIT_DATA_PATH)/favicon.ico
rm -f $(DESTDIR)$(CGIT_DATA_PATH)/robots.txt
- $(foreach file,$(patsubst filters/%,%,$(shell find filters/ ! -type d)), \
+ $(foreach file,$(patsubst extensions/%,%,$(shell find extensions/ ! -type d)), \
$(call rm_f,$(DESTDIR)$(filterdir)/$(file)))
uninstall-doc: uninstall-man uninstall-html uninstall-pdf
uninstall-man:
- @for i in $(DOC_MAN5); do \
+ @for i in $(notdir $(DOC_MAN5)); do \
rm -fv $(DESTDIR)$(mandir)/man5/$$i; \
done
uninstall-html:
- @for i in $(DOC_HTML); do \
+ @for i in $(notdir $(DOC_HTML)); do \
rm -fv $(DESTDIR)$(htmldir)/$$i; \
done
uninstall-pdf:
- @for i in $(DOC_PDF); do \
+ @for i in $(notdir $(DOC_PDF)); do \
rm -fv $(DESTDIR)$(pdfdir)/$$i; \
done
@@ -146,35 +140,36 @@ doc-man5: $(DOC_MAN5)
doc-html: $(DOC_HTML)
doc-pdf: $(DOC_PDF)
-%.5 : %.5.txt
- a2x -f manpage $<
+$(DOC_MAN5): $(BUILDDIR)/%.5 : %.5.txt
+ @mkdir -p $(BUILDDIR)
+ a2x -f manpage -D $(BUILDDIR) $<
-$(DOC_HTML): %.html : %.txt
- $(TXT_TO_HTML) -o $@+ $< && \
- mv $@+ $@
+$(DOC_HTML): $(BUILDDIR)/%.html : %.txt
+ @mkdir -p $(BUILDDIR)
+ $(TXT_TO_HTML) -o $@ $<
-$(DOC_PDF): %.pdf : %.txt
- a2x -f pdf cgitrc.5.txt
+$(DOC_PDF): $(BUILDDIR)/%.pdf : %.txt
+ @mkdir -p $(BUILDDIR)
+ a2x -f pdf -D $(BUILDDIR) $<
-clean: clean-doc
- $(RM) cgit VERSION CGIT-CFLAGS *.o tags
- $(RM) -r .deps
+# Everything generated lives under build/, so cleaning is a single remove.
+clean:
+ $(RM) -r $(BUILDDIR)
cleanall: clean
- $(MAKE) -C git clean
-
-clean-doc:
- $(RM) cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo
+ @if test -e $(GITDIR)/Makefile; then $(MAKE) -C $(GITDIR) clean; fi
+# Fetch a Git release tarball for builds without the submodule checked out.
get-git:
- curl -L $(GIT_URL) | tar -xJf - && rm -rf git && mv git-$(GIT_VER) git
+ mkdir -p $(dir $(GITDIR))
+ curl -L $(GIT_URL) | tar -xJf - && rm -rf $(GITDIR) && mv git-$(GIT_VER) $(GITDIR)
tags:
- $(QUIET_TAGS)find . -name '*.[ch]' | xargs ctags
+ @mkdir -p $(BUILDDIR)
+ find $(SRCDIR) -name '*.[ch]' | xargs ctags -f $(BUILDDIR)/tags
-.PHONY: all cgit git get-git
-.PHONY: clean clean-doc cleanall
-.PHONY: doc doc-html doc-man doc-pdf
+.PHONY: all cgit cgit-with-git sparse test get-git tags
+.PHONY: clean cleanall
+.PHONY: doc doc-html doc-man doc-man5 doc-pdf
.PHONY: install install-doc install-html install-man install-pdf
-.PHONY: tags test
.PHONY: uninstall uninstall-doc uninstall-html uninstall-man uninstall-pdf
diff --git a/cgit.css b/assets/cgit.css
index d10a24d..d10a24d 100644
--- a/cgit.css
+++ b/assets/cgit.css
diff --git a/cgit.js b/assets/cgit.js
index df3ad4e..df3ad4e 100644
--- a/cgit.js
+++ b/assets/cgit.js
diff --git a/cgit.png b/assets/cgit.png
index 425528e..425528e 100644
--- a/cgit.png
+++ b/assets/cgit.png
Binary files differ
diff --git a/favicon.ico b/assets/favicon.ico
index 56ff593..56ff593 100644
--- a/favicon.ico
+++ b/assets/favicon.ico
Binary files differ
diff --git a/robots.txt b/assets/robots.txt
index 1b33266..1b33266 100644
--- a/robots.txt
+++ b/assets/robots.txt
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 7c39bf9..7a0cf03 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -707,7 +707,7 @@ auth filter::
with a 302 redirect, and write to output one or more "Set-Cookie"
HTTP headers, each followed by a newline.
- Please see `filters/simple-authentication.lua` for a clear example
+ Please see `extensions/simple-authentication.lua` for a clear example
script that may be modified.
commit filter::
diff --git a/contrib/hooks/post-receive.agefile b/examples/hooks/post-receive.agefile
index 2f72ae9..2f72ae9 100755
--- a/contrib/hooks/post-receive.agefile
+++ b/examples/hooks/post-receive.agefile
diff --git a/filters/about-formatting.sh b/extensions/about-formatting.sh
index 85daf9c..85daf9c 100755
--- a/filters/about-formatting.sh
+++ b/extensions/about-formatting.sh
diff --git a/filters/commit-links.sh b/extensions/commit-links.sh
index 796ac30..796ac30 100755
--- a/filters/commit-links.sh
+++ b/extensions/commit-links.sh
diff --git a/filters/email-gravatar.lua b/extensions/email-gravatar.lua
index c39b490..c39b490 100644
--- a/filters/email-gravatar.lua
+++ b/extensions/email-gravatar.lua
diff --git a/filters/email-gravatar.py b/extensions/email-gravatar.py
index d70440e..d70440e 100755
--- a/filters/email-gravatar.py
+++ b/extensions/email-gravatar.py
diff --git a/filters/email-libravatar.lua b/extensions/email-libravatar.lua
index 7336baf..7336baf 100644
--- a/filters/email-libravatar.lua
+++ b/extensions/email-libravatar.lua
diff --git a/filters/file-authentication.lua b/extensions/file-authentication.lua
index 0248804..0248804 100644
--- a/filters/file-authentication.lua
+++ b/extensions/file-authentication.lua
diff --git a/filters/gentoo-ldap-authentication.lua b/extensions/gentoo-ldap-authentication.lua
index 673c88d..673c88d 100644
--- a/filters/gentoo-ldap-authentication.lua
+++ b/extensions/gentoo-ldap-authentication.lua
diff --git a/filters/html-converters/man2html b/extensions/html-converters/man2html
index 0ef7884..0ef7884 100755
--- a/filters/html-converters/man2html
+++ b/extensions/html-converters/man2html
diff --git a/filters/html-converters/md2html b/extensions/html-converters/md2html
index 59f43a8..59f43a8 100755
--- a/filters/html-converters/md2html
+++ b/extensions/html-converters/md2html
diff --git a/filters/html-converters/rst2html b/extensions/html-converters/rst2html
index 02d90f8..02d90f8 100755
--- a/filters/html-converters/rst2html
+++ b/extensions/html-converters/rst2html
diff --git a/filters/html-converters/txt2html b/extensions/html-converters/txt2html
index 495eece..495eece 100755
--- a/filters/html-converters/txt2html
+++ b/extensions/html-converters/txt2html
diff --git a/filters/owner-example.lua b/extensions/owner-example.lua
index 50fc25a..50fc25a 100644
--- a/filters/owner-example.lua
+++ b/extensions/owner-example.lua
diff --git a/filters/simple-authentication.lua b/extensions/simple-authentication.lua
index 23d3457..23d3457 100644
--- a/filters/simple-authentication.lua
+++ b/extensions/simple-authentication.lua
diff --git a/filters/syntax-highlighting.py b/extensions/syntax-highlighting.py
index e912594..e912594 100755
--- a/filters/syntax-highlighting.py
+++ b/extensions/syntax-highlighting.py
diff --git a/filters/syntax-highlighting.sh b/extensions/syntax-highlighting.sh
index 840bc34..840bc34 100755
--- a/filters/syntax-highlighting.sh
+++ b/extensions/syntax-highlighting.sh
diff --git a/gen-version.sh b/gen-version.sh
deleted file mode 100755
index 80cf49a..0000000
--- a/gen-version.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-
-# Get version-info specified in Makefile
-V=$1
-
-# Use `git describe` to get current version if we're inside a git repo
-if test "$(git rev-parse --git-dir 2>/dev/null)" = '.git'
-then
- V=$(git describe --abbrev=4 HEAD 2>/dev/null)
-fi
-
-new="CGIT_VERSION = $V"
-old=$(cat VERSION 2>/dev/null)
-
-# Exit if VERSION is uptodate
-test "$old" = "$new" && exit 0
-
-# Update VERSION with new version-info
-echo "$new" > VERSION
-cat VERSION
diff --git a/git b/libraries/git
-Subproject 94f057755b7941b321fd11fec1b2e3ca5313a4e0
+Subproject 94f057755b7941b321fd11fec1b2e3ca5313a4e0
diff --git a/cache.c b/source/cache.c
index e70af13..e70af13 100644
--- a/cache.c
+++ b/source/cache.c
diff --git a/cache.h b/source/cache.h
index 470da4f..470da4f 100644
--- a/cache.h
+++ b/source/cache.h
diff --git a/cgit.c b/source/cgit.c
index ca318e8..ca318e8 100644
--- a/cgit.c
+++ b/source/cgit.c
diff --git a/cgit.h b/source/cgit.h
index 7d7ece7..7d7ece7 100644
--- a/cgit.h
+++ b/source/cgit.h
diff --git a/cgit.mk b/source/cgit.mk
index 3fcc1ca..d012349 100644
--- a/cgit.mk
+++ b/source/cgit.mk
@@ -1,22 +1,30 @@
-# This Makefile is run in the "git" directory in order to re-use Git's
-# build variables and operating system detection. Hence all files in
-# CGit's directory must be prefixed with "../".
+# This Makefile runs inside the bundled Git tree (libraries/git) so that it
+# can reuse Git's build variables and platform detection. The top-level
+# Makefile invokes it as:
+#
+# make -C libraries/git -f ../../source/cgit.mk ../../build/cgit
+#
+# so every path back into the project is prefixed with "../../": sources come
+# from ../../source and all build output goes to ../../build.
include Makefile
-CGIT_PREFIX = ../
+# Locations relative to libraries/git, where this file is run.
+CGIT_PREFIX = ../../
+CGIT_SRC = $(CGIT_PREFIX)source/
+CGIT_BUILD = $(CGIT_PREFIX)build/
-include $(CGIT_PREFIX)cgit.conf
-# The CGIT_* variables are inherited when this file is called from the
-# main Makefile - they are defined there.
+# The CGIT_* variables are inherited from the top-level Makefile.
-$(CGIT_PREFIX)VERSION: force-version
- @cd $(CGIT_PREFIX) && '$(SHELL_PATH_SQ)' ./gen-version.sh "$(CGIT_VERSION)"
--include $(CGIT_PREFIX)VERSION
+$(CGIT_BUILD)VERSION: force-version
+ @mkdir -p $(CGIT_BUILD)
+ @cd $(CGIT_PREFIX) && '$(SHELL_PATH_SQ)' source/gen-version.sh "$(CGIT_VERSION)" build/VERSION
+-include $(CGIT_BUILD)VERSION
.PHONY: force-version
-# CGIT_CFLAGS is a separate variable so that we can track it separately
-# and avoid rebuilding all of Git when these variables change.
+# CGIT_CFLAGS is tracked separately so that changing it does not force a
+# rebuild of Git itself.
CGIT_CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"'
CGIT_CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"'
CGIT_CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"'
@@ -95,16 +103,16 @@ CGIT_OBJ_NAMES += ui-summary.o
CGIT_OBJ_NAMES += ui-tag.o
CGIT_OBJ_NAMES += ui-tree.o
-CGIT_OBJS := $(addprefix $(CGIT_PREFIX),$(CGIT_OBJ_NAMES))
+CGIT_OBJS := $(addprefix $(CGIT_BUILD),$(CGIT_OBJ_NAMES))
-# Only cgit.c reference CGIT_VERSION so we only rebuild its objects when the
+# Only cgit.c references CGIT_VERSION, so only its objects rebuild when the
# version changes.
-CGIT_VERSION_OBJS := $(addprefix $(CGIT_PREFIX),cgit.o cgit.sp)
-$(CGIT_VERSION_OBJS): $(CGIT_PREFIX)VERSION
+CGIT_VERSION_OBJS := $(addprefix $(CGIT_BUILD),cgit.o cgit.sp)
+$(CGIT_VERSION_OBJS): $(CGIT_BUILD)VERSION
$(CGIT_VERSION_OBJS): EXTRA_CPPFLAGS = \
-DCGIT_VERSION='"$(CGIT_VERSION)"'
-# Git handles dependencies using ":=" so dependencies in CGIT_OBJ are not
+# Git handles dependencies using ":=" so dependencies in CGIT_OBJS are not
# handled by that and we must handle them ourselves.
cgit_dep_files := $(foreach f,$(CGIT_OBJS),$(dir $f).depend/$(notdir $f).d)
cgit_dep_files_present := $(wildcard $(cgit_dep_files))
@@ -112,30 +120,31 @@ ifneq ($(cgit_dep_files_present),)
include $(cgit_dep_files_present)
endif
-ifeq ($(wildcard $(CGIT_PREFIX).depend),)
-missing_dep_dirs += $(CGIT_PREFIX).depend
+ifeq ($(wildcard $(CGIT_BUILD).depend),)
+missing_dep_dirs += $(CGIT_BUILD).depend
endif
-$(CGIT_PREFIX).depend:
+$(CGIT_BUILD).depend:
@mkdir -p $@
-$(CGIT_PREFIX)CGIT-CFLAGS: FORCE
+$(CGIT_BUILD)CGIT-CFLAGS: FORCE
+ @mkdir -p $(CGIT_BUILD)
@FLAGS='$(subst ','\'',$(CGIT_CFLAGS))'; \
- if test x"$$FLAGS" != x"`cat ../CGIT-CFLAGS 2>/dev/null`" ; then \
+ if test x"$$FLAGS" != x"`cat $(CGIT_BUILD)CGIT-CFLAGS 2>/dev/null`" ; then \
echo 1>&2 " * new CGit build flags"; \
- echo "$$FLAGS" >$(CGIT_PREFIX)CGIT-CFLAGS; \
+ echo "$$FLAGS" >$(CGIT_BUILD)CGIT-CFLAGS; \
fi
-$(CGIT_OBJS): %.o: %.c GIT-CFLAGS $(CGIT_PREFIX)CGIT-CFLAGS $(missing_dep_dirs)
- $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $(CGIT_CFLAGS) $<
+$(CGIT_OBJS): $(CGIT_BUILD)%.o: $(CGIT_SRC)%.c GIT-CFLAGS $(CGIT_BUILD)CGIT-CFLAGS $(missing_dep_dirs)
+ $(QUIET_CC)$(CC) -o $@ -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $(CGIT_CFLAGS) $<
-$(CGIT_PREFIX)cgit: $(CGIT_OBJS) GIT-LDFLAGS $(GITLIBS)
+$(CGIT_BUILD)cgit: $(CGIT_OBJS) GIT-LDFLAGS $(GITLIBS)
@echo 1>&1 " * $(LUA_MESSAGE)"
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) $(CGIT_LIBS)
CGIT_SP_OBJS := $(patsubst %.o,%.sp,$(CGIT_OBJS))
-$(CGIT_SP_OBJS): %.sp: %.c GIT-CFLAGS $(CGIT_PREFIX)CGIT-CFLAGS FORCE
+$(CGIT_SP_OBJS): $(CGIT_BUILD)%.sp: $(CGIT_SRC)%.c GIT-CFLAGS $(CGIT_BUILD)CGIT-CFLAGS FORCE
$(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $(CGIT_CFLAGS) $(SPARSE_FLAGS) $<
cgit-sparse: $(CGIT_SP_OBJS)
diff --git a/cmd.c b/source/cmd.c
index 0eb75b1..0eb75b1 100644
--- a/cmd.c
+++ b/source/cmd.c
diff --git a/cmd.h b/source/cmd.h
index 6249b1d..6249b1d 100644
--- a/cmd.h
+++ b/source/cmd.h
diff --git a/configfile.c b/source/configfile.c
index e039109..e039109 100644
--- a/configfile.c
+++ b/source/configfile.c
diff --git a/configfile.h b/source/configfile.h
index af7ca19..af7ca19 100644
--- a/configfile.h
+++ b/source/configfile.h
diff --git a/filter.c b/source/filter.c
index c778d05..c778d05 100644
--- a/filter.c
+++ b/source/filter.c
diff --git a/source/gen-version.sh b/source/gen-version.sh
new file mode 100755
index 0000000..23d0d0b
--- /dev/null
+++ b/source/gen-version.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# Writes a "CGIT_VERSION = ..." line to the output file (default: VERSION),
+# for the build to include. Run from the project root so `git describe` acts
+# on cgit rather than the bundled Git submodule.
+#
+# Usage: gen-version.sh <fallback-version> [output-file]
+
+V=$1
+OUT=${2:-VERSION}
+
+# Prefer `git describe` when run at the top of the cgit working tree.
+if test "$(git rev-parse --git-dir 2>/dev/null)" = '.git'
+then
+ V=$(git describe --abbrev=4 HEAD 2>/dev/null)
+fi
+
+new="CGIT_VERSION = $V"
+old=$(cat "$OUT" 2>/dev/null)
+
+# Exit if the version is already up to date.
+test "$old" = "$new" && exit 0
+
+echo "$new" > "$OUT"
+cat "$OUT"
diff --git a/html.c b/source/html.c
index 0bac34b..0bac34b 100644
--- a/html.c
+++ b/source/html.c
diff --git a/html.h b/source/html.h
index fa4de77..fa4de77 100644
--- a/html.h
+++ b/source/html.h
diff --git a/parsing.c b/source/parsing.c
index bdaed25..bdaed25 100644
--- a/parsing.c
+++ b/source/parsing.c
diff --git a/scan-tree.c b/source/scan-tree.c
index c120efe..c120efe 100644
--- a/scan-tree.c
+++ b/source/scan-tree.c
diff --git a/scan-tree.h b/source/scan-tree.h
index def0a7a..def0a7a 100644
--- a/scan-tree.h
+++ b/source/scan-tree.h
diff --git a/shared.c b/source/shared.c
index a39394d..a39394d 100644
--- a/shared.c
+++ b/source/shared.c
diff --git a/ui-atom.c b/source/ui-atom.c
index 0659e96..0659e96 100644
--- a/ui-atom.c
+++ b/source/ui-atom.c
diff --git a/ui-atom.h b/source/ui-atom.h
index dda953b..dda953b 100644
--- a/ui-atom.h
+++ b/source/ui-atom.h
diff --git a/ui-blame.c b/source/ui-blame.c
index 5c6f36e..5c6f36e 100644
--- a/ui-blame.c
+++ b/source/ui-blame.c
diff --git a/ui-blame.h b/source/ui-blame.h
index 5b97e03..5b97e03 100644
--- a/ui-blame.h
+++ b/source/ui-blame.h
diff --git a/ui-blob.c b/source/ui-blob.c
index bc91656..bc91656 100644
--- a/ui-blob.c
+++ b/source/ui-blob.c
diff --git a/ui-blob.h b/source/ui-blob.h
index 16847b2..16847b2 100644
--- a/ui-blob.h
+++ b/source/ui-blob.h
diff --git a/ui-clone.c b/source/ui-clone.c
index e11f496..e11f496 100644
--- a/ui-clone.c
+++ b/source/ui-clone.c
diff --git a/ui-clone.h b/source/ui-clone.h
index 3e460a3..3e460a3 100644
--- a/ui-clone.h
+++ b/source/ui-clone.h
diff --git a/ui-commit.c b/source/ui-commit.c
index 972e9bc..972e9bc 100644
--- a/ui-commit.c
+++ b/source/ui-commit.c
diff --git a/ui-commit.h b/source/ui-commit.h
index 8198b4b..8198b4b 100644
--- a/ui-commit.h
+++ b/source/ui-commit.h
diff --git a/ui-diff.c b/source/ui-diff.c
index 6cfa697..6cfa697 100644
--- a/ui-diff.c
+++ b/source/ui-diff.c
diff --git a/ui-diff.h b/source/ui-diff.h
index 39264a1..39264a1 100644
--- a/ui-diff.h
+++ b/source/ui-diff.h
diff --git a/ui-log.c b/source/ui-log.c
index 9906bbc..9906bbc 100644
--- a/ui-log.c
+++ b/source/ui-log.c
diff --git a/ui-log.h b/source/ui-log.h
index 325607c..325607c 100644
--- a/ui-log.h
+++ b/source/ui-log.h
diff --git a/ui-patch.c b/source/ui-patch.c
index f9d2eeb..f9d2eeb 100644
--- a/ui-patch.c
+++ b/source/ui-patch.c
diff --git a/ui-patch.h b/source/ui-patch.h
index 7a6cacd..7a6cacd 100644
--- a/ui-patch.h
+++ b/source/ui-patch.h
diff --git a/ui-plain.c b/source/ui-plain.c
index a2a4087..a2a4087 100644
--- a/ui-plain.c
+++ b/source/ui-plain.c
diff --git a/ui-plain.h b/source/ui-plain.h
index 5bff07b..5bff07b 100644
--- a/ui-plain.h
+++ b/source/ui-plain.h
diff --git a/ui-refs.c b/source/ui-refs.c
index 11fb9fc..11fb9fc 100644
--- a/ui-refs.c
+++ b/source/ui-refs.c
diff --git a/ui-refs.h b/source/ui-refs.h
index 1d4a54a..1d4a54a 100644
--- a/ui-refs.h
+++ b/source/ui-refs.h
diff --git a/ui-repolist.c b/source/ui-repolist.c
index 1b224cf..1b224cf 100644
--- a/ui-repolist.c
+++ b/source/ui-repolist.c
diff --git a/ui-repolist.h b/source/ui-repolist.h
index 1b6b322..1b6b322 100644
--- a/ui-repolist.h
+++ b/source/ui-repolist.h
diff --git a/ui-shared.c b/source/ui-shared.c
index df52a9b..df52a9b 100644
--- a/ui-shared.c
+++ b/source/ui-shared.c
diff --git a/ui-shared.h b/source/ui-shared.h
index 2a3a7f5..2a3a7f5 100644
--- a/ui-shared.h
+++ b/source/ui-shared.h
diff --git a/ui-snapshot.c b/source/ui-snapshot.c
index d157222..d157222 100644
--- a/ui-snapshot.c
+++ b/source/ui-snapshot.c
diff --git a/ui-snapshot.h b/source/ui-snapshot.h
index a8deec3..a8deec3 100644
--- a/ui-snapshot.h
+++ b/source/ui-snapshot.h
diff --git a/ui-ssdiff.c b/source/ui-ssdiff.c
index af8bc9e..af8bc9e 100644
--- a/ui-ssdiff.c
+++ b/source/ui-ssdiff.c
diff --git a/ui-ssdiff.h b/source/ui-ssdiff.h
index 11f2714..11f2714 100644
--- a/ui-ssdiff.h
+++ b/source/ui-ssdiff.h
diff --git a/ui-stats.c b/source/ui-stats.c
index 02c60ef..02c60ef 100644
--- a/ui-stats.c
+++ b/source/ui-stats.c
diff --git a/ui-stats.h b/source/ui-stats.h
index 0e61b03..0e61b03 100644
--- a/ui-stats.h
+++ b/source/ui-stats.h
diff --git a/ui-summary.c b/source/ui-summary.c
index 947812a..947812a 100644
--- a/ui-summary.c
+++ b/source/ui-summary.c
diff --git a/ui-summary.h b/source/ui-summary.h
index cba696a..cba696a 100644
--- a/ui-summary.h
+++ b/source/ui-summary.h
diff --git a/ui-tag.c b/source/ui-tag.c
index 8f58f14..8f58f14 100644
--- a/ui-tag.c
+++ b/source/ui-tag.c
diff --git a/ui-tag.h b/source/ui-tag.h
index d295cdc..d295cdc 100644
--- a/ui-tag.h
+++ b/source/ui-tag.h
diff --git a/ui-tree.c b/source/ui-tree.c
index 5ac8c9a..5ac8c9a 100644
--- a/ui-tree.c
+++ b/source/ui-tree.c
diff --git a/ui-tree.h b/source/ui-tree.h
index bbd34e3..bbd34e3 100644
--- a/ui-tree.h
+++ b/source/ui-tree.h
diff --git a/tests/Makefile b/tests/Makefile
index 65e1117..38df21d 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,4 +1,4 @@
-include ../git/config.mak.uname
+include ../libraries/git/config.mak.uname
-include ../cgit.conf
SHELL_PATH ?= $(SHELL)
diff --git a/tests/setup.sh b/tests/setup.sh
index 8db810f..db5361c 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -42,7 +42,7 @@ IFS=$LF
set -- $test_argv
IFS=$OLDIFS
-: ${TEST_DIRECTORY=$(pwd)/../git/t}
+: ${TEST_DIRECTORY=$(pwd)/../libraries/git/t}
: ${TEST_OUTPUT_DIRECTORY=$(pwd)}
TEST_NO_CREATE_REPO=YesPlease
. "$TEST_DIRECTORY"/test-lib.sh
@@ -55,7 +55,7 @@ then
PATH="$CGIT_VALGRIND/bin:$PATH"
export GIT_VALGRIND CGIT_VALGRIND
else
- PATH="$(pwd)/../..:$PATH"
+ PATH="$(pwd)/../../build:$PATH"
fi
FILTER_DIRECTORY=$(cd ../filters && pwd)
diff --git a/tests/t0001-validate-git-versions.sh b/tests/t0001-validate-git-versions.sh
index dd84fe3..79699fd 100755
--- a/tests/t0001-validate-git-versions.sh
+++ b/tests/t0001-validate-git-versions.sh
@@ -20,22 +20,22 @@ test_expect_success 'extract Git version from Makefile' '
# must apply the same transformation to the version in the Makefile before
# comparing them.
test_expect_success 'test Git version matches Makefile' '
- ( cat ../../git/GIT-VERSION-FILE || echo "No GIT-VERSION-FILE" ) |
+ ( cat ../../libraries/git/GIT-VERSION-FILE || echo "No GIT-VERSION-FILE" ) |
sed -e "s/GIT_VERSION[ ]*=[ ]*//" -e "s/\\.dirty$//" >git_version &&
sed -e "s/-/./g" makefile_version >makefile_git_version &&
test_cmp git_version makefile_git_version
'
test_expect_success 'test submodule version matches Makefile' '
- if ! test -e ../../git/.git
+ if ! test -e ../../libraries/git/.git
then
- echo "git/ is not a Git repository" >&2
+ echo "libraries/git/ is not a Git repository" >&2
else
(
cd ../.. &&
- sm_oid=$(git ls-files --stage -- git |
+ sm_oid=$(git ls-files --stage -- libraries/git |
sed -e "s/^[0-9]* \\([0-9a-f]*\\) [0-9] .*$/\\1/") &&
- cd git &&
+ cd libraries/git &&
git describe --match "v[0-9]*" $sm_oid
) | sed -e "s/^v//" -e "s/-/./" >sm_version &&
test_cmp sm_version makefile_version
diff --git a/tests/t0108-patch.sh b/tests/t0108-patch.sh
index 013d680..18973bb 100755
--- a/tests/t0108-patch.sh
+++ b/tests/t0108-patch.sh
@@ -24,7 +24,7 @@ test_expect_success 'find `cgit` signature' '
'
test_expect_success 'compare with output of git-format-patch(1)' '
- CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" ../../VERSION) &&
+ CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" ../../build/VERSION) &&
git --git-dir="$PWD/repos/foo/.git" format-patch --subject-prefix="" --signature="cgit $CGIT_VERSION" --stdout HEAD^ >tmp2 &&
strip_headers <tmp >tmp_ &&
test_cmp tmp_ tmp2
@@ -53,7 +53,7 @@ test_expect_success 'find `cgit` signature' '
'
test_expect_success 'compare with output of git-format-patch(1)' '
- CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" ../../VERSION) &&
+ CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" ../../build/VERSION) &&
git --git-dir="$PWD/repos/foo/.git" format-patch -N --subject-prefix="" --signature="cgit $CGIT_VERSION" --stdout HEAD~3..HEAD >tmp2 &&
strip_headers <tmp >tmp_ &&
test_cmp tmp_ tmp2
diff --git a/tests/valgrind/bin/cgit b/tests/valgrind/bin/cgit
index dcdfbe5..56ca807 100755
--- a/tests/valgrind/bin/cgit
+++ b/tests/valgrind/bin/cgit
@@ -9,4 +9,4 @@ exec valgrind -q --error-exitcode=126 \
--track-origins=yes \
--log-fd=4 \
--input-fd=4 \
- "$CGIT_VALGRIND/../../cgit" "$@"
+ "$CGIT_VALGRIND/../../build/cgit" "$@"