Skip to content

Commit 3651330

Browse files
Corner, Bradleysergiomb2
authored andcommitted
Fix for git localized messages issue, and also fixes _gc is already running_ message
1 parent 7c2a052 commit 3651330

File tree

3 files changed

+131
-17
lines changed

3 files changed

+131
-17
lines changed

ChangeLog.md

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,40 @@
88
* Added the ability to specify the '--branches' and '--tags' arguments multiple times (thanks pdf).
99
* Fixed a problem with processing of the '--exclude' argument (improper quoting internally) (thanks pdf).
1010

11+
# 2.3.3 - 2016-03-02
12+
This is a bugfix release. It provides fix for git localized messages issue, and also fixes "gc is already running" message.
13+
14+
As git2svn runs git to do it's things (and analyzes it's responses in some points), it is necessary to set LANGUAGE environment variable to "en_US" to fix this kind of error:
15+
16+
Running command: git branch --track "<some_branch_here>" "remotes/svn/<some_branch_here>"
17+
fatal: Не удалось настроить информацию отслеживания; стартовая точка «remotes/svn/<some_branch_here>» не является веткой.
18+
********************************************************************
19+
svn2git warning: Tracking remote SVN branches is deprecated.
20+
In a future release local branches will be created without tracking.
21+
If you must resync your branches, run: svn2git --rebase
22+
********************************************************************
23+
Running command: git checkout "<some_branch_here>"
24+
error: pathspec '<some_branch_here>' did not match any file(s) known to git.
25+
command failed:
26+
git checkout "<some_branch_here>"
27+
28+
Notice localized message of git output. You can fix it with new key `--force-en-us-to-git`.
29+
30+
Also there was changes in git, which triggers `git gc --auto` after some point of modifications to local git repo, so now svn2git modifies `gc.auto` option, sets it to `0` to disable automatic packing of loose objects.
31+
This fixes failing at the end of svn2git script, where it calls `git gc` explicitly:
32+
33+
Running command: git gc
34+
fatal: gc is already running on machine '<machine_name>' pid <pid> (use --force if not)
35+
command failed:
36+
git gc
37+
38+
For me, `gc ---auto` starts just after `fetch`, and while svn2git finishes it's work (really fast) it stays running. When svn2git starts `git gc` explicitly, this new process conflicts with already running process, causing an error message.
39+
40+
1141
# 2.3.2 - 2014-06-08
1242

1343
This is a bugfix release. It fixes issues running with Windows using MRI ruby and fixes a problem with Ruby 1.8.7.
14-
44+
1545
* Removed open4 dependency. svn2git no longer has any runtime dependencies and things work well on Windows again.
1646
* Fixed an issue with Ruby 1.8.7, which doesn't implicitly require the 'thread' library meaning classes that library weren't in scope.
1747

@@ -23,20 +53,20 @@
2353
issue a "git pull" to fetch the changes. git-svn ceased allowing this in 1.8.3.2, which broke svn2git with that
2454
version of git and all subsequent versions. The rationale seemed to be in order to prevent pushing changes from
2555
git-svn back up and breaking the remote link, but this was never something svn2git supported anyway.
26-
56+
2757
Acknowledging the new reality of upstream, the old behavior is retained but deprecated for users of git < 1.8.3.2.
2858
We'll be removing the establishment of remote tracking SVN branches in the 2.5.0 release. If you wish to sync back
2959
with upstream, run `svn2git --rebase`. If you're on git >= 1.8.3.2 your only option for resynchronizing is to
3060
use `svn2git --rebase`.
31-
61+
3262
Many thanks to ktdreyer for modernizing the test suite and Daniel Ruf (DanielRuf) for pushing on the git compatibility
3363
issue.
34-
64+
3565
* Fixed creating local branches for remote SVN branches in git >= 1.8.3.2.
3666
* Fixed verbose logging of sub-process STDERR stream.
3767
* Added MIT license metadata to gemspec.
3868
* Switched to minitest to get tests working on Ruby 1.9+ with minitest 5+ installed.
39-
69+
4070

4171
# 2.3.0 - 2014-05-14
4272

@@ -112,7 +142,7 @@
112142

113143
Thanks to Francois Rey (fmjrey), Sven Axelsson (svenax), and Julian Taylor (juliantaylor) for submitting all the patches
114144
that comprise this release. svn2git now works with a much wider array SVN repositories because of their efforts.
115-
145+
116146
* Added --no-minimize-url option for migrating specific subprojects from an SVN repo containing several projects (thanks fmjrey).
117147
* Added --username option for migrating password-protected repositories (thanks svenax).
118148
* Added --revision option for specifying the revision to start importing from (thanks svenax).
@@ -147,7 +177,7 @@
147177
# 1.3.1 - 2009-06-09
148178

