threads / patch / 6298

patchCheck git pull remote before defaulting to 'origin'

Subject: [PATCH] Check git pull remote before defaulting to 'origin'

## tl;dr

3 messages between Dec 10, 2006 and Jan 9, 2007. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Catalin Marinas· Dec 10, 2006, 16:41 UTC · lore

Re: RFC PATCH: support for default remote in StGIT

On 09/12/06, Pavel Roskin <proski@gnu.org> wrote:
> Sorry, I was unlucky to pick your address from setup.py, where it's
> incorrect (gmail.org, not gmail.com), so I'm sending you another copy.
Thanks for spotting this.
> One approach is to leave the default remote selection completely to git.
> The downside is that StGIT prints the remote it's pulling from.  Now
> StGIT will have to print common words that it's pulling something.  Or
> maybe it shouldn't print anything?

Yann started a thread on this but I didn't find the time to look at this properly. He's idea was to store the remote branch information in the StGIT metadata but I'd like to leave this for GIT to deal with.

The StGIT UI can probably be modified to display something useful but I don't see a problem if it doesn't.

Show 7 quoted lines
> The other approach is to calculate the default remote in StGIT.  This
> would allow StGIT to tell the user where it's pulling from.
>
> However, I had to introduce a function that ignores errors except there
> is any output on stderr.  This is because git-repo-config returns error
> code 1 if it cannot find the key.  Maybe git-repo-config should have an
> option not to fail in this case?  Perhaps a default value to return?

With the recent changes, StGIT shares the config files with GIT and it has direct access to git settings without the need to use git-repo-config. Just use "config.has_key" and "config.get_option".

Maybe a combination of your two options - StGIT could try to get the default branch and, if there isn't any in the config files, just invoke git-pull without any argument (and display something like "pulling from default").

Pavel Roskin· Jan 9, 2007, 07:20 UTC · re: Catalin Marinas · lore
Check git pull remote before defaulting to 'origin'
Signed-off-by: Pavel Roskin <proski@gnu.org>
---
 stgit/commands/pull.py |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
Show changes to stgit/commands/pull.py +8 −2
diff --git a/stgit/commands/pull.py b/stgit/commands/pull.py
index 227249e..7c5db22 100644
--- a/stgit/commands/pull.py
+++ b/stgit/commands/pull.py
@@ -50,10 +50,16 @@ def func(parser, options, args):
     if len(args) > 2:
         parser.error('incorrect number of arguments')
 
-    repository = 'origin'
-    refspec = None
     if len(args) >= 1:
         repository = args[0]
+    else:
+        section = 'branch "%s"' % git.get_head_file()
+        if config.has_option(section, 'remote'):
+            repository = config.get(section, 'remote')
+        else:
+            repository = 'origin'
+
+    refspec = None
     if len(args) == 2:
         refspec = args[1]
 
-- 
Regards,
Pavel Roskin

← back to recent threads