from stgit.config import config
from stgit.lib import git, stack
from stgit.out import out
+from stgit import utils
-help = 'Publish the stack changes to a merge-friendly head'
+help = 'Push the stack changes to a merge-friendly branch'
kind = 'stack'
usage = ['[options] [branch]']
description = """
cd = git.CommitData(
tree = tree, parents = parents, message = message,
author = git.Person.author(), committer = git.Person.committer())
- cd = common.update_commit_data(cd, options, allow_edit = True)
+ cd = common.update_commit_data(cd, options)
return repository.commit(cd)
else:
parser.error('incorrect number of arguments')
+ if not public_ref.startswith('refs/heads/'):
+ public_ref = 'refs/heads/' + public_ref
+
# just clone the stack if the public ref does not exist
if not repository.refs.exists(public_ref):
repository.refs.set(public_ref, stack.head, 'publish')
# check for rebased stack. In this case we emulate a merge with the stack
# base by setting two parents.
merge_bases = repository.get_merge_bases(public_head, stack.base)
+ if public_head in merge_bases:
+ # fast-forward the public ref
+ repository.refs.set(public_ref, stack.head, 'publish')
+ out.info('Fast-forwarded "%s"' % public_ref)
+ return
if not stack.base in merge_bases:
- message = 'Merge %s into %s' % (repository.describe(stack.base),
- public_ref)
+ message = 'Merge %s into %s' % (repository.describe(stack.base).strip(),
+ utils.strip_prefix('refs/heads/',
+ public_ref))
public_head = __create_commit(repository, stack.head.data.tree,
[public_head, stack.base], options,
message)
cd = pc.data.set_parent(public_head)
public_head = repository.commit(cd)
public_tree = public_head.data.tree
- out.start('Published new patch "%s"' % p)
+ out.info('Published new patch "%s"' % p)
# create a new commit (only happens if no new patches are detected)
if public_tree.sha1 != stack.head.data.tree.sha1: