[StGit PATCH 09/14] Don't write a log entry if there were no changes
- From
Karl Hasselström <kha@treskal.com>
- Date
- Jun 12, 2008, 05:35 UTC
- Message-ID
- <20080612053502.23549.64988.stgit@yoghurt>
- In-Reply-To
- <20080612052913.23549.69687.stgit@yoghurt>
Some commands end up calling log_entry() without verifying that they did in fact change anything. (One example of this is a conflicting push, which will log two entries, everything else and the conflicting push, with the "everything else" part being empty if there was only one patch to push.) So before appending to the log, make sure that the entry we're appending isn't a no-op.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
stgit/lib/log.py | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/stgit/lib/log.py b/stgit/lib/log.py index 920c261..3aec6e7 100644 --- a/stgit/lib/log.py +++ b/stgit/lib/log.py @@ -164,6 +164,9 @@ def log_entry(stack, msg): out.warn(str(e), 'No log entry written.') return full_log_tree, short_log_tree = log_entry_trees(stack.repository, stack) + if len(last_log) == 1 and full_log_tree == last_log[0].full_log.data.tree: + # No changes, so there's no point writing a new log entry. + return stack_log = stack.repository.commit( git.CommitData(tree = short_log_tree, message = msg, parents = [ll.stack_log for ll in last_log]))