* [PATCH] Use FETCH_HEAD to know where to rebase to after pull.
@ 2007-02-03 21:29 Yann Dirson
0 siblings, 0 replies; only message in thread
From: Yann Dirson @ 2007-02-03 21:29 UTC (permalink / raw)
To: Catalin Marinas; +Cc: git
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@altern.org>
---
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2007-02-03 21:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-03 21:29 [PATCH] Use FETCH_HEAD to know where to rebase to after pull Yann Dirson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).