git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[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]))
Previous: Karl Hasselström
Message 11 of 11 in “Updated "stg reset" series”
  1. 00/10 Updated "stg reset" seriesKarl Hasselström, Apr 20, 2008
  2. 01/10 Prevent most commands from running when there are conflictsKarl Hasselström, Apr 20, 2008
  3. 02/10 Add property with a list of all patch namesKarl Hasselström, Apr 20, 2008
  4. 03/10 Library functions for tree and blob manipulationKarl Hasselström, Apr 20, 2008
  5. 04/10 Write to a stack log when stack is modifiedKarl Hasselström, Apr 20, 2008
  6. 05/10 Add utility function for reordering patchesKarl Hasselström, Apr 20, 2008
  7. 06/10 New command: stg resetKarl Hasselström, Apr 20, 2008
  8. 07/10 Log conflicts separatelyKarl Hasselström, Apr 20, 2008
  9. 08/10 Log conflicts separately for all commandsKarl Hasselström, Apr 20, 2008
  10. 09/10 Add a --hard flag to stg resetKarl Hasselström, Apr 20, 2008
  11. 10/10 Don't write a log entry if there were no changesKarl Hasselström, Apr 20, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.