help = 'generate a new commit for the current patch'
-usage = """%prog [options] [<files...>]
+usage = """%prog [options] [<files or dirs>]
Include the latest tree changes in the current patch. This command
generates a new GIT commit object with the patch details, the previous
-one no longer being visible. The patch attributes like author,
-committer and description can be changed with the command line
-options. The '--force' option is useful when a commit object was
-created with a different tool but the changes need to be included in
-the current patch."""
+one no longer being visible. The '--force' option is useful
+when a commit object was created with a different tool
+but the changes need to be included in the current patch."""
-directory = DirectoryGotoToplevel()
+directory = DirectoryHasRepository()
options = [make_option('-f', '--force',
help = 'force the refresh even if HEAD and '\
'top differ',
make_option('--update',
help = 'only update the current patch files',
action = 'store_true'),
+ make_option('--index',
+ help = 'use the current contents of the index instead of looking at the working directory',
+ action = 'store_true'),
make_option('--undo',
help = 'revert the commit generated by the last refresh',
action = 'store_true'),
]
def func(parser, options, args):
- autoresolved = config.get('stgit.autoresolved')
+ """Generate a new commit for the current or given patch.
+ """
+ args = git.ls_files(args)
+ directory.cd_to_topdir()
+ autoresolved = config.get('stgit.autoresolved')
if autoresolved != 'yes':
check_conflicts()
if not patch:
raise CmdException, 'No patches applied'
+ if options.index:
+ if args or options.update:
+ raise CmdException, \
+ 'Only full refresh is available with the --index option'
+ if options.patch:
+ raise CmdException, \
+ '--patch is not compatible with the --index option'
+
if not options.force:
check_head_top_equal(crt_series)
out.done()
return
- files = [path for (stat,path) in git.tree_status(verbose = True)]
- if args:
- files = [f for f in files if f in args]
+ if not options.index:
+ files = [path for (stat, path) in git.tree_status(files = args, verbose = True)]
- if files or not crt_series.head_top_equal():
+ if options.index or files or not crt_series.head_top_equal():
if options.patch:
applied = crt_series.get_applied()
between = applied[:applied.index(patch):-1]
if autoresolved == 'yes':
resolved_all()
- crt_series.refresh_patch(files = files,
- backup = True, notes = options.annotate)
+
+ if options.index:
+ crt_series.refresh_patch(cache_update = False,
+ backup = True, notes = options.annotate)
+ else:
+ crt_series.refresh_patch(files = files,
+ backup = True, notes = options.annotate)
if crt_series.empty_patch(patch):
out.done('empty patch')