git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yann Dirson <ydirson@altern.org>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [PATCH 2/3] Rebase to parent branch after git-fetch in "stg pull".
Date: Fri, 02 Feb 2007 00:48:05 +0100	[thread overview]
Message-ID: <20070201234805.3313.20525.stgit@gandelf.nowhere.earth> (raw)
In-Reply-To: <20070201234534.3313.10426.stgit@gandelf.nowhere.earth>


Previously we were just assuming that the remote from which we
just failed defined a local branch whose name was the same as the
remote def, and that this branch was the parent.  While this is true
for the most common case (branch "origin" from remote "origin"), it is
quite an unflexible assumption.

Also move the rebasing from git.pull to commands.pull.func since that
is clearly stgit-level stuff, and rename git.pull() to git.fetch() to
match default behaviour.

Signed-off-by: Yann Dirson <ydirson@altern.org>
---

 stgit/commands/pull.py |   20 +++++++++++---------
 stgit/git.py           |   10 +++-------
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/stgit/commands/pull.py b/stgit/commands/pull.py
index f837fd4..15bbed6 100644
--- a/stgit/commands/pull.py
+++ b/stgit/commands/pull.py
@@ -26,15 +26,15 @@ from stgit import stack, git
 help = 'pull the changes from the remote repository'
 usage = """%prog [options] [<repository>]
 
-Pull the latest changes from the given repository (defaulting to
-'origin'). This command works by popping all the patches from the
-stack, pulling the changes in the parent repository, setting the base
-of the stack to the latest parent HEAD and pushing the patches back
-(unless '--nopush' is specified). The 'push' operation can fail if
-there are conflicts. They need to be resolved and the patch pushed
-again.
+Pull the latest changes from the given remote repository (defaulting
+to branch.<name>.remote, or 'origin' if not set). This command works
+by popping all the patches from the stack, pulling the changes in the
+parent repository, setting the base of the stack to the latest parent
+HEAD and pushing the patches back (unless '--nopush' is specified).
+The 'push' operation can fail if there are conflicts. They need to be
+resolved and the patch pushed again.
 
-Check the 'git pull' documentation for the <repository> format."""
+Check the 'git fetch' documentation for the <repository> format."""
 
 options = [make_option('-n', '--nopush',
                        help = 'do not push the patches back after pulling',
@@ -71,7 +71,9 @@ def func(parser, options, args):
 
     # pull the remote changes
     print 'Pulling from "%s"...' % repository
-    git.pull(repository)
+    git.fetch(repository)
+    if (config.get('stgit.pull-does-rebase')):
+        git.reset(tree_id = git.rev_parse(crt_series.get_parent_branch()))
     print 'done'
 
     # push the patches back
diff --git a/stgit/git.py b/stgit/git.py
index e30b959..49ebae1 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -807,9 +807,9 @@ def reset(files = None, tree_id = None, check_out = True):
     if not files:
         __set_head(tree_id)
 
-def pull(repository = 'origin', refspec = None):
-    """Pull changes from the remote repository. Uses 'git-fetch'
-    and moves the stack base.
+def fetch(repository = 'origin', refspec = None):
+    """Fetches changes from the remote repository, using 'git-fetch'
+    by default.
     """
     # we update the HEAD
     __clear_head_cache()
@@ -822,10 +822,6 @@ def pull(repository = 'origin', refspec = None):
     if __run(command, args) != 0:
         raise GitException, 'Failed "%s %s"' % (command, repository)
 
-    if (config.get('stgit.pull-does-rebase')):
-        # FIXME!
-        reset(tree_id = rev_parse(repository))
-
 def repack():
     """Repack all objects into a single pack
     """

  parent reply	other threads:[~2007-02-01 23:49 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-01 23:47 [PATCH 0/3] Update to stgit parent tracking Yann Dirson
2007-02-01 23:48 ` [PATCH 1/3] The user does not want to mess with the refspecs Yann Dirson
2007-02-01 23:48 ` Yann Dirson [this message]
2007-02-02  9:58   ` [PATCH 2/3] Rebase to parent branch after git-fetch in "stg pull" Catalin Marinas
2007-02-02 18:07     ` Yann Dirson
2007-02-02 22:42       ` Yann Dirson
2007-02-02 23:01         ` Catalin Marinas
2007-02-02 23:25           ` Catalin Marinas
2007-02-03 21:46             ` Yann Dirson
2007-02-03 23:01               ` Junio C Hamano
2007-02-04  0:23                 ` Junio C Hamano
2007-02-04  0:24                 ` Yann Dirson
2007-02-04  1:49                 ` Jeff King
2007-02-04  2:10                   ` Junio C Hamano
2007-02-04  2:38                     ` Jeff King
2007-02-02 23:56       ` git-clone wrongly setting branch.*.merge ? (Was: [PATCH 2/3] Rebase to parent branch after git-fetch in "stg pull".) Yann Dirson
2007-02-03  0:14         ` Yann Dirson
2007-02-03  0:17         ` Jakub Narebski
2007-02-03 12:16         ` Catalin Marinas
2007-02-03 14:47           ` Yann Dirson
2007-02-01 23:48 ` [PATCH 3/3] Do not return 'origin' as parent remote when there is no such remote Yann Dirson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070201234805.3313.20525.stgit@gandelf.nowhere.earth \
    --to=ydirson@altern.org \
    --cc=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).