+
+def fetch_head():
+ """Return the git id for the tip of the parent branch as left by
+ 'git fetch'.
+ """
+
+ fetch_head=None
+ stream = open(os.path.join(basedir.get(), 'FETCH_HEAD'), "r")
+ for line in stream:
+ # Only consider lines not tagged not-for-merge
+ m = re.match('^([^\t]*)\t\t', line)
+ if m:
+ if fetch_head:
+ raise GitException, "StGit does not support multiple FETCH_HEAD"
+ else:
+ fetch_head=m.group(1)
+ stream.close()
+
+ # here we are sure to have a single fetch_head
+ return fetch_head