changeset 5576:72f8f8091b03

repository.Git: avoid gratuitous reset --hard. Fixes lilypond rebuilds. Unlike git checkout which makes a point of documenting the importance of preserving/updating timestamps, git reset --hard blindly destroys all timestamps on not-modified files. This breaks configure-up-to-date checks, notably lilypond's. See http://lists.gnu.org/archive/html/lilypond-devel/2009-08/msg00488.html
author Jan Nieuwenhuizen <janneke@gnu.org>
date Thu, 24 Sep 2009 09:56:22 +0200
parents e31edefcd33f
children c5d81ab00fef 090949f22c11
files gub/repository.py
diffstat 1 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/gub/repository.py	Tue Sep 22 12:21:04 2009 +0100
+++ b/gub/repository.py	Thu Sep 24 09:56:22 2009 +0200
@@ -658,17 +658,16 @@
     def _update_workdir_shallow (self, destdir):
         branch = self.branch # branch is empty?
         branch = 'master'
+        HEAD = self.checksum ()
         if not os.path.isdir (os.path.join (destdir, self.vc_system)):
             self.system ('mkdir -p %(destdir)s' % locals ())
             self.system ('cd %(destdir)s && git init' % locals ())
-        open ('%(destdir)s/.git/objects/info/alternates' % locals (), 'w').write (os.path.join (self.dir, 'objects'))
-        if 0: # no-go
-            open ('%(destdir)s/.git/HEAD' % locals (), 'w').write (self.checksum ())
-            HEAD = 'HEAD'
-        HEAD = self.checksum ()
-        self.system ('cd %(destdir)s && git reset --hard %(HEAD)s' % locals ())
-        self.system ('cd %(destdir)s && (git checkout -f %(branch)s || git branch %(branch)s)' % locals ())
-        self.system ('cd %(destdir)s && git reset --hard %(HEAD)s' % locals ())
+            open ('%(destdir)s/.git/objects/info/alternates' % locals (), 'w').write (os.path.join (self.dir, 'objects'))
+#            self.system ('cd %(destdir)s && git reset --hard %(HEAD)s' % locals ())
+        if self.git_pipe ('diff' % locals (), dir=destdir):
+            self.system ('cd %(destdir)s && git reset --hard %(HEAD)s' % locals ())
+        self.system ('cd %(destdir)s && git checkout %(HEAD)s' % locals ())
+        self.system ('cd %(destdir)s && (git checkout %(branch)s || git checkout -b %(branch)s)' % locals ())
     def _update_workdir (self, destdir):
         checkout_dir = self.dir
         branch = self.get_ref ()