From: Yann Dirson <ydirson@altern.org>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [PATCH] Use branch.*.stgit.parentbranch for authoritative parent information.
Date: Sun, 04 Feb 2007 10:48:21 +0100 [thread overview]
Message-ID: <20070204094723.18334.72391.stgit@gandelf.nowhere.earth> (raw)
Also set the API to use remote=None as "parent branch is local", and
have set_parent() translate that to branch.*.remote=".".
Also enforces that we never set a parent-branch info without a
parent-remote (so they are now both set or both untouched), and try to
give useful info when we have to use the old "origin" defaults.
Signed-off-by: Yann Dirson <ydirson@altern.org>
---
This is an updated version of yesterday's patch rebased to current
HEAD, and with normalized string quoting.
stgit/commands/branch.py | 3 ++-
stgit/git.py | 5 +----
stgit/stack.py | 30 ++++++++++++++++++++----------
3 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/stgit/commands/branch.py b/stgit/commands/branch.py
index f074d47..3026d9c 100644
--- a/stgit/commands/branch.py
+++ b/stgit/commands/branch.py
@@ -151,8 +151,9 @@ def func(parser, options, args):
if parentremote:
print 'Using "%s" remote to pull parent from.' % parentremote
else:
- print 'Not identified a remote to pull parent from.'
+ print 'Recording as a local branch.'
else:
+ # no known parent branch, can't guess the remote
parentremote = None
stack.Series(args[0]).init(create_at = tree_id,
diff --git a/stgit/git.py b/stgit/git.py
index 3d84e97..73d07fd 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -950,8 +950,5 @@ def identify_remote(branchname):
if branchname in remotes_local_branches(remote):
return remote
- # FIXME: in the case of local branch we should maybe set remote to
- # "." but are we even sure it is the only case left ?
-
- # if we get here we've found nothing
+ # if we get here we've found nothing, the branch is a local one
return None
diff --git a/stgit/stack.py b/stgit/stack.py
index 3960729..e091d4e 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -418,8 +418,10 @@ class Series(StgitObject):
if value:
return value
elif 'origin' in git.remotes_list():
- # FIXME: this is for compatibility only. Should be
- # dropped when all relevant commands record this info.
+ print 'Notice: no parent remote declared for stack "%s", ' \
+ 'defaulting to "origin". Consider setting "branch.%s.remote" ' \
+ 'and "branch.%s.merge" with "git repo-config".' \
+ % (self.__name, self.__name, self.__name)
return 'origin'
else:
raise StackException, 'Cannot find a parent remote for "%s"' % self.__name
@@ -428,26 +430,34 @@ class Series(StgitObject):
value = config.set('branch.%s.remote' % self.__name, remote)
def get_parent_branch(self):
- value = config.get('branch.%s.merge' % self.__name)
+ value = config.get('branch.%s.stgit.parentbranch' % self.__name)
if value:
return value
elif git.rev_parse('heads/origin'):
- # FIXME: this is for compatibility only. Should be
- # dropped when all relevant commands record this info.
+ print 'Notice: no parent branch declared for stack "%s", ' \
+ 'defaulting to "heads/origin". Consider setting ' \
+ '"branch.%s.stgit.parentbranch" with "git repo-config".' \
+ % (self.__name, self.__name)
return 'heads/origin'
else:
raise StackException, 'Cannot find a parent branch for "%s"' % self.__name
def __set_parent_branch(self, name):
- config.set('branch.%s.merge' % self.__name, name)
+ if config.get('branch.%s.remote' % self.__name):
+ # Never set merge if remote is not set to avoid
+ # possibly-erroneous lookups into 'origin'
+ config.set('branch.%s.merge' % self.__name, name)
+ config.set('branch.%s.stgit.parentbranch' % self.__name, name)
def set_parent(self, remote, localbranch):
+ # policy: record local branches as remote='.'
+ recordremote = remote or '.'
if localbranch:
+ self.__set_parent_remote(recordremote)
self.__set_parent_branch(localbranch)
- if remote:
- self.__set_parent_remote(remote)
- elif remote:
- raise StackException, 'Remote "%s" without a branch cannot be used as parent' % remote
+ # We'll enforce this later
+# else:
+# raise StackException, 'Parent branch (%s) should be specified for %s' % localbranch, self.__name
def __patch_is_current(self, patch):
return patch.get_name() == self.get_current()
reply other threads:[~2007-02-04 9:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20070204094723.18334.72391.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).