[PATCH] Use FETCH_HEAD to know where to rebase to after pull.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since 'git fetch' already takes care of the branch.*.merge parameters,
resolves the new tip of the parent branch and puts it in FETCH_HEAD,
we're better just taking it from there.

This fixes the regression on t1200-push-modified.sh.

Signed-off-by: Yann Dirson <ydirson@xxxxxxxxxx>
---

 stgit/commands/pull.py |    4 ++--
 stgit/git.py           |   23 ++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/stgit/commands/pull.py b/stgit/commands/pull.py
index 330cc25..e1aca87 100644
--- a/stgit/commands/pull.py
+++ b/stgit/commands/pull.py
@@ -73,8 +73,8 @@ def func(parser, options, args):
     print 'Pulling from "%s"...' % repository
     git.fetch(repository)
     if (config.get('stgit.pull-does-rebase') == 'yes'):
-        print "rebasing to '%s'..." % crt_series.get_parent_branch()
-        git.reset(tree_id = git.rev_parse(crt_series.get_parent_branch()))
+        print "rebasing to '%s'..." % git.fetch_head()
+        git.reset(tree_id = git.fetch_head())
     print 'done'
 
     # push the patches back
diff --git a/stgit/git.py b/stgit/git.py
index 3d84e97..6769a9f 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -931,7 +931,8 @@ def remotes_local_branches(remote):
         for line in stream:
             # Only consider Pull lines
             m = re.match('^Pull: (.*)\n$', line)
-            branches.append(refspec_localpart(m.group(1)))
+            if m:
+                branches.append(refspec_localpart(m.group(1)))
         stream.close()
     elif remote in __remotes_from_dir('branches'):
         # old-style branches only declare one branch
@@ -955,3 +956,23 @@ def identify_remote(branchname):
 
     # if we get here we've found nothing
     return None
+
+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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]