git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-filter-branch: Add an example on how to remove empty commits
@ 2008-10-30  0:33 Petr Baudis
  2008-10-30  0:39 ` Sam Vilain
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Petr Baudis @ 2008-10-30  0:33 UTC (permalink / raw)
  To: git; +Cc: Sverre Rabbelier

From: Sverre Rabbelier <srabbelier@gmail.com>

Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
 Documentation/git-filter-branch.txt |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
index fed6de6..2565244 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -246,6 +246,21 @@ git filter-branch --commit-filter '
 	fi' HEAD
 ------------------------------------------------------------------------------
 
+To remove commits that are empty (do not introduce any change):
+
+------------------------------------------------------------------------------
+git rev-list HEAD | while read c; do [ -n "$(git diff-tree --root $c)" ] || echo $c; done > revs
+
+git filter-branch --commit-filter '
+  if grep -q "$GIT_COMMIT" '"$(pwd)/"revs';
+  then
+    skip_commit "$@";
+  else
+    git commit-tree "$@";
+  fi' HEAD
+
+------------------------------------------------------------------------------
+
 The function 'skip_commit' is defined as follows:
 
 --------------------------
-- 
1.5.6.3.536.g61aad

^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2009-01-11 20:56 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-30  0:33 [PATCH] git-filter-branch: Add an example on how to remove empty commits Petr Baudis
2008-10-30  0:39 ` Sam Vilain
2008-10-30  0:56 ` Johannes Schindelin
2008-10-30 13:26 ` Pierre Habouzit
2008-10-30 15:06   ` Deskin Miller
2008-10-30 15:10     ` Pierre Habouzit
2008-10-30 16:18   ` filter-branch enhancements Pierre Habouzit
2008-10-30 16:18     ` [PATCH] make git-filter-branch use parse-options Pierre Habouzit
2008-10-30 16:18       ` [Proof of concept PATCH] implement --prune-empty switch for filter-branch Pierre Habouzit
2008-10-31  8:22       ` [PATCH] make git-filter-branch use parse-options Pierre Habouzit
2008-10-31  9:26   ` [PATCH] filter-branch: add git_commit_non_empty_tree and --prune-empty Pierre Habouzit
2008-10-31 22:36     ` Johannes Schindelin
2008-10-31 22:42       ` Pierre Habouzit
2008-11-03  4:58     ` Junio C Hamano
2008-11-03  9:27       ` Pierre Habouzit
2008-11-03 15:18         ` Pierre Habouzit
2009-01-09 19:29           ` Jay Soffian
2009-01-11 11:18             ` Pierre Habouzit
2009-01-11 13:35               ` Johannes Schindelin
2009-01-11 14:27                 ` Pierre Habouzit
2009-01-11 14:40                   ` Sverre Rabbelier
2009-01-11 14:55                     ` Pierre Habouzit
2009-01-11 15:08                       ` Sverre Rabbelier
2009-01-11 20:52                   ` Junio C Hamano
2009-01-11 20:55                     ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).