MCPcopy Index your code
hub / github.com/git/git / parse_describe_args

Function parse_describe_args

pretty.c:1333–1397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1331}
1332
1333static size_t parse_describe_args(const char *start, struct strvec *args)
1334{
1335 struct {
1336 const char *name;
1337 enum {
1338 DESCRIBE_ARG_BOOL,
1339 DESCRIBE_ARG_INTEGER,
1340 DESCRIBE_ARG_STRING,
1341 } type;
1342 } option[] = {
1343 { "tags", DESCRIBE_ARG_BOOL},
1344 { "abbrev", DESCRIBE_ARG_INTEGER },
1345 { "exclude", DESCRIBE_ARG_STRING },
1346 { "match", DESCRIBE_ARG_STRING },
1347 };
1348 const char *arg = start;
1349
1350 for (;;) {
1351 int found = 0;
1352 const char *argval;
1353 size_t arglen = 0;
1354 int optval = 0;
1355 int i;
1356
1357 for (i = 0; !found && i < ARRAY_SIZE(option); i++) {
1358 switch (option[i].type) {
1359 case DESCRIBE_ARG_BOOL:
1360 if (match_placeholder_bool_arg(arg, option[i].name, &arg, &optval)) {
1361 if (optval)
1362 strvec_pushf(args, "--%s", option[i].name);
1363 else
1364 strvec_pushf(args, "--no-%s", option[i].name);
1365 found = 1;
1366 }
1367 break;
1368 case DESCRIBE_ARG_INTEGER:
1369 if (match_placeholder_arg_value(arg, option[i].name, &arg,
1370 &argval, &arglen)) {
1371 char *endptr;
1372 if (!arglen)
1373 return 0;
1374 strtol(argval, &endptr, 10);
1375 if (endptr - argval != arglen)
1376 return 0;
1377 strvec_pushf(args, "--%s=%.*s", option[i].name, (int)arglen, argval);
1378 found = 1;
1379 }
1380 break;
1381 case DESCRIBE_ARG_STRING:
1382 if (match_placeholder_arg_value(arg, option[i].name, &arg,
1383 &argval, &arglen)) {
1384 if (!arglen)
1385 return 0;
1386 strvec_pushf(args, "--%s=%.*s", option[i].name, (int)arglen, argval);
1387 found = 1;
1388 }
1389 break;
1390 }

Callers 1

format_commit_oneFunction · 0.85

Calls 3

strvec_pushfFunction · 0.85

Tested by

no test coverage detected