[StGit PATCH 10/10] Don't write a log entry if there were no changes
- From
Karl Hasselström <kha@treskal.com>
- Date
- Apr 20, 2008, 22:11 UTC
- Message-ID
- <20080420221118.5837.38770.stgit@yoghurt>
- In-Reply-To
- <20080420215625.5837.82896.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 9904941..a18c80e 100644 --- a/stgit/lib/log.py +++ b/stgit/lib/log.py @@ -49,6 +49,9 @@ def log_entry(stack, msg): out.warn(str(e), 'No log entry written.') return log_tree = log_entry_tree(stack.repository, stack) + if len(last_log) == 1 and 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 = log_tree, message = msg, parents = [ll.stack_log for ll in last_log]))