From: Catalin Marinas Date: Tue, 17 Jul 2007 23:01:21 +0000 (+0100) Subject: Allow refresh --annotate to replace the top log entry X-Git-Tag: v0.13~7 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/ea7634bb704b06deebea815ead41b30ed8544866 Allow refresh --annotate to replace the top log entry If there is no changes to check in and therefore no patch commit to generate, the --annotate option simply replaces the top log with one containing the notes. Signed-off-by: Catalin Marinas --- diff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py index 7145431..8277388 100644 --- a/stgit/commands/refresh.py +++ b/stgit/commands/refresh.py @@ -128,7 +128,7 @@ def func(parser, options, args): 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() @@ -167,5 +167,10 @@ def func(parser, options, args): 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) diff --git a/stgit/stack.py b/stgit/stack.py index b03fdc0..7ffaf75 100644 --- a/stgit/stack.py +++ b/stgit/stack.py @@ -1188,15 +1188,33 @@ class Series(PatchSet): """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(), diff --git a/t/t1400-patch-history.sh b/t/t1400-patch-history.sh index b182838..b0602ff 100755 --- a/t/t1400-patch-history.sh +++ b/t/t1400-patch-history.sh @@ -44,8 +44,11 @@ test_expect_success \ 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 \