Эх сурвалжийг харах

Detach branch even when already on the latest revision using sync -d

This patch fixes repo behaviour when running sync -d with unmodified
topic branches.

Prior to this patch sync -d would see the latest revision is already
checked out, thus staying on the branch. Since "-d" means detach we
should follow git's behaviour and actually detach from the branch in
that case.

Basic test case - after a fresh repo init + sync -
        * repo start --all testdetach
        * repo sync -d
        * repo status
-> status shows active topic branch "testdetach",
   should show :
nothing to commit (working directory clean)

Change-Id: Ic1351e6b5721b76557a51ab09f9dd42c38a4b415
Florian Vallee 13 жил өмнө
parent
commit
7cf1b36bcd
1 өөрчлөгдсөн 7 нэмэгдсэн , 4 устгасан
  1. 7 4
      project.py

+ 7 - 4
project.py

@@ -1044,12 +1044,15 @@ class Project(object):
 
       if head == revid:
         # No changes; don't do anything further.
+        # Except if the head needs to be detached
         #
-        return
+        if not syncbuf.detach_head:
+          return
+      else:
+        lost = self._revlist(not_rev(revid), HEAD)
+        if lost:
+          syncbuf.info(self, "discarding %d commits", len(lost))
 
-      lost = self._revlist(not_rev(revid), HEAD)
-      if lost:
-        syncbuf.info(self, "discarding %d commits", len(lost))
       try:
         self._Checkout(revid, quiet=True)
       except GitError, e: