summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Vallee <florian.vallee@gmail.com>2012-06-07 17:11:42 +0200
committerShawn O. Pearce <sop@google.com>2012-06-13 10:36:17 -0700
commit7cf1b36bcdc79c9239413e35b02dee54aa801a20 (patch)
tree9b51d1cac514908b2a74c046e7e28b219d106342
parent5e57234ec619d0de930333a8dde3004d1dc575d6 (diff)
downloadgit-repo-7cf1b36bcdc79c9239413e35b02dee54aa801a20.tar.gz
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
-rw-r--r--project.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/project.py b/project.py
index d336f990..114ff491 100644
--- a/project.py
+++ b/project.py
@@ -1044,12 +1044,15 @@ class Project(object):
1044 1044
1045 if head == revid: 1045 if head == revid:
1046 # No changes; don't do anything further. 1046 # No changes; don't do anything further.
1047 # Except if the head needs to be detached
1047 # 1048 #
1048 return 1049 if not syncbuf.detach_head:
1050 return
1051 else:
1052 lost = self._revlist(not_rev(revid), HEAD)
1053 if lost:
1054 syncbuf.info(self, "discarding %d commits", len(lost))
1049 1055
1050 lost = self._revlist(not_rev(revid), HEAD)
1051 if lost:
1052 syncbuf.info(self, "discarding %d commits", len(lost))
1053 try: 1056 try:
1054 self._Checkout(revid, quiet=True) 1057 self._Checkout(revid, quiet=True)
1055 except GitError, e: 1058 except GitError, e: