Skip to contentSkip to conversation

Documentation/git-filter-branch: add a new commit-filter example

PATCH In review Miklos Vajna 3 participants 6 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Documentation/git-filter-branch: add a new commit-filter example

There is a commit-filter example already which skips commits but there is no example on how to edit commit messages.

One can figure out this example by carefully reading the git-filter-branch and git-commit-tree documentation but I think it isn't trivial so this example is helpful.

---

The lack of such an example was noticed by dvorak on IRC.

 Documentation/git-filter-branch.txt |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
Documentation/git-filter-branch.txt +6 -0
index e22dfa5..a035b9c 100644
@@ -240,6 +240,12 @@ committed a merge between P1 and P2, it will be propagated properly
 and all children of the merge will become merge commits with P1,P2
 as their parents instead of the merge commit.
 
+To remove the 'git-svn-id' strings from commit messages in a repository created
+by git-svn:
+
+------------------------------------------------------------------------------
+git filter-branch --commit-filter 'sed "/^git-svn-id:/d" |git commit-tree "$@"'
+------------------------------------------------------------------------------
 
 To restrict rewriting to only part of the history, specify a revision
 range in addition to the new branch name.  The new branch name will
Signature · 1 line
1.5.4.2
#1 lore raw
Quoted 20 lines · Miklos Vajna

There is a commit-filter example already which skips commits but there is no example on how to edit commit messages.

One can figure out this example by carefully reading the git-filter-branch and git-commit-tree documentation but I think it isn't trivial so this example is helpful.

---

The lack of such an example was noticed by dvorak on IRC.

 Documentation/git-filter-branch.txt |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
Documentation/git-filter-branch.txt +0 -0
index e22dfa5..a035b9c 100644

Documentation/git-filter-branch.txt committed a merge between P1 and P2, it will be propagated properly · line 244

Quoted 5 lines
Documentation/git-filter-branch.txt +2 -0
@@ -240,6 +240,12 @@ committed a merge between P1 and P2, it will be propagated properly
 and all children of the merge will become merge commits with P1,P2
 as their parents instead of the merge commit.
 
+To remove the 'git-svn-id' strings from commit messages in a repository created
+by git-svn:

People who are not interested in git-svn at all may still want to fix up their commit log messages, and I think starting a paragraph with 'git-svn-blah' would risk them skipping it without reading (I certainly would). Probably we would want to add a sentence before "To remove ...", like this:

You can rewrite the commit log messages using --commit-filter. For example, git-svn-id strings in a repository created with git-svn can be cleaned up this way:

Documentation/git-filter-branch.txt committed a merge between P1 and P2, it will be propagated properly · line 248

Quoted 3 lines
Documentation/git-filter-branch.txt +3 -0
+------------------------------------------------------------------------------
+git filter-branch --commit-filter 'sed "/^git-svn-id:/d" |git commit-tree "$@"'
+------------------------------------------------------------------------------

Please try to keep them a bit shorter for reviewing pleasure on 80-column terminals after your message was quoted once or perhaps a few times. The example is easier to read if you write like this, I think:

----------------------------------------------------------------
git filter-branch --commit-filter '

	sed -e "/^git-svn-id:/d" | git commit-tree "$@"

'
----------------------------------------------------------------

I am not sure if git-svn people condone or encourage such removals, though.

#2 lore raw

PATCH 1/1 Documentation/git-filter-branch: add a new commit-filter example

There is a commit-filter example already which skips commits but there is no example on how to edit commit messages.

One can figure out this example by carefully reading the git-filter-branch and git-commit-tree documentation but I think it isn't trivial so this example is helpful.

---

Quoted 9 lines · Junio C Hamano

People who are not interested in git-svn at all may still want to fix up their commit log messages, and I think starting a paragraph with 'git-svn-blah' would risk them skipping it without reading (I certainly would). Probably we would want to add a sentence before "To remove ...", like this:

You can rewrite the commit log messages using --commit-filter. For example, git-svn-id strings in a repository created with git-svn can be cleaned up this way:

second try follows :)

Quoted 11 lines
Quoted 5 lines
+------------------------------------------------------------------------------
+git filter-branch --commit-filter 'sed "/^git-svn-id:/d" |git

commit-tree "$@"'
+------------------------------------------------------------------------------

Please try to keep them a bit shorter for reviewing pleasure on 80-column terminals after your message was quoted once or perhaps a few times. The example is easier to read if you write like this, I think:

Quoted 6 lines

----------------------------------------------------------------
git filter-branch --commit-filter '

      sed -e "/^git-svn-id:/d" | git commit-tree "$@"

'
----------------------------------------------------------------

ok. i used 72 in my mails and 80 in the code, but now i'm using 72 in the code as well.

Quoted 2 lines

I am not sure if git-svn people condone or encourage such removals, though.

i think it's only useful if you use git-svn for an svn -> git conversion, provided that the project switches to git (there will be no more svn commits and noone wants to push back git commits to svn).

 Documentation/git-filter-branch.txt |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
Documentation/git-filter-branch.txt +9 -0
index e22dfa5..367064b 100644
@@ -240,6 +240,15 @@ committed a merge between P1 and P2, it will be propagated properly
 and all children of the merge will become merge commits with P1,P2
 as their parents instead of the merge commit.
 
+You can rewrite the commit log messages using `--commit-filter`.  For
+example, `git-svn-id` strings in a repository created by `git-svn` can
+be removed this way:
+
+-------------------------------------------------------
+git filter-branch --commit-filter '
+	sed -e "/^git-svn-id:/d" | git commit-tree "$@"
+'
+-------------------------------------------------------
 
 To restrict rewriting to only part of the history, specify a revision
 range in addition to the new branch name.  The new branch name will
Signature · 1 line
1.5.4.2
#3 lore raw

Hi,

Documentation/git-filter-branch.txt committed a merge between P1 and P2, it will be propagated properly · line 251

Quoted 5 lines · Miklos Vajna

+-------------------------------------------------------

Documentation/git-filter-branch.txt +4 -0
+git filter-branch --commit-filter '
+	sed -e "/^git-svn-id:/d" | git commit-tree "$@"
+'
+-------------------------------------------------------

And there I thought that was the job of --msg-filter ;-)

Ciao,
Dscho

#4 lore raw
Quoted 9 lines · Johannes Schindelin

Documentation/git-filter-branch.txt committed a merge between P1 and P2, it will be propagated properly · line 251

Quoted 5 lines · Miklos Vajna

+-------------------------------------------------------

Documentation/git-filter-branch.txt +4 -0
+git filter-branch --commit-filter '
+	sed -e "/^git-svn-id:/d" | git commit-tree "$@"
+'
+-------------------------------------------------------

And there I thought that was the job of --msg-filter ;-)

Ahhhhhhh, that was the little voice that kept telling me there is something wrong with the patch...

#5 lore raw

PATCH 1/1 Documentation/git-filter-branch: add a new msg-filter example

There were no example on how to edit commit messages, so add an msg-filter example.

---

Quoted 2 lines · Junio C Hamano

Ahhhhhhh, that was the little voice that kept telling me there is something wrong with the patch...

uh-oh. third try :)

 Documentation/git-filter-branch.txt |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
Documentation/git-filter-branch.txt +9 -0
index e22dfa5..1948f6f 100644
@@ -240,6 +240,15 @@ committed a merge between P1 and P2, it will be propagated properly
 and all children of the merge will become merge commits with P1,P2
 as their parents instead of the merge commit.
 
+You can rewrite the commit log messages using `--message-filter`.  For
+example, `git-svn-id` strings in a repository created by `git-svn` can
+be removed this way:
+
+-------------------------------------------------------
+git filter-branch --message-filter '
+	sed -e "/^git-svn-id:/d"
+'
+-------------------------------------------------------
 
 To restrict rewriting to only part of the history, specify a revision
 range in addition to the new branch name.  The new branch name will
Signature · 1 line
1.5.4.3