diff options
Diffstat (limited to 'templates')
-rw-r--r-- | templates/.gitignore | 2 | ||||
-rw-r--r-- | templates/Makefile | 46 | ||||
-rw-r--r-- | templates/branches-- | 1 | ||||
-rw-r--r-- | templates/hooks--applypatch-msg | 15 | ||||
-rw-r--r-- | templates/hooks--commit-msg | 14 | ||||
-rw-r--r-- | templates/hooks--post-commit | 8 | ||||
-rw-r--r-- | templates/hooks--post-update | 8 | ||||
-rw-r--r-- | templates/hooks--pre-applypatch | 15 | ||||
-rw-r--r-- | templates/hooks--pre-commit | 71 | ||||
-rw-r--r-- | templates/hooks--pre-rebase | 150 | ||||
-rw-r--r-- | templates/hooks--update | 89 | ||||
-rw-r--r-- | templates/info--exclude | 6 | ||||
-rw-r--r-- | templates/remotes-- | 1 | ||||
-rw-r--r-- | templates/this--description | 1 |
14 files changed, 427 insertions, 0 deletions
diff --git a/templates/.gitignore b/templates/.gitignore new file mode 100644 index 0000000000..6759ecbf98 --- /dev/null +++ b/templates/.gitignore @@ -0,0 +1,2 @@ +blt +boilerplates.made diff --git a/templates/Makefile b/templates/Makefile new file mode 100644 index 0000000000..9e1ae1a4e0 --- /dev/null +++ b/templates/Makefile @@ -0,0 +1,46 @@ +# make and install sample templates + +INSTALL ?= install +TAR ?= tar +prefix ?= $(HOME) +template_dir ?= $(prefix)/share/git-core/templates/ +# DESTDIR= + +# Shell quote (do not use $(call) to accomodate ancient setups); +DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) +template_dir_SQ = $(subst ','\'',$(template_dir)) + +all: boilerplates.made custom + +# 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. + +bpsrc = $(filter-out %~,$(wildcard *--*)) +boilerplates.made : $(bpsrc) + 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 + date >$@ + +# If you need build-tailored templates, build them into blt/ +# directory yourself here. +custom: + : no custom templates yet + +clean: + rm -rf blt boilerplates.made + +install: all + $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(template_dir_SQ)' + (cd blt && $(TAR) cf - .) | \ + (cd '$(DESTDIR_SQ)$(template_dir_SQ)' && $(TAR) xf -) diff --git a/templates/branches-- b/templates/branches-- new file mode 100644 index 0000000000..fae88709a6 --- /dev/null +++ b/templates/branches-- @@ -0,0 +1 @@ +: this is just to ensure the directory exists. diff --git a/templates/hooks--applypatch-msg b/templates/hooks--applypatch-msg new file mode 100644 index 0000000000..02de1ef84c --- /dev/null +++ b/templates/hooks--applypatch-msg @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, make this file executable. + +. git-sh-setup +test -x "$GIT_DIR/hooks/commit-msg" && + exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} +: diff --git a/templates/hooks--commit-msg b/templates/hooks--commit-msg new file mode 100644 index 0000000000..643822d235 --- /dev/null +++ b/templates/hooks--commit-msg @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by git-commit with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, make this file executable. + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1 /d')" diff --git a/templates/hooks--post-commit b/templates/hooks--post-commit new file mode 100644 index 0000000000..8be6f34ad9 --- /dev/null +++ b/templates/hooks--post-commit @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script that is called after a successful +# commit is made. +# +# To enable this hook, make this file executable. + +: Nothing diff --git a/templates/hooks--post-update b/templates/hooks--post-update new file mode 100644 index 0000000000..bcba8937bb --- /dev/null +++ b/templates/hooks--post-update @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, make this file executable by "chmod +x post-update". + +exec git-update-server-info diff --git a/templates/hooks--pre-applypatch b/templates/hooks--pre-applypatch new file mode 100644 index 0000000000..5f56ce8053 --- /dev/null +++ b/templates/hooks--pre-applypatch @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, make this file executable. + +. git-sh-setup +test -x "$GIT_DIR/hooks/pre-commit" && + exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"} +: + diff --git a/templates/hooks--pre-commit b/templates/hooks--pre-commit new file mode 100644 index 0000000000..723a9ef210 --- /dev/null +++ b/templates/hooks--pre-commit @@ -0,0 +1,71 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by git-commit with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, make this file executable. + +# This is slightly modified from Andrew Morton's Perfect Patch. +# Lines you introduce should not have trailing whitespace. +# Also check for an indentation that has SP before a TAB. + +if git-rev-parse --verify HEAD 2>/dev/null +then + git-diff-index -p -M --cached HEAD +else + # NEEDSWORK: we should produce a diff with an empty tree here + # if we want to do the same verification for the initial import. + : +fi | +perl -e ' + my $found_bad = 0; + my $filename; + my $reported_filename = ""; + my $lineno; + sub bad_line { + my ($why, $line) = @_; + if (!$found_bad) { + print STDERR "*\n"; + print STDERR "* You have some suspicious patch lines:\n"; + print STDERR "*\n"; + $found_bad = 1; + } + if ($reported_filename ne $filename) { + print STDERR "* In $filename\n"; + $reported_filename = $filename; + } + print STDERR "* $why (line $lineno)\n"; + print STDERR "$filename:$lineno:$line\n"; + } + while (<>) { + if (m|^diff --git a/(.*) b/\1$|) { + $filename = $1; + next; + } + if (/^@@ -\S+ \+(\d+)/) { + $lineno = $1 - 1; + next; + } + if (/^ /) { + $lineno++; + next; + } + if (s/^\+//) { + $lineno++; + chomp; + if (/\s$/) { + bad_line("trailing whitespace", $_); + } + if (/^\s* /) { + bad_line("indent SP followed by a TAB", $_); + } + if (/^(?:[<>=]){7}/) { + bad_line("unresolved merge conflict", $_); + } + } + } + exit($found_bad); +' + diff --git a/templates/hooks--pre-rebase b/templates/hooks--pre-rebase new file mode 100644 index 0000000000..981c454cda --- /dev/null +++ b/templates/hooks--pre-rebase @@ -0,0 +1,150 @@ +#!/bin/sh +# +# Copyright (c) 2006 Junio C Hamano +# + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` +fi + +case "$basebranch,$topic" in +master,refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Is topic fully merged to master? +not_in_master=`git-rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git-rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git-rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git-rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up-to-date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git-rev-list --pretty=oneline ^${publish} "$topic"` + perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +exit 0 + +################################################################ + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git-rev-list ^master ^topic next + git-rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git-rev-list master..topic + + if this is empty, it is fully merged to "master". diff --git a/templates/hooks--update b/templates/hooks--update new file mode 100644 index 0000000000..76d5ac2477 --- /dev/null +++ b/templates/hooks--update @@ -0,0 +1,89 @@ +#!/bin/sh +# +# An example hook script to mail out commit update information. +# It also blocks tags that aren't annotated. +# Called by git-receive-pack with arguments: refname sha1-old sha1-new +# +# To enable this hook: +# (1) change the recipient e-mail address +# (2) make this file executable by "chmod +x update". +# + +project=$(cat $GIT_DIR/description) +recipients="commit-list@somewhere.com commit-list@somewhereelse.com" + +ref_type=$(git cat-file -t "$3") + +# Only allow annotated tags in a shared repo +# Remove this code to treat dumb tags the same as everything else +case "$1","$ref_type" in +refs/tags/*,commit) + echo "*** Un-annotated tags are not allowed in this repo" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." + exit 1;; +refs/tags/*,tag) + echo "### Pushing version '${1##refs/tags/}' to the masses" >&2 + # recipients="release-announce@somwehere.com announce@somewhereelse.com" + ;; +esac + +# set this to 'cat' to get a very detailed listing. +# short only kicks in when an annotated tag is added +short='git shortlog' + +# see 'date --help' for info on how to write this +# The default is a human-readable iso8601-like format with minute +# precision ('2006-01-25 15:58 +0100' for example) +date_format="%F %R %z" + +(if expr "$2" : '0*$' >/dev/null +then + # new ref + case "$1" in + refs/tags/*) + # a pushed and annotated tag (usually) means a new version + tag="${1##refs/tags/}" + if [ "$ref_type" = tag ]; then + eval $(git cat-file tag $3 | \ + sed -n '4s/tagger \([^>]*>\)[^0-9]*\([0-9]*\).*/tagger="\1" ts="\2"/p') + date=$(date --date="1970-01-01 00:00:00 $ts seconds" +"$date_format") + echo "Tag '$tag' created by $tagger at $date" + git cat-file tag $3 | sed -n '5,$p' + echo + fi + prev=$(git describe "$3^" | sed 's/-g.*//') + # the first tag in a repo will yield no $prev + if [ -z "$prev" ]; then + echo "Changes since the dawn of time:" + git rev-list --pretty $3 | $short + else + echo "Changes since $prev:" + git rev-list --pretty $prev..$3 | $short + echo --- + git diff --stat $prev..$3 + echo --- + fi + ;; + + refs/heads/*) + branch="${1##refs/heads/}" + echo "New branch '$branch' available with the following commits:" + git-rev-list --pretty "$3" $(git-rev-parse --not --all) + ;; + esac +else + base=$(git-merge-base "$2" "$3") + case "$base" in + "$2") + git diff --stat "$3" "^$base" + echo + echo "New commits:" + ;; + *) + echo "Rebased ref, commits from common ancestor:" + ;; + esac + git-rev-list --pretty "$3" "^$base" +fi) | +mail -s "$project: Changes to '${1##refs/heads/}'" $recipients +exit 0 diff --git a/templates/info--exclude b/templates/info--exclude new file mode 100644 index 0000000000..2c87b72dff --- /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/remotes-- b/templates/remotes-- new file mode 100644 index 0000000000..fae88709a6 --- /dev/null +++ b/templates/remotes-- @@ -0,0 +1 @@ +: this is just to ensure the directory exists. diff --git a/templates/this--description b/templates/this--description new file mode 100644 index 0000000000..c6f25e80b8 --- /dev/null +++ b/templates/this--description @@ -0,0 +1 @@ +Unnamed repository; edit this file to name it for gitweb. |