Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protecting branches with a slash #34

Closed
warrenseine opened this issue Mar 17, 2014 · 5 comments
Closed

Protecting branches with a slash #34

warrenseine opened this issue Mar 17, 2014 · 5 comments

Comments

@warrenseine
Copy link

I'd like to protect the tip of a branch which has a slash in its name: feature/worker-prototype.

When I run the BFG on the repository while protecting the branch, JGit doesn't like the "/" and throw an exception.

Exception in thread "main" java.lang.IllegalArgumentException: / is not permitted as a path 'segment' for this filesystem. Segment in question: 991564ae-feature/worker-prototype.csv. If you want to create a Path from a system dependent string then use fromString. If you want to create a child path use resolve instead of / to create the child path. It should be noted that the string after '/' must be a single segment but resolve accepts full strings. Examples: Path.fromString("c: \a\b") path / ("a/b/c", '/') path resolve "a\b\c" at scalax.file.FileSystem.checkSegmentForSeparators(FileSystem.scala:280) at scalax.file.defaultfs.DefaultPath.$div(DefaultPath.scala:44) at com.madgag.git.bfg.cleaner.CLIReporter$$anonfun$reportProtectedCommitsAndTheirDirt$1.apply(Reporter.scala:122) at com.madgag.git.bfg.cleaner.CLIReporter$$anonfun$reportProtectedCommitsAndTheirDirt$1.apply(Reporter.scala:108) at scala.collection.immutable.List.foreach(List.scala:318) at com.madgag.git.bfg.cleaner.CLIReporter.reportProtectedCommitsAndTheirDirt(Reporter.scala:107) at com.madgag.git.bfg.cleaner.CLIReporter.reportObjectProtection(Reporter.scala:80) at com.madgag.git.bfg.cleaner.RepoRewriter$.rewrite(RepoRewriter.scala:96) at com.madgag.git.bfg.cli.Main$$anonfun$1.apply(Main.scala:59) at com.madgag.git.bfg.cli.Main$$anonfun$1.apply(Main.scala:34) at scala.Option.map(Option.scala:145) at com.madgag.git.bfg.cli.Main$delayedInit$body.apply(Main.scala:33) at scala.Function0$class.apply$mcV$sp(Function0.scala:40) at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) at scala.App$$anonfun$main$1.apply(App.scala:71) at scala.App$$anonfun$main$1.apply(App.scala:71) at scala.collection.immutable.List.foreach(List.scala:318) at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32) at scala.App$class.main(App.scala:71) at com.madgag.git.bfg.cli.Main$.main(Main.scala:27) at com.madgag.git.bfg.cli.Main.main(Main.scala)

Using BFG 1.11. Is there a fix / an easy workaround?

@rtyley
Copy link
Owner

rtyley commented Mar 17, 2014

Can you supply the exact command line invocation you're using?

@warrenseine
Copy link
Author

java -jar bfg-1.11.1.jar --strip-blobs-bigger-than 100K -p 'feature/worker-prototype' my-repo.git

@rtyley
Copy link
Owner

rtyley commented Mar 18, 2014

Ah, ok, I think I see the problem. It's to do with this line here:

https://github.com/rtyley/bfg-repo-cleaner/blob/3021459/bfg-library/src/main/scala/com/madgag/git/bfg/cleaner/Reporter.scala#L122

The code wasn't expecting branch names with a slash (because, like, obviously those are ug-lee). I'll release a fix within a couple of days, but for the time being, here's your workaround - don't refer to that ref by the 'slashed' name - use a simple-named ref instead:

$ git tag nice-simple-name feature/worker-prototype
$ java -jar bfg-1.11.1.jar --strip-blobs-bigger-than 100K -p 'nice-simple-name' my-repo.git

@warrenseine
Copy link
Author

Ok, thanks for the workaround!

rtyley added a commit that referenced this issue Mar 21, 2014
Eg this crashed:

$ java -jar bfg-1.11.1.jar --strip-blobs-bigger-than 100K -p 'feature/worker-prototype' my-repo.git

The code wasn't expecting branch names with a slash (because, like,
obviously those are ug-lee) - and it's not possible to create filenames
that contain slashes:

#34
abaga129 pushed a commit to abaga129/glean that referenced this issue Jul 18, 2019
Eg this crashed:

$ java -jar bfg-1.11.1.jar --strip-blobs-bigger-than 100K -p 'feature/worker-prototype' my-repo.git

The code wasn't expecting branch names with a slash (because, like,
obviously those are ug-lee) - and it's not possible to create filenames
that contain slashes:

rtyley/bfg-repo-cleaner#34
@plcarmel
Copy link

plcarmel commented Nov 3, 2021

It doesn't work for me with version 2.14. I have to rename the branches that contain slashes. Maybe it is because I am using it on Windows ?

Caused by: java.io.FileNotFoundException: C:\path\to\project.git.bfg-report\2021-11-03\13-56-47\protected-dirt\359fa679-releases\something\10.0.csv (Le chemin dÆaccΦs spΘcifiΘ est introuvable)
        at java.io.FileOutputStream.open0(Native Method)
        at java.io.FileOutputStream.open(Unknown Source)
        at java.io.FileOutputStream.<init>(Unknown Source)
        at com.google.common.io.Files$FileByteSink.openStream(Files.java:193)
        at com.google.common.io.Files$FileByteSink.openStream(Files.java:181)
        at com.google.common.io.ByteSink$AsCharSink.openStream(ByteSink.java:149)
        at com.google.common.io.CharSink.openBufferedStream(CharSink.java:81)
        at com.google.common.io.CharSink.writeLines(CharSink.java:159)
        at com.google.common.io.CharSink.writeLines(CharSink.java:126)
        at com.madgag.git.bfg.cleaner.Reporter$.dump(Reporter.scala:31)
        at com.madgag.git.bfg.cleaner.CLIReporter.$anonfun$reportProtectedCommitsAndTheirDirt$3(Reporter.scala:158)
        at com.madgag.git.bfg.cleaner.CLIReporter.$anonfun$reportProtectedCommitsAndTheirDirt$3$adapted(Reporter.scala:136)
        at scala.collection.immutable.HashSet.foreach(HashSet.scala:937)
        at com.madgag.git.bfg.cleaner.CLIReporter.reportProtectedCommitsAndTheirDirt(Reporter.scala:136)
        at com.madgag.git.bfg.cleaner.CLIReporter.reportObjectProtection(Reporter.scala:106)
        at com.madgag.git.bfg.cleaner.RepoRewriter$.rewrite(RepoRewriter.scala:96)
        at com.madgag.git.bfg.cli.Main$.$anonfun$new$1(Main.scala:59)
        at com.madgag.git.bfg.cli.Main$.$anonfun$new$1$adapted(Main.scala:34)
        at scala.Option.map(Option.scala:242)
        at com.madgag.git.bfg.cli.Main$.delayedEndpoint$com$madgag$git$bfg$cli$Main$1(Main.scala:34)
        at com.madgag.git.bfg.cli.Main$delayedInit$body.apply(Main.scala:27)
        at scala.Function0.apply$mcV$sp(Function0.scala:39)
        at scala.Function0.apply$mcV$sp$(Function0.scala:39)
        at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
        at scala.App.$anonfun$main$1(App.scala:76)
        at scala.App.$anonfun$main$1$adapted(App.scala:76)
        at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
        at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:919)
        at scala.App.main(App.scala:76)
        at scala.App.main$(App.scala:74)
        at com.madgag.git.bfg.cli.Main$.main(Main.scala:27)
        at com.madgag.git.bfg.cli.Main.main(Main.scala)
        ... 8 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants