Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=git-hooks.git;a=commitdiff;h=db1f88047d7bb1a2cbcf6a5f8e380e903689a154

commit db1f88047d7bb1a2cbcf6a5f8e380e903689a154
Author: Miklos Vajna <[EMAIL PROTECTED]>
Date:   Mon Mar 24 14:32:39 2008 +0100

detach: new plugin for detached head

this will hopefully speed up git push. till now we did not know where we
were after a push, so we needed to check every file if it has to be
updated. now we store the old sha1 in the pre-receive, so that we have
to update only the modified files. much faster.

diff --git a/detach/__init__.py b/detach/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/detach/detach.py b/detach/detach.py
new file mode 100644
index 0000000..f4fbc98
--- /dev/null
+++ b/detach/detach.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+import os, time, sys
+
+first = True
+
+def callback(patch):
+       global first
+
+       if not first:
+               return
+       first = False
+       os.chdir("..")
+       if "GIT_DIR" in os.environ.keys():
+               del os.environ['GIT_DIR']
+       limit = 300
+       for i in range(limit):
+               try:
+                       os.stat(".git/index.lock")
+                       print "Waiting for lock to be released to do a 'git 
checkout'"
+                       sys.stdout.flush()
+                       time.sleep(1)
+               except OSError:
+                       sock = os.popen("git-show-ref -h -s HEAD")
+                       hash = sock.readline().strip()
+                       sock.close()
+                       os.system("git checkout -m %s" % hash)
+                       return
+       print "WARNING: Timeout exceeded, checkout failed!"
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to