@@ -94,17 +94,16 @@ pub fn add_package(app: &App, package: &NewPackage) -> CargoResult<()> {
94
94
let repo = app. git_repo . lock ( ) ;
95
95
let repo = & * repo;
96
96
let name = package. name . as_slice ( ) ;
97
- let ( c1, c2) = match name. len ( ) {
98
- 0 => unreachable ! ( ) ,
99
- 1 => ( format ! ( "{}:" , name. slice_to( 1 ) ) , format ! ( "::" ) ) ,
100
- 2 => ( format ! ( "{}" , name. slice_to( 2 ) ) , format ! ( "::" ) ) ,
101
- 3 => ( format ! ( "{}" , name. slice_to( 2 ) ) , format ! ( "{}:" , name. char_at( 2 ) ) ) ,
102
- _ => ( name. slice_to ( 2 ) . to_string ( ) , name. slice ( 2 , 4 ) . to_string ( ) ) ,
97
+ let repo_path = repo. path ( ) . dir_path ( ) ;
98
+ let dst = match name. len ( ) {
99
+ 1 => repo_path. join ( "1" ) . join ( name) ,
100
+ 2 => repo_path. join ( "2" ) . join ( name) ,
101
+ 3 => repo_path. join ( "3" ) . join ( name. slice_to ( 1 ) ) . join ( name) ,
102
+ _ => repo_path. join ( name. slice ( 0 , 2 ) )
103
+ . join ( name. slice ( 2 , 4 ) )
104
+ . join ( name) ,
103
105
} ;
104
106
105
- let part = Path :: new ( c1) . join ( c2) . join ( name) ;
106
- let dst = repo. path ( ) . dir_path ( ) . join ( & part) ;
107
-
108
107
// Attempt to commit the package in a loop. It's possible that we're going
109
108
// to need to rebase our repository, and after that it's possible that we're
110
109
// going to race to commit the changes. For now we just cap out the maximum
@@ -123,7 +122,7 @@ pub fn add_package(app: &App, package: &NewPackage) -> CargoResult<()> {
123
122
124
123
// git add $file
125
124
let mut index = try!( repo. index ( ) ) ;
126
- try!( index. add_path ( & part ) ) ;
125
+ try!( index. add_path ( & dst . path_relative_from ( & repo_path ) . unwrap ( ) ) ) ;
127
126
try!( index. write ( ) ) ;
128
127
let tree_id = try!( index. write_tree ( ) ) ;
129
128
let tree = try!( repo. find_tree ( tree_id) ) ;
0 commit comments