or options.edit or options.message \
or options.authname or options.authemail or options.authdate \
or options.commname or options.commemail \
- or options.sign or options.ack or options.annotate:
+ or options.sign or options.ack:
if options.patch:
applied = crt_series.get_applied()
if options.patch:
between.reverse()
push_patches(between)
+ elif options.annotate:
+ # only annotate the top log entry as there is no need to
+ # refresh the patch and generate a full commit
+ crt_series.log_patch(crt_series.get_patch(patch), None,
+ notes = options.annotate)
else:
out.info('Patch "%s" is already up to date' % patch)
"""Generate a log commit for a patch
"""
top = git.get_commit(patch.get_top())
- msg = '%s\t%s' % (message, top.get_id_hash())
- if notes:
- msg += '\n\n' + notes
-
old_log = patch.get_log()
- if old_log:
- parents = [old_log]
+
+ if message is None:
+ # replace the current log entry
+ if not old_log:
+ raise StackException, \
+ 'No log entry to annotate for patch "%s"' \
+ % patch.get_name()
+ replace = True
+ log_commit = git.get_commit(old_log)
+ msg = log_commit.get_log().split('\n')[0]
+ log_parent = log_commit.get_parent()
+ if log_parent:
+ parents = [log_parent]
+ else:
+ parents = []
else:
- parents = []
+ # generate a new log entry
+ replace = False
+ msg = '%s\t%s' % (message, top.get_id_hash())
+ if old_log:
+ parents = [old_log]
+ else:
+ parents = []
+
+ if notes:
+ msg += '\n\n' + notes
log = git.commit(message = msg, parents = parents,
cache_update = False, tree_id = top.get_tree(),
test_expect_success \
'Check the log annotation' \
'
- stg log foo | grep -q -e "\[refresh\] foo notes "
- stg log bar | grep -q -e "\[refresh\] "
+ stg log foo | grep -q -e "\[refresh\] foo notes " &&
+ stg log bar | grep -q -e "\[refresh\] " &&
+ stg refresh -p foo --annotate="foo notes 2" &&
+ stg log foo | grep -q -v -e "\[refresh\] foo notes " &&
+ stg log foo | grep -q -e "\[refresh\] foo notes 2"
'
test_expect_success \