149179
Thanks to KUBO Atsuhiro (iteman) for finding a problem with the tagging process and providing a patch.
150-
180+
151181
* Fixed a problem with creating actual git tags when the SVN tags path was named anything other than 'tags.'
152182

153183
# 1.3.0 - 2009-06-09
@@ -182,14 +212,14 @@
182212
* Improved docs.
183213

184214
# 1.1.1 - 2009-04-15
185-
215+
186216
* Started using Jeweler for gem management.
187217
* Fixed issue with not loading up RubyGems appropriately.
188218

189219
# 1.1.0 - 2009-01-02
190220

191221
* First release since nirvdrum fork.
192-
222+
193223
* Fixed issues with handling of tags and branches.
194224
* Added better logging of output from git-svn.
195225
* Wrap external command processing to capture failures.

README.md

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,59 @@ Make sure you have git, git-svn, and ruby installed. svn2git is a ruby wrapper
6868

6969
$ sudo apt-get install git-core git-svn ruby
7070

71-
Once you have the necessary software on your system, you can install svn2git through rubygems, which will add the `svn2git` command to your PATH.
71+
Once you have the necessary software on your system, you can install svn2git through rubygems, which will add the `svn2git` command to your PATH.
7272

7373
$ sudo gem install svn2git
7474

75+
Some hints before you start
76+
-----
77+
In Ubuntu 14.04 you have to install latest git and subversion versions to successfully done conversion.
78+
This fixes "error: git-svn died of signal 11" issue.
79+
80+
Upgrade can be done using PPAs:
81+
[https://launchpad.net/~dominik-stadler/+archive/ubuntu/subversion-1.9](https://launchpad.net/~dominik-stadler/+archive/ubuntu/subversion-1.9)
82+
[https://launchpad.net/~git-core/+archive/ubuntu/ppa](https://launchpad.net/~git-core/+archive/ubuntu/ppa)
83+
84+
To add each ppa use commands:
85+
86+
$ sudo add-apt-repository ppa:dominik-stadler/subversion-1.9
87+
$ sudo add-apt-repository ppa:git-core/ppa
88+
89+
or add -E to sudo if you are using proxy to preserve environment variables with proxy information
90+
91+
$ sudo -E add-apt-repository ppa:dominik-stadler/subversion-1.9
92+
$ sudo -E add-apt-repository ppa:git-core/ppa
93+
94+
After that update repository cache and upgrade packages
95+
96+
$ sudo apt-get update
97+
$ sudo apt-get install git-core git-svn subversion
98+
99+
This will upgrade git, git-svn and subversion to latest version (as for 2016-03-02)
100+
101+
Also if you get this kind of error
102+
103+
Running command: git branch --track "<some_branch_here>" "remotes/svn/<some_branch_here>"
104+
fatal: Не удалось настроить информацию отслеживания; стартовая точка «remotes/svn/<some_branch_here>» не является веткой.
105+
********************************************************************
106+
svn2git warning: Tracking remote SVN branches is deprecated.
107+
In a future release local branches will be created without tracking.
108+
If you must resync your branches, run: svn2git --rebase
109+
********************************************************************
110+
Running command: git checkout "<some_branch_here>"
111+
error: pathspec '<some_branch_here>' did not match any file(s) known to git.
112+
command failed:
113+
git checkout "<some_branch_here>"
114+
115+
Notice localized message of git. As svn2git script analyzes git answer here, force English messages from git, using new key `--force-en-us-to-git` (testing feature).
116+
This sets LANGUAGE environment variable to "en_US" for svn2git and its child processes.
117+
118+
Also if you have to provide a password to subversion repository and stuck on
119+
120+
Authentication realm: <http://your_subversion_repository.domain> CollabNet Subversion Repository
121+
Password for '<your_login>':
122+
123+
then try to invoke in console `svn co` first to authorize at subversion repo, it will cache your visit, and then rerun svn2git command.
75124

76125
Usage
77126
-----
@@ -143,6 +192,16 @@ specified trunk=foo branches=bar and tags=foobar it would be referencing
143192
http://svn.example.com/path/to/repo/foo as your trunk, and so on. However, in
144193
case 4 it references the root of the repo as trunk.
145194

195+
### Tags Notice ###
196+
197+
Notice, that if you want to push tags also to git repo, you need to run not only
198+
199+
git push origin --all
200+
201+
but also
202+
203+
git push origin --tags
204+
146205
### Repository Updates ###
147206

148207
As of svn2git 2.0 there is a new feature to pull in the latest changes from SVN into your
@@ -202,11 +261,11 @@ Options Reference
202261

203262
$ svn2git --help
204263
Usage: svn2git SVN_URL [options]
205-
264+
206265
Specific options:
207266
--rebase Instead of cloning a new project, rebase an existing one against SVN
208267
--username NAME Username for transports that needs it (http(s), svn)
209-
--password PASS Password for transports that needs it (http(s), svn)
268+
--password PASSWORD Password for transports that needs it (http(s), svn)
210269
--trunk TRUNK_PATH Subpath to trunk from repository URL (default: trunk)
211270
--branches BRANCHES_PATH Subpath to branches from repository URL (default: branches); can be used multiple times
212271
--tags TAGS_PATH Subpath to tags from repository URL (default: tags); can be used multiple times
@@ -221,7 +280,9 @@ Options Reference
221280
--authors AUTHORS_FILE Path to file containing svn-to-git authors mapping (default: ~/.svn2git/authors)
222281
--exclude REGEX Specify a Perl regular expression to filter paths when fetching; can be used multiple times
223282
-v, --verbose Be verbose in logging -- useful for debugging issues
224-
283+
--rebasebranch REBASEBRANCH Rebase specified branch.
284+
--force-en-us-to-git Force en_US locale to be used by git commands, called by this script.
285+
225286
-h, --help Show this message
226287

227288
FAQ
@@ -234,9 +295,9 @@ FAQ
234295
Those commits are the first (head) commit of branch in svn that is
235296
associated with that tag. If you want to see all the branches and tags
236297
and their relationships in gitk you can run the following: gitk --all
237-
298+
238299
For further details please refer to FAQ #2.
239-
300+
240301
2. Why don't you reference the parent of the tag commits instead?
241302

242303
In svn you are forced to create what are known in git as annotated tags.
@@ -246,11 +307,10 @@ FAQ
246307
treated as an annotated tag. Hence, for there to be a true 1-to-1 mapping
247308
between git and svn we have to transfer over the svn commit which acts as
248309
an annotated tag and then tag that commit in git using an annotated tag.
249-
310+
250311
If we were to reference the parent of this svn tagged commit there could
251312
potentially be situations where a developer would checkout a tag in git
252313
and the resulting code base would be different than if they checked out
253314
that very same tag in the original svn repo. This is only due to the fact
254315
that the svn tags allow changesets in them, making them not just annotated
255316
tags.
256-

lib/svn2git/migration.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ def initialize(args)
2626
end
2727

2828
def run!
29+
log "LANGUAGE is: #{ENV["LANGUAGE"]}\n"
30+
if @options[:forceenustogit]
31+
log "Set LANGUAGE environment variable to \"en_US.\"\n"
32+
ENV["LANGUAGE"]="en_US"
33+
log "LANGUAGE is: #{ENV["LANGUAGE"]}\n"
34+
end
35+
2936
if @options[:rebase]
3037
get_branches
3138
elsif @options[:rebasebranch]
@@ -37,6 +44,13 @@ def run!
3744
fix_tags
3845
fix_trunk
3946
optimize_repos
47+
48+
ensure
49+
unless @gc_auto_is_off.nil?
50+
run_command("#{git_config_command} --get gc.auto", false)
51+
run_command("#{git_config_command} --unset gc.auto")
52+
run_command("#{git_config_command} --get gc.auto", false)
53+
end
4054
end
4155

4256
def parse(args)
@@ -54,6 +68,7 @@ def parse(args)
5468
options[:username] = nil
5569
options[:password] = nil
5670
options[:rebasebranch] = false
71+
options[:forceenustogit] = false
5772

5873
if File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE))
5974
options[:authors] = DEFAULT_AUTHORS_FILE
@@ -138,6 +153,10 @@ def parse(args)
138153
options[:rebasebranch] = rebasebranch
139154
end
140155

156+
opts.on('--force-en-us-to-git', 'Force en_US locale to be used by git commands, called by this script.') do
157+
options[:forceenustogit] = true
158+
end
159+
141160
opts.separator ""
142161

143162
# No argument, shows at tail. This will print an options summary.
@@ -224,6 +243,11 @@ def clone!
224243
run_command(cmd, true, true)
225244
end
226245

246+
run_command("#{git_config_command} --get gc.auto", false)
247+
run_command("#{git_config_command} gc.auto 0")
248+
gc_auto_is_off = true
249+
run_command("#{git_config_command} --get gc.auto", false)
250+
227251
run_command("#{git_config_command} svn.authorsfile #{authors}") unless authors.nil?
228252

229253
cmd = "git svn fetch "

0 commit comments

Comments
 (0)