File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ def parser(subparsers, _):
21
21
help = 'move uncomitted changes made in the current branch to the '
22
22
'destination branch' ,
23
23
action = 'store_true' )
24
+ switch_parser .add_argument ('-mi' , '--move-ignored' ,
25
+ help = 'move ignored files to the destination branch, '
26
+ 'has no effect if --move-over is also set' ,
27
+ action = 'store_true' )
24
28
switch_parser .set_defaults (func = main )
25
29
26
30
@@ -33,6 +37,6 @@ def main(args, repo):
33
37
pprint .err_exp ('to create a new branch do gl branch -c {0}' .format (args .branch ))
34
38
return False
35
39
36
- repo .switch_current_branch (b , move_over = args .move_over )
40
+ repo .switch_current_branch (b , move_over = args .move_over , move_ignored = args . move_ignored )
37
41
pprint .ok ('Switched to branch {0}' .format (args .branch ))
38
42
return True
Original file line number Diff line number Diff line change @@ -256,13 +256,15 @@ def listall_branches(self):
256
256
"""
257
257
return self .git_repo .listall_branches (pygit2 .GIT_BRANCH_LOCAL )
258
258
259
- def switch_current_branch (self , dst_b , move_over = False ):
259
+ def switch_current_branch (self , dst_b , move_over = False , move_ignored = False ):
260
260
"""Switches to the given branch.
261
261
262
262
Args:
263
263
dst_b: the destination branch.
264
264
move_over: if True, then uncommitted changes made in the current branch are
265
265
moved to the destination branch (defaults to False).
266
+ move_ignored: if True, and move_over is False, then ignored files are moved
267
+ to the destination branch, but uncommitted changes are not (defaults to False).
266
268
"""
267
269
if dst_b .is_current :
268
270
raise ValueError (
@@ -346,7 +348,10 @@ def save(b):
346
348
347
349
if not move_over :
348
350
# Stash
349
- git .stash .save ('--all' , '--' , msg )
351
+ if move_ignored :
352
+ git .stash .save ('--include-untracked' , '--' , msg )
353
+ else :
354
+ git .stash .save ('--all' , '--' , msg )
350
355
351
356
def restore (b ):
352
357
s_id , msg = _stash (_stash_msg (b .branch_name ))
You can’t perform that action at this time.
0 commit comments