X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/de4c9d27c59100d6c2c3e04720f0c9651e58a87c..5dfb1afc61066532c8ae2b88be2dbafb31317ea1:/stgit/commands/clean.py diff --git a/stgit/commands/clean.py b/stgit/commands/clean.py index efd85c2..8f5c606 100644 --- a/stgit/commands/clean.py +++ b/stgit/commands/clean.py @@ -24,7 +24,11 @@ from stgit import stack, git help = 'delete the empty patches in the series' -usage = """%prog [options]""" +usage = """%prog [options] + +Delete the empty patches in the whole series or only those applied or +unapplied. A patch is considered empty if the two commit objects +representing its boundaries refer to the same tree object.""" options = [make_option('-a', '--applied', help = 'delete the empty applied patches', @@ -34,16 +38,20 @@ options = [make_option('-a', '--applied', action = 'store_true')] -def __delete_empty(patches, push = False): +def __delete_empty(patches, applied): """Delete the empty patches """ for p in patches: if crt_series.empty_patch(p): print 'Deleting patch "%s"...' % p, sys.stdout.flush() + + if applied and crt_series.patch_applied(p): + crt_series.pop_patch(p) crt_series.delete_patch(p) + print 'done' - elif push: + elif applied and crt_series.patch_unapplied(p): crt_series.push_patch(p) def func(parser, options, args): @@ -61,7 +69,6 @@ def func(parser, options, args): if options.applied: applied = crt_series.get_applied() - crt_series.pop_patch(applied[0]) __delete_empty(applied, True) if options.unapplied: