From 71f463773a310de016da20136fd7160685f97faa Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Wed, 20 Aug 2008 17:36:25 +0200 Subject: Install templates with the user and group of the installing personality If 'make install' was run with sufficient privileges, then the installed templates, which are copied using 'tar', would receive the user and group of whoever built git. This instructs 'tar' to ignore the user and group that are recorded in the archive. Signed-off-by: Johannes Sixt Signed-off-by: Junio C Hamano --- templates/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/Makefile b/templates/Makefile index 9f3f1fc352..cc3fc3094c 100644 --- a/templates/Makefile +++ b/templates/Makefile @@ -48,4 +48,4 @@ clean: install: all $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)' (cd blt && $(TAR) cf - .) | \ - (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xf -) + (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xfo -) -- cgit v1.2.3 From d8bdc49265559786533d7f7377b2c39038dd6309 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 21 Aug 2008 19:31:50 -0500 Subject: Fix permission bits on sources checked out with an overtight umask Two patches 9907721 (templates/Makefile: don't depend on local umask setting, 2008-02-28) and 96cda0b (templates/Makefile: install is unnecessary, just use mkdir -p, 2008-08-21) tried to prevent an overtight umask the builder/installer might have from screwing over the installation procedure, but we forgot there was another source of trouble. If the person who checked out the source tree had an overtight umask, it will leak out to the built products, which is propagated to the installation destination. Signed-off-by: Junio C Hamano --- templates/Makefile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'templates') diff --git a/templates/Makefile b/templates/Makefile index cc3fc3094c..a12c6e214e 100644 --- a/templates/Makefile +++ b/templates/Makefile @@ -23,17 +23,19 @@ all: boilerplates.made custom bpsrc = $(filter-out %~,$(wildcard *--*)) boilerplates.made : $(bpsrc) - $(QUIET)ls *--* 2>/dev/null | \ + $(QUIET)umask 022 && 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" : '\(.*\)/'` && \ - $(INSTALL) -d -m 755 blt/$$dir && \ + mkdir -p blt/$$dir && \ case "$$boilerplate" in \ - *--) ;; \ - *) cp -p $$boilerplate blt/$$dst ;; \ - esac || exit; \ + *--) continue;; \ + esac && \ + cp $$boilerplate blt/$$dst && \ + if test -x "blt/$$dst"; then rx=rx; else rx=r; fi && \ + chmod a+$$rx "blt/$$dst" || exit; \ done && \ date >$@ -- cgit v1.2.3 From 28001d0873cfce1ad6a44f1c2deaf9388d953cc3 Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Thu, 19 Feb 2009 07:36:00 +0000 Subject: Modify description file to say what this file is A lot of people see this message for the first time on the gitweb interface, where there is no clue as to what 'this file' means. Signed-off-by: John Tapsell Signed-off-by: Junio C Hamano --- templates/hooks--update.sample | 6 ++++-- templates/this--description | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'templates') diff --git a/templates/hooks--update.sample b/templates/hooks--update.sample index 93c605594f..a3f68ae3b4 100755 --- a/templates/hooks--update.sample +++ b/templates/hooks--update.sample @@ -43,10 +43,12 @@ allowdeletetag=$(git config --bool hooks.allowdeletetag) # check for no description projectdesc=$(sed -e '1q' "$GIT_DIR/description") -if [ -z "$projectdesc" -o "$projectdesc" = "Unnamed repository; edit this file to name it for gitweb." ]; then +case "$projectdesc" in +"Unnamed repository"* | "") echo "*** Project description file hasn't been set" >&2 exit 1 -fi + ;; +esac # --- Check types # if $newrev is 0000...0000, it's a commit to delete a ref. diff --git a/templates/this--description b/templates/this--description index c6f25e80b8..498b267a8c 100644 --- a/templates/this--description +++ b/templates/this--description @@ -1 +1 @@ -Unnamed repository; edit this file to name it for gitweb. +Unnamed repository; edit this file 'description' to name the repository. -- cgit v1.2.3 From aed97c677cdfd1b9bbc9b33b5418ad4a29109082 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Thu, 16 Apr 2009 22:00:44 +0200 Subject: hook/update: example of how to prevent branch creation Since git doesn't provide a receive.denyBranchCreation or similar, here is an example of how to be sure users cannot create branches remotely by pushing a new reference. This setup has been proven useful to prevent creation of spurious branches because of users having their remote.origin.push set to HEAD, when they use `git push` while being on a local topic branch of theirs instead of the proper one. Signed-off-by: Pierre Habouzit Signed-off-by: Junio C Hamano --- templates/hooks--update.sample | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/hooks--update.sample b/templates/hooks--update.sample index a3f68ae3b4..f8bf490cff 100755 --- a/templates/hooks--update.sample +++ b/templates/hooks--update.sample @@ -16,6 +16,9 @@ # hooks.allowdeletebranch # This boolean sets whether deleting branches will be allowed in the # repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. # # --- Command line @@ -39,6 +42,7 @@ fi # --- Config allowunannotated=$(git config --bool hooks.allowunannotated) allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) allowdeletetag=$(git config --bool hooks.allowdeletetag) # check for no description @@ -52,7 +56,8 @@ esac # --- Check types # if $newrev is 0000...0000, it's a commit to delete a ref. -if [ "$newrev" = "0000000000000000000000000000000000000000" ]; then +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then newrev_type=delete else newrev_type=$(git-cat-file -t $newrev) @@ -80,6 +85,10 @@ case "$refname","$newrev_type" in ;; refs/heads/*,commit) # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi ;; refs/heads/*,delete) # delete branch -- cgit v1.2.3 From 7742c65ba5d74f9cbb426f206a88ae04be3f46cd Mon Sep 17 00:00:00 2001 From: Heiko Voigt Date: Fri, 8 May 2009 17:22:30 +0200 Subject: Extend sample update hook, disable modifying of existing tags Because no special rule for this existed it was allowed by default Signed-off-by: Heiko Voigt Signed-off-by: Junio C Hamano --- templates/hooks--update.sample | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'templates') diff --git a/templates/hooks--update.sample b/templates/hooks--update.sample index f8bf490cff..fd63b2d662 100755 --- a/templates/hooks--update.sample +++ b/templates/hooks--update.sample @@ -13,6 +13,9 @@ # hooks.allowdeletetag # This boolean sets whether deleting tags will be allowed in the # repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. # hooks.allowdeletebranch # This boolean sets whether deleting branches will be allowed in the # repository. By default they won't be. @@ -44,6 +47,7 @@ allowunannotated=$(git config --bool hooks.allowunannotated) allowdeletebranch=$(git config --bool hooks.allowdeletebranch) denycreatebranch=$(git config --bool hooks.denycreatebranch) allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) # check for no description projectdesc=$(sed -e '1q' "$GIT_DIR/description") @@ -82,6 +86,12 @@ case "$refname","$newrev_type" in ;; refs/tags/*,tag) # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi ;; refs/heads/*,commit) # branch -- cgit v1.2.3 From c646217e1366b0397552fad8c32acb47fbe8977d Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 16 May 2009 12:21:50 +0200 Subject: pre-commit.sample: don't print incidental SHA1 Make the sample pre-commit hook script discard all git-rev-parse output, not just stderr. Otherwise, it would print an SHA1. Signed-off-by: Jim Meyering Signed-off-by: Junio C Hamano --- templates/hooks--pre-commit.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample index 0e49279c7f..0ba62076fb 100755 --- a/templates/hooks--pre-commit.sample +++ b/templates/hooks--pre-commit.sample @@ -7,7 +7,7 @@ # # To enable this hook, rename this file to "pre-commit". -if git-rev-parse --verify HEAD 2>/dev/null +if git-rev-parse --verify HEAD >/dev/null 2>&1 then against=HEAD else -- cgit v1.2.3 From d00e364de99d51bb76e437820e23cfa820417ec5 Mon Sep 17 00:00:00 2001 From: Heiko Voigt Date: Tue, 19 May 2009 22:01:54 +0200 Subject: Extend sample pre-commit hook to check for non ascii filenames At the moment non-ascii encodings of filenames are not portably converted between different filesystems by git. This will most likely change in the future but to allow repositories to be portable among different file/operating systems this check is enabled by default. Signed-off-by: Heiko Voigt Signed-off-by: Junio C Hamano --- templates/hooks--pre-commit.sample | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'templates') diff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample index 0ba62076fb..b11ad6a6fb 100755 --- a/templates/hooks--pre-commit.sample +++ b/templates/hooks--pre-commit.sample @@ -7,6 +7,31 @@ # # To enable this hook, rename this file to "pre-commit". +# If you want to allow non-ascii filenames set this variable to true. +allownonascii=$(git config hooks.allownonascii) + +# Cross platform projects tend to avoid non-ascii filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + test "$(git diff --cached --name-only --diff-filter=A -z | + LC_ALL=C tr -d '[ -~]\0')" +then + echo "Error: Attempt to add a non-ascii filename." + echo + echo "This can cause problems if you want to work together" + echo "with people on other platforms than you." + echo + echo "To be portable it is adviseable to rename the file ..." + echo + echo "If you know what you are doing you can disable this" + echo "check using:" + echo + echo " git config hooks.allownonascii true" + echo + exit 1 +fi + if git-rev-parse --verify HEAD >/dev/null 2>&1 then against=HEAD -- cgit v1.2.3 From f1e3156e627fa66714deea665c8f3585088b9695 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 21 Sep 2009 13:00:34 +0200 Subject: pre-commit.sample: add comment re tr portability; fix grammar Add a comment explaining why square brackets around a tr range are not only ok, but actually required in this case. Correct spelling and grammar. Signed-off-by: Jim Meyering Signed-off-by: Junio C Hamano --- templates/hooks--pre-commit.sample | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'templates') diff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample index b11ad6a6fb..043970a751 100755 --- a/templates/hooks--pre-commit.sample +++ b/templates/hooks--pre-commit.sample @@ -14,15 +14,18 @@ allownonascii=$(git config hooks.allownonascii) # them from being added to the repository. We exploit the fact that the # printable range starts at the space character and ends with tilde. if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. test "$(git diff --cached --name-only --diff-filter=A -z | LC_ALL=C tr -d '[ -~]\0')" then - echo "Error: Attempt to add a non-ascii filename." + echo "Error: Attempt to add a non-ascii file name." echo - echo "This can cause problems if you want to work together" - echo "with people on other platforms than you." + echo "This can cause problems if you want to work" + echo "with people on other platforms." echo - echo "To be portable it is adviseable to rename the file ..." + echo "To be portable it is advisable to rename the file ..." echo echo "If you know what you are doing you can disable this" echo "check using:" -- cgit v1.2.3 From 42a0ea94ce661a069f0622f6c01d1d1f21cbbc18 Mon Sep 17 00:00:00 2001 From: Frederik Schwarzer Date: Mon, 28 Sep 2009 10:25:55 +0200 Subject: Correct minor typo in post-receive hook template Signed-off-by: Shawn O. Pearce --- templates/hooks--post-receive.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/hooks--post-receive.sample b/templates/hooks--post-receive.sample index 18d2e0f727..7a83e17ab5 100755 --- a/templates/hooks--post-receive.sample +++ b/templates/hooks--post-receive.sample @@ -9,7 +9,7 @@ # For example: # aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master # -# see contrib/hooks/ for an sample, or uncomment the next line and +# see contrib/hooks/ for a sample, or uncomment the next line and # rename the file to "post-receive". #. /usr/share/doc/git-core/contrib/hooks/post-receive-email -- cgit v1.2.3 From 36e561064e83d3f890f8fa128b3ca4e0d7691f10 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Sat, 24 Oct 2009 15:06:57 +0200 Subject: Work around option parsing bug in the busybox tar implementation The first argument of the tar command is interpreted as a bundle of letters specifying the mode of operation and additional options, with any option arguments taken from subsequent words on the command line as needed. The implementation of tar in busybox treats this bundle as if preceded by a dash and then parses it by getopt rules, which mishandles 'tar xfo -'. Use 'tar xof -' instead to work this around. Signed-off-by: Andreas Schwab Signed-off-by: Junio C Hamano --- templates/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/Makefile b/templates/Makefile index a12c6e214e..408f0137a8 100644 --- a/templates/Makefile +++ b/templates/Makefile @@ -50,4 +50,4 @@ clean: install: all $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)' (cd blt && $(TAR) cf - .) | \ - (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xfo -) + (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xof -) -- cgit v1.2.3 From 0cc5691a8b05a7eabdeef520c94b1bb3bcac7874 Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Fri, 30 Oct 2009 18:20:28 +0100 Subject: Don't create the $GIT_DIR/branches directory on init Git itself does not even look at this directory. Any tools that actually needs it should create it itself. Signed-off-by: Robin Rosenberg Signed-off-by: Junio C Hamano --- templates/branches-- | 1 - 1 file changed, 1 deletion(-) delete mode 100644 templates/branches-- (limited to 'templates') diff --git a/templates/branches-- b/templates/branches-- deleted file mode 100644 index fae88709a6..0000000000 --- a/templates/branches-- +++ /dev/null @@ -1 +0,0 @@ -: this is just to ensure the directory exists. -- cgit v1.2.3 From c8a58ac5a52b0850fbca87898d1c6aa44cf5626f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 31 Oct 2009 11:16:50 -0700 Subject: Revert "Don't create the $GIT_DIR/branches directory on init" This reverts commit 0cc5691a8b05a7eabdeef520c94b1bb3bcac7874. There is not enough justification for doing this. We do not update things in .git/branches and .git/remotes anymore, but still do read information from there and will keep doing so. Besides, this breaks quite a lot of tests in t55?? series. --- templates/branches-- | 1 + 1 file changed, 1 insertion(+) create mode 100644 templates/branches-- (limited to 'templates') 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. -- cgit v1.2.3 From c30eb852e281d55b04465b7814e00396893f74f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Thu, 5 Nov 2009 11:57:57 +0100 Subject: pre-commit.sample: Diff against the empty tree when HEAD is invalid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was already the case for the old "diff --check" call, but the new one that checks whether there are any non-ascii file names was missing it, making that check fail for root commits. Signed-off-by: Björn Steinbrink Signed-off-by: Junio C Hamano --- templates/hooks--pre-commit.sample | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'templates') diff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample index 043970a751..439eefda51 100755 --- a/templates/hooks--pre-commit.sample +++ b/templates/hooks--pre-commit.sample @@ -7,6 +7,14 @@ # # To enable this hook, rename this file to "pre-commit". +if git-rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + # If you want to allow non-ascii filenames set this variable to true. allownonascii=$(git config hooks.allownonascii) @@ -17,7 +25,7 @@ if [ "$allownonascii" != "true" ] && # Note that the use of brackets around a tr range is ok here, (it's # even required, for portability to Solaris 10's /usr/bin/tr), since # the square bracket bytes happen to fall in the designated range. - test "$(git diff --cached --name-only --diff-filter=A -z | + test "$(git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0')" then echo "Error: Attempt to add a non-ascii file name." @@ -35,12 +43,4 @@ then exit 1 fi -if git-rev-parse --verify HEAD >/dev/null 2>&1 -then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 -fi - exec git diff-index --check --cached $against -- -- cgit v1.2.3