@@ -95,15 +95,15 @@ static char *parse_refname(const char **next)
95
95
* provided but cannot be converted to a SHA-1, die. flags can
96
96
* include PARSE_SHA1_OLD and/or PARSE_SHA1_ALLOW_EMPTY.
97
97
*/
98
- static int parse_next_oid (struct strbuf * input , const char * * next ,
98
+ static int parse_next_oid (const char * * next , const char * end ,
99
99
struct object_id * oid ,
100
100
const char * command , const char * refname ,
101
101
int flags )
102
102
{
103
103
struct strbuf arg = STRBUF_INIT ;
104
104
int ret = 0 ;
105
105
106
- if (* next == input -> buf + input -> len )
106
+ if (* next == end )
107
107
goto eof ;
108
108
109
109
if (line_termination ) {
@@ -128,7 +128,7 @@ static int parse_next_oid(struct strbuf *input, const char **next,
128
128
die ("%s %s: expected NUL but got: %s" ,
129
129
command , refname , * next );
130
130
(* next )++ ;
131
- if (* next == input -> buf + input -> len )
131
+ if (* next == end )
132
132
goto eof ;
133
133
strbuf_addstr (& arg , * next );
134
134
* next += arg .len ;
@@ -179,7 +179,7 @@ static int parse_next_oid(struct strbuf *input, const char **next,
179
179
*/
180
180
181
181
static const char * parse_cmd_update (struct ref_transaction * transaction ,
182
- struct strbuf * input , const char * next )
182
+ const char * next , const char * end )
183
183
{
184
184
struct strbuf err = STRBUF_INIT ;
185
185
char * refname ;
@@ -190,11 +190,11 @@ static const char *parse_cmd_update(struct ref_transaction *transaction,
190
190
if (!refname )
191
191
die ("update: missing <ref>" );
192
192
193
- if (parse_next_oid (input , & next , & new_oid , "update" , refname ,
193
+ if (parse_next_oid (& next , end , & new_oid , "update" , refname ,
194
194
PARSE_SHA1_ALLOW_EMPTY ))
195
195
die ("update %s: missing <newvalue>" , refname );
196
196
197
- have_old = !parse_next_oid (input , & next , & old_oid , "update" , refname ,
197
+ have_old = !parse_next_oid (& next , end , & old_oid , "update" , refname ,
198
198
PARSE_SHA1_OLD );
199
199
200
200
if (* next != line_termination )
@@ -214,7 +214,7 @@ static const char *parse_cmd_update(struct ref_transaction *transaction,
214
214
}
215
215
216
216
static const char * parse_cmd_create (struct ref_transaction * transaction ,
217
- struct strbuf * input , const char * next )
217
+ const char * next , const char * end )
218
218
{
219
219
struct strbuf err = STRBUF_INIT ;
220
220
char * refname ;
@@ -224,7 +224,7 @@ static const char *parse_cmd_create(struct ref_transaction *transaction,
224
224
if (!refname )
225
225
die ("create: missing <ref>" );
226
226
227
- if (parse_next_oid (input , & next , & new_oid , "create" , refname , 0 ))
227
+ if (parse_next_oid (& next , end , & new_oid , "create" , refname , 0 ))
228
228
die ("create %s: missing <newvalue>" , refname );
229
229
230
230
if (is_null_oid (& new_oid ))
@@ -246,7 +246,7 @@ static const char *parse_cmd_create(struct ref_transaction *transaction,
246
246
}
247
247
248
248
static const char * parse_cmd_delete (struct ref_transaction * transaction ,
249
- struct strbuf * input , const char * next )
249
+ const char * next , const char * end )
250
250
{
251
251
struct strbuf err = STRBUF_INIT ;
252
252
char * refname ;
@@ -257,7 +257,7 @@ static const char *parse_cmd_delete(struct ref_transaction *transaction,
257
257
if (!refname )
258
258
die ("delete: missing <ref>" );
259
259
260
- if (parse_next_oid (input , & next , & old_oid , "delete" , refname ,
260
+ if (parse_next_oid (& next , end , & old_oid , "delete" , refname ,
261
261
PARSE_SHA1_OLD )) {
262
262
have_old = 0 ;
263
263
} else {
@@ -282,7 +282,7 @@ static const char *parse_cmd_delete(struct ref_transaction *transaction,
282
282
}
283
283
284
284
static const char * parse_cmd_verify (struct ref_transaction * transaction ,
285
- struct strbuf * input , const char * next )
285
+ const char * next , const char * end )
286
286
{
287
287
struct strbuf err = STRBUF_INIT ;
288
288
char * refname ;
@@ -292,7 +292,7 @@ static const char *parse_cmd_verify(struct ref_transaction *transaction,
292
292
if (!refname )
293
293
die ("verify: missing <ref>" );
294
294
295
- if (parse_next_oid (input , & next , & old_oid , "verify" , refname ,
295
+ if (parse_next_oid (& next , end , & old_oid , "verify" , refname ,
296
296
PARSE_SHA1_OLD ))
297
297
oidclr (& old_oid );
298
298
@@ -311,7 +311,7 @@ static const char *parse_cmd_verify(struct ref_transaction *transaction,
311
311
}
312
312
313
313
static const char * parse_cmd_option (struct ref_transaction * transaction ,
314
- struct strbuf * input , const char * next )
314
+ const char * next , const char * end )
315
315
{
316
316
const char * rest ;
317
317
if (skip_prefix (next , "no-deref" , & rest ) && * rest == line_termination )
@@ -323,7 +323,7 @@ static const char *parse_cmd_option(struct ref_transaction *transaction,
323
323
324
324
static const struct parse_cmd {
325
325
const char * prefix ;
326
- const char * (* fn )(struct ref_transaction * , struct strbuf * , const char * );
326
+ const char * (* fn )(struct ref_transaction * , const char * , const char * );
327
327
} command [] = {
328
328
{ "update" , parse_cmd_update },
329
329
{ "create" , parse_cmd_create },
@@ -363,7 +363,7 @@ static void update_refs_stdin(struct ref_transaction *transaction)
363
363
if (!cmd )
364
364
die ("unknown command: %s" , next );
365
365
366
- next = cmd -> fn (transaction , & input , next );
366
+ next = cmd -> fn (transaction , next , input . buf + input . len );
367
367
next ++ ;
368
368
}
369
369
0 commit comments