Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0ce14aa

Browse files
authored
Merge pull request #234 from Mooninaut/add-no-ignored-flag-to-gl-switch
Add --move-ignored / -mi flag to "gl switch".
2 parents b45cd2d + 799ce69 commit 0ce14aa

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

gitless/cli/gl_switch.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ def parser(subparsers, _):
2121
help='move uncomitted changes made in the current branch to the '
2222
'destination branch',
2323
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')
2428
switch_parser.set_defaults(func=main)
2529

2630

@@ -33,6 +37,6 @@ def main(args, repo):
3337
pprint.err_exp('to create a new branch do gl branch -c {0}'.format(args.branch))
3438
return False
3539

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)
3741
pprint.ok('Switched to branch {0}'.format(args.branch))
3842
return True

gitless/core.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,15 @@ def listall_branches(self):
256256
"""
257257
return self.git_repo.listall_branches(pygit2.GIT_BRANCH_LOCAL)
258258

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):
260260
"""Switches to the given branch.
261261
262262
Args:
263263
dst_b: the destination branch.
264264
move_over: if True, then uncommitted changes made in the current branch are
265265
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).
266268
"""
267269
if dst_b.is_current:
268270
raise ValueError(
@@ -346,7 +348,10 @@ def save(b):
346348

347349
if not move_over:
348350
# 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)
350355

351356
def restore(b):
352357
s_id, msg = _stash(_stash_msg(b.branch_name))

0 commit comments

Comments
 (0)