@@ -35,6 +35,7 @@ struct backfill_context {
3535 struct oid_array current_batch ;
3636 size_t min_batch_size ;
3737 int sparse ;
38+ struct rev_info revs ;
3839};
3940
4041static void backfill_context_clear (struct backfill_context * ctx )
@@ -80,7 +81,6 @@ static int fill_missing_blobs(const char *path UNUSED,
8081
8182static int do_backfill (struct backfill_context * ctx )
8283{
83- struct rev_info revs ;
8484 struct path_walk_info info = PATH_WALK_INFO_INIT ;
8585 int ret ;
8686
@@ -92,13 +92,14 @@ static int do_backfill(struct backfill_context *ctx)
9292 }
9393 }
9494
95- repo_init_revisions (ctx -> repo , & revs , "" );
96- handle_revision_arg ("HEAD" , & revs , 0 , 0 );
95+ /* Walk from HEAD if otherwise unspecified. */
96+ if (!ctx -> revs .pending .nr )
97+ handle_revision_arg ("HEAD" , & ctx -> revs , 0 , 0 );
9798
9899 info .blobs = 1 ;
99100 info .tags = info .commits = info .trees = 0 ;
100101
101- info .revs = & revs ;
102+ info .revs = & ctx -> revs ;
102103 info .path_fn = fill_missing_blobs ;
103104 info .path_fn_data = ctx ;
104105
@@ -109,7 +110,6 @@ static int do_backfill(struct backfill_context *ctx)
109110 download_batch (ctx );
110111
111112 path_walk_info_clear (& info );
112- release_revisions (& revs );
113113 return ret ;
114114}
115115
@@ -121,6 +121,7 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit
121121 .current_batch = OID_ARRAY_INIT ,
122122 .min_batch_size = 50000 ,
123123 .sparse = 0 ,
124+ .revs = REV_INFO_INIT ,
124125 };
125126 struct option options [] = {
126127 OPT_UNSIGNED (0 , "min-batch-size" , & ctx .min_batch_size ,
@@ -134,7 +135,12 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit
134135 builtin_backfill_usage , options );
135136
136137 argc = parse_options (argc , argv , prefix , options , builtin_backfill_usage ,
137- 0 );
138+ PARSE_OPT_KEEP_UNKNOWN_OPT |
139+ PARSE_OPT_KEEP_ARGV0 |
140+ PARSE_OPT_KEEP_DASHDASH );
141+
142+ repo_init_revisions (repo , & ctx .revs , prefix );
143+ argc = setup_revisions (argc , argv , & ctx .revs , NULL );
138144
139145 repo_config (repo , git_default_config , NULL );
140146
@@ -143,5 +149,6 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit
143149
144150 result = do_backfill (& ctx );
145151 backfill_context_clear (& ctx );
152+ release_revisions (& ctx .revs );
146153 return result ;
147154}
0 commit comments