Skip to content

Commit b549392

Browse files
committed
Merge branch 'rebase'
* rebase: cmds: do not display errors when cancelling a rebase xbase: save empty files when GIT_XBASE_CANCEL_ACTION=save xbase: refactor save() into a function Closes git-cola#826 Signed-off-by: David Aguilar <davvid@gmail.com>
2 parents 21e557f + 09421a0 commit b549392

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

cola/cmds.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,7 @@ def __init__(self, **kwargs):
16031603
self.env = {
16041604
'GIT_EDITOR': prefs.editor(),
16051605
'GIT_SEQUENCE_EDITOR': sequence_editor(),
1606+
'GIT_XBASE_CANCEL_ACTION': 'save',
16061607
}
16071608
self.env.update(kwargs)
16081609

@@ -1667,9 +1668,9 @@ def do(self):
16671668
# as much effort.
16681669
status, out, err = self.model.git.rebase(*args, _no_win32_startupinfo=True, **kwargs)
16691670
self.model.update_status()
1670-
title = N_('Rebase stopped')
1671-
Interaction.command(title, 'git rebase', status, out, err)
1672-
1671+
if err.strip() != 'Nothing to do':
1672+
title = N_('Rebase stopped')
1673+
Interaction.command(title, 'git rebase', status, out, err)
16731674
return status, out, err
16741675

16751676

share/doc/git-cola/relnotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ Usability, bells and whistles
2020

2121
https://github.com/git-cola/git-cola/pull/813
2222

23+
* The `git xbase` rebase editor no longer displays an error when
24+
cancelling an interactive rebase.
25+
26+
https://github.com/git-cola/git-cola/issues/814
27+
2328
Fixes
2429
-----
2530
* The DAG window now updates itself when branches and tags are created.

share/git-cola/bin/git-xbase

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class Editor(QtWidgets.QWidget):
159159
self.context = context
160160
self.filename = filename
161161
self.comment_char = comment_char = prefs.comment_char()
162+
self.cancel_action = core.getenv('GIT_XBASE_CANCEL_ACTION', 'abort')
162163

163164
self.notifier = notifier = observable.Observable()
164165
self.diff = diff.DiffWidget(notifier, context, self)
@@ -255,21 +256,31 @@ class Editor(QtWidgets.QWidget):
255256

256257
# actions
257258
def cancel(self):
258-
self.status = 1
259-
self.exit.emit(1)
259+
if self.cancel_action == 'save':
260+
status = self.save('')
261+
else:
262+
status = 1
263+
264+
self.status = status
265+
self.exit.emit(status)
260266

261267
def rebase(self):
262268
lines = [item.value() for item in self.tree.items()]
263269
sequencer_instructions = '\n'.join(lines) + '\n'
270+
status = self.save(sequencer_instructions)
271+
self.status = status
272+
self.exit.emit(status)
273+
274+
def save(self, string):
275+
"""Save the instruction sheet"""
264276
try:
265-
core.write(self.filename, sequencer_instructions)
266-
self.status = 0
267-
self.exit.emit(0)
277+
core.write(self.filename, string)
278+
status = 0
268279
except Exception as e:
269280
msg, details = utils.format_exception(e)
270281
sys.stderr.write(msg + '\n\n' + details)
271-
self.status = 128
272-
self.exit.emit(128)
282+
status = 128
283+
return status
273284

274285
def external_diff(self):
275286
items = self.tree.selected_items()

0 commit comments

Comments
 (0)