0

We're doing a conversion from cvs/bugzilla to git/Stash/Jira. I'm testing using git filter-branch to rewrite bugzilla bug #s in the commit messages with jira issue IDs. This works except it only affected master and not any branches. I used -- --all but didn't have any branches checked out. Is that necessary? Exact command follows:

git filter-branch -f --msg-filter 'ruby -S gitBugzillaToJira.sh' --tag-name-filter cat -- --all

Note - The gitBugzillatoJira.sh ruby script does the work to swap bugzilla number to the Jira issue ID.

Any ideas?

Roberto Tyley
  • 24,513
  • 11
  • 72
  • 101
Scott
  • 303
  • 2
  • 11
  • I'm the author of The BFG, which will offer commit message rewriting in its next release. Out of interest, how many distinct issue ids do you have to rewrite? – Roberto Tyley Aug 21 '13 at 03:33
  • ~10k issues. I've read about BFG! Even saw the video comparing BFG (on a Pi) and filter-branch. :-) I hadn't looked at it more because I had the filter-branch working (or so I thought) and now realized this issue... – Scott Aug 21 '13 at 13:35
  • @RobertoTyley Was this feature ever included in the BFG repo cleaner? I just used version 1.12.16 and I was unable to spot an option that allows changing commit messages. – lenz Jan 08 '18 at 22:13

2 Answers2

1

Your git-filter-branch incantation looks correct, it should be updating all refs that are in the local copy of your repo.

Here's a very similar demo, showing this working correctly, as expected :

$ git clone https://github.com/defunkt/github-gem.git
$ cd github-gem/
$ git filter-branch -f --msg-filter 'sed "s/e/E/g"' --tag-name-filter cat -- --all

...you'll see output like this coming back from git-filter-branch, indicating that it's updated all branches and tags (without you having to do a git checkout on them):

Rewrite 8ef0c3087d2e5d1f6fe328c06974d787b47df423 (436/436)
Ref 'refs/heads/master' was rewritten
Ref 'refs/remotes/origin/master' was rewritten
Ref 'refs/remotes/origin/fallthrough' was rewritten
Ref 'refs/remotes/origin/gist' was rewritten
Ref 'refs/remotes/origin/keithpitt-ruby-1.9-update' was rewritten
WARNING: Ref 'refs/remotes/origin/master' is unchanged
Ref 'refs/remotes/origin/organizations' was rewritten
Ref 'refs/remotes/origin/upload' was rewritten
Ref 'refs/tags/REL-0.4.2' was rewritten

What output do you get from this part of your git filter-branch run?

Roberto Tyley
  • 24,513
  • 11
  • 72
  • 101
  • Thanks for your comments. I voted your answer up for being helpful. As evidenced below I now realize it wasn't git filter-branch that was the problem after all. It was my git-push incantation! – Scott Aug 22 '13 at 01:55
0

User Error!

Like the image says, it was case of user error! After getting 3rd party confirmation my git-filter-branch should work I realized I only had done git push so only locally checked out branches were pushed. Looks like I should git push --all to update all refs. Now, I need to figure out why I'm getting 3 references to master along with my other branches:

* [new branch]      refs/original/refs/heads/master -> refs/original/refs/heads/master
* [new branch]      refs/original/refs/remotes/origin/master -> refs/original/refs/remotes/origin/master
* [new branch]      origin/master -> origin/master
Scott
  • 303
  • 2
  • 11
  • I shoulda searched SO, first. From http://stackoverflow.com/questions/7654822/remove-refs-original-heads-master-from-git-repo-after-filter-branch-tree-filte refs/original/* is the back up copy that I read about with refs/heads/master being the head pointer to my local master and refs/remotes/origin/master being the master branch – Scott Aug 22 '13 at 02:02