[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu Apr 26 01:55:02 UTC 2018


The branch, master has been updated
       via  5757d25 script/git-hooks: add check-trailing-whitespace
       via  8649e21 Add a wrapper script as git pre-commit hook
      from  a6fade4 rpc_server: Fix NetSessEnum with stale sessions

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5757d259321f20fab349fd1a0d447473ba2c8fc6
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Apr 10 13:19:09 2018 +0200

    script/git-hooks: add check-trailing-whitespace
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Apr 26 03:54:39 CEST 2018 on sn-devel-144

commit 8649e216650de85cd73eda64caa2e338d59582d5
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Apr 10 13:04:27 2018 +0200

    Add a wrapper script as git pre-commit hook
    
    When developer mode is enabled, the wrapper script
    "script/git-hooks/pre-commit-hook" gets installed as
    
      .git/hooks/pre-commit
    
    and calls "script/git-hooks/pre-commit-script".
    
    This way we can later modify the "script/git-hooks/pre-commit-script"
    without the need to ever change the installed commit hook itself.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 script/git-hooks/check-trailing-whitespace | 17 +++++++++++++++++
 script/git-hooks/pre-commit-hook           | 17 +++++++++++++++++
 script/git-hooks/pre-commit-script         | 19 +++++++++++++++++++
 wscript                                    |  9 ++++++++-
 4 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100755 script/git-hooks/check-trailing-whitespace
 create mode 100755 script/git-hooks/pre-commit-hook
 create mode 100755 script/git-hooks/pre-commit-script


Changeset truncated at 500 lines:

diff --git a/script/git-hooks/check-trailing-whitespace b/script/git-hooks/check-trailing-whitespace
new file mode 100755
index 0000000..5303f1f
--- /dev/null
+++ b/script/git-hooks/check-trailing-whitespace
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+git diff-index --cached --check  HEAD -- :/*.[ch] :/*.p[ylm]
+
+if [ $? != 0 ]; then
+    echo
+    echo "The commit failed because it seems to introduce trailing whitespace"
+    echo "into C, Perl, or Python code."
+    echo
+    echo "If you are sure you want to do this, repeat the commit with the "
+    echo "--no-verify, like this:"
+    echo
+    echo "   git commit --no-verify"
+    exit 1
+fi
+
+exit 0
diff --git a/script/git-hooks/pre-commit-hook b/script/git-hooks/pre-commit-hook
new file mode 100755
index 0000000..3f51254
--- /dev/null
+++ b/script/git-hooks/pre-commit-hook
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+set -eu
+
+gitdir=$(git rev-parse --show-toplevel)
+if [ $? -ne 0 ] ; then
+    echo "git rev-parse --show-toplevel failed"
+    exit 1
+fi
+
+if [ ! -f ${gitdir}/script/git-hooks/pre-commit-script ] ; then
+    exit 0
+fi
+
+${gitdir}/script/git-hooks/pre-commit-script || exit $?
+
+exit 0
diff --git a/script/git-hooks/pre-commit-script b/script/git-hooks/pre-commit-script
new file mode 100755
index 0000000..015a553
--- /dev/null
+++ b/script/git-hooks/pre-commit-script
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+set -eu
+
+#
+# make emacs/magit work, cf
+# https://github.com/magit/magit/issues/3419
+#
+unset GIT_LITERAL_PATHSPECS
+
+gitdir=$(git rev-parse --show-toplevel)
+if [ $? -ne 0 ] ; then
+    echo "git rev-parse --show-toplevel failed"
+    exit 1
+fi
+
+${gitdir}/script/git-hooks/check-trailing-whitespace || exit $?
+
+exit 0
diff --git a/wscript b/wscript
index b45146c..dbfc121 100644
--- a/wscript
+++ b/wscript
@@ -10,7 +10,7 @@ import sys, os, tempfile
 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
 import wafsamba, Options, samba_dist, samba_git, Scripting, Utils, samba_version
 import Logs, samba_utils
-
+import shutil
 
 samba_dist.DIST_DIRS('.')
 samba_dist.DIST_BLACKLIST('.gitignore .bzrignore source4/selftest/provisions')
@@ -106,6 +106,13 @@ def configure(conf):
     if Options.options.developer:
         conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
         conf.env.DEVELOPER = True
+        # if we are in a git tree without a pre-commit hook, install a
+        # simple default.
+        pre_commit_hook = os.path.join(srcdir, '.git/hooks/pre-commit')
+        if (os.path.isdir(os.path.dirname(pre_commit_hook)) and
+            not os.path.exists(pre_commit_hook)):
+            shutil.copy(os.path.join(srcdir, 'script/git-hooks/pre-commit-hook'),
+                        pre_commit_hook)
 
     conf.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list