277
* however it should be done together with apply_cached.
278
*/
279
cp.git_cmd = 1;
280
- argv_array_pushl(&cp.args, "diff-tree", "--binary", NULL);
281
- argv_array_pushf(&cp.args, "%s^2^..%s^2", w_commit_hex, w_commit_hex);
280
+ strvec_pushl(&cp.args, "diff-tree", "--binary", NULL);
281
+ strvec_pushf(&cp.args, "%s^2^..%s^2", w_commit_hex, w_commit_hex);
282
283
return pipe_command(&cp, NULL, 0, out, 0, NULL, 0);
284
}
293
* buffer.
294
*/
295
cp.git_cmd = 1;
296
- argv_array_pushl(&cp.args, "apply", "--cached", NULL);
296
+ strvec_pushl(&cp.args, "apply", "--cached", NULL);
297
return pipe_command(&cp, out->buf, out->len, NULL, 0, NULL, 0);
298
}
299
306
* API for resetting.
307
*/
308
cp.git_cmd = 1;
309
- argv_array_push(&cp.args, "reset");
309
+ strvec_push(&cp.args, "reset");
310
311
return run_command(&cp);
312
}
335
* converted together with update_index.
336
*/
337
cp.git_cmd = 1;
338
- argv_array_pushl(&cp.args, "diff-index", "--cached", "--name-only",
338
+ strvec_pushl(&cp.args, "diff-index", "--cached", "--name-only",
339
"--diff-filter=A", NULL);
340
- argv_array_push(&cp.args, c_tree_hex);
340
+ strvec_push(&cp.args, c_tree_hex);
341
return pipe_command(&cp, NULL, 0, out, 0, NULL, 0);
342
}
343
350
* function exposed in order to remove this forking.
351
*/
352
cp.git_cmd = 1;
353
- argv_array_pushl(&cp.args, "update-index", "--add", "--stdin", NULL);
353
+ strvec_pushl(&cp.args, "update-index", "--add", "--stdin", NULL);
354
return pipe_command(&cp, out->buf, out->len, NULL, 0, NULL, 0);
355
}
356
365
* run_command to fork processes that will not interfere.
366
*/
367
cp.git_cmd = 1;
368
- argv_array_push(&cp.args, "read-tree");
369
- argv_array_push(&cp.args, oid_to_hex(u_tree));
370
- argv_array_pushf(&cp.env_array, "GIT_INDEX_FILE=%s",
368
+ strvec_push(&cp.args, "read-tree");
369
+ strvec_push(&cp.args, oid_to_hex(u_tree));
370
+ strvec_pushf(&cp.env_array, "GIT_INDEX_FILE=%s",
371
stash_index_path.buf);
372
if (run_command(&cp)) {
373
remove_path(stash_index_path.buf);
376
377
child_process_init(&cp);
378
cp.git_cmd = 1;
379
- argv_array_pushl(&cp.args, "checkout-index", "--all", NULL);
380
- argv_array_pushf(&cp.env_array, "GIT_INDEX_FILE=%s",
379
+ strvec_pushl(&cp.args, "checkout-index", "--all", NULL);
380
+ strvec_pushf(&cp.env_array, "GIT_INDEX_FILE=%s",
381
stash_index_path.buf);
382
383
res = run_command(&cp);
499
*/
500
cp.git_cmd = 1;
501
cp.dir = prefix;
502
- argv_array_pushf(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT"=%s",
502
+ strvec_pushf(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT"=%s",
503
absolute_path(get_git_work_tree()));
504
- argv_array_pushf(&cp.env_array, GIT_DIR_ENVIRONMENT"=%s",
504
+ strvec_pushf(&cp.env_array, GIT_DIR_ENVIRONMENT"=%s",
505
absolute_path(get_git_dir()));
506
- argv_array_push(&cp.args, "status");
506
+ strvec_push(&cp.args, "status");
507
run_command(&cp);
508
}
509
546
*/
547
548
cp_reflog.git_cmd = 1;
549
- argv_array_pushl(&cp_reflog.args, "reflog", "delete", "--updateref",
549
+ strvec_pushl(&cp_reflog.args, "reflog", "delete", "--updateref",
550
"--rewrite", NULL);
551
- argv_array_push(&cp_reflog.args, info->revision.buf);
551
+ strvec_push(&cp_reflog.args, info->revision.buf);
552
ret = run_command(&cp_reflog);
553
if (!ret) {
554
if (!quiet)
566
cp.git_cmd = 1;
567
/* Even though --quiet is specified, rev-parse still outputs the hash */
568
cp.no_stdout = 1;
569
- argv_array_pushl(&cp.args, "rev-parse", "--verify", "--quiet", NULL);
570
- argv_array_pushf(&cp.args, "%s@{0}", ref_stash);
569
+ strvec_pushl(&cp.args, "rev-parse", "--verify", "--quiet", NULL);
570
+ strvec_pushf(&cp.args, "%s@{0}", ref_stash);
571
ret = run_command(&cp);
572
573
/* do_clear_stash if we just dropped the last stash entry */
663
return -1;
664
665
cp.git_cmd = 1;
666
- argv_array_pushl(&cp.args, "checkout", "-b", NULL);
667
- argv_array_push(&cp.args, branch);
668
- argv_array_push(&cp.args, oid_to_hex(&info.b_commit));
666
+ strvec_pushl(&cp.args, "checkout", "-b", NULL);
667
+ strvec_push(&cp.args, branch);
668
+ strvec_push(&cp.args, oid_to_hex(&info.b_commit));
669
ret = run_command(&cp);
670
if (!ret)
671
ret = do_apply_stash(prefix, &info, 1, 0);
692
return 0;
693
694
cp.git_cmd = 1;
695
- argv_array_pushl(&cp.args, "log", "--format=%gd: %gs", "-g",
695
+ strvec_pushl(&cp.args, "log", "--format=%gd: %gs", "-g",
696
"--first-parent", "-m", NULL);
697
- argv_array_pushv(&cp.args, argv);
698
- argv_array_push(&cp.args, ref_stash);
699
- argv_array_push(&cp.args, "--");
697
+ strvec_pushv(&cp.args, argv);
698
+ strvec_push(&cp.args, ref_stash);
699
+ strvec_push(&cp.args, "--");
700
return run_command(&cp);
701
}
702
727
int ret = 0;
728
struct stash_info info;
729
struct rev_info rev;
730
- struct argv_array stash_args = ARGV_ARRAY_INIT;
731
- struct argv_array revision_args = ARGV_ARRAY_INIT;
730
+ struct strvec stash_args = STRVEC_INIT;
731
+ struct strvec revision_args = STRVEC_INIT;
732
struct option options[] = {
733
OPT_END()
734
};
737
git_config(git_diff_ui_config, NULL);
738
init_revisions(&rev, prefix);
739
740
- argv_array_push(&revision_args, argv[0]);
740
+ strvec_push(&revision_args, argv[0]);
741
for (i = 1; i < argc; i++) {
742
if (argv[i][0] != '-')
743
- argv_array_push(&stash_args, argv[i]);
743
+ strvec_push(&stash_args, argv[i]);
744
else
745
- argv_array_push(&revision_args, argv[i]);
745
+ strvec_push(&revision_args, argv[i]);
746
}
747
748
ret = get_stash_info(&info, stash_args.argc, stash_args.argv);
749
- argv_array_clear(&stash_args);
749
+ strvec_clear(&stash_args);
750
if (ret)
751
return -1;
752
842
return do_store_stash(&obj, stash_msg, quiet);
843
}
844
845
-static void add_pathspecs(struct argv_array *args,
845
+static void add_pathspecs(struct strvec *args,
846
const struct pathspec *ps) {
847
int i;
848
849
for (i = 0; i < ps->nr; i++)
850
- argv_array_push(args, ps->items[i].original);
850
+ strvec_push(args, ps->items[i].original);
851
}
852
853
/*
960
struct index_state istate = { NULL };
961
962
cp_upd_index.git_cmd = 1;
963
- argv_array_pushl(&cp_upd_index.args, "update-index", "-z", "--add",
963
+ strvec_pushl(&cp_upd_index.args, "update-index", "-z", "--add",
964
"--remove", "--stdin", NULL);
965
- argv_array_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s",
965
+ strvec_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s",
966
stash_index_path.buf);
967
968
strbuf_addf(&untracked_msg, "untracked files on %s\n", msg->buf);
1003
remove_path(stash_index_path.buf);
1004
1005
cp_read_tree.git_cmd = 1;
1006
- argv_array_pushl(&cp_read_tree.args, "read-tree", "HEAD", NULL);
1007
- argv_array_pushf(&cp_read_tree.env_array, "GIT_INDEX_FILE=%s",
1006
+ strvec_pushl(&cp_read_tree.args, "read-tree", "HEAD", NULL);
1007
+ strvec_pushf(&cp_read_tree.env_array, "GIT_INDEX_FILE=%s",
1008
stash_index_path.buf);
1009
if (run_command(&cp_read_tree)) {
1010
ret = -1;
1034
}
1035
1036
cp_diff_tree.git_cmd = 1;
1037
- argv_array_pushl(&cp_diff_tree.args, "diff-tree", "-p", "-U1", "HEAD",
1037
+ strvec_pushl(&cp_diff_tree.args, "diff-tree", "-p", "-U1", "HEAD",
1038
oid_to_hex(&info->w_tree), "--", NULL);
1039
if (pipe_command(&cp_diff_tree, NULL, 0, out_patch, 0, NULL, 0)) {
1040
ret = -1;
1088
}
1089
1090
cp_upd_index.git_cmd = 1;
1091
- argv_array_pushl(&cp_upd_index.args, "update-index",
1091
+ strvec_pushl(&cp_upd_index.args, "update-index",
1092
"--ignore-skip-worktree-entries",
1093
"-z", "--add", "--remove", "--stdin", NULL);
1094
- argv_array_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s",
1094
+ strvec_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s",
1095
stash_index_path.buf);
1096
1097
if (pipe_command(&cp_upd_index, diff_output.buf, diff_output.len,
1342
struct child_process cp = CHILD_PROCESS_INIT;
1343
1344
cp.git_cmd = 1;
1345
- argv_array_pushl(&cp.args, "clean", "--force",
1345
+ strvec_pushl(&cp.args, "clean", "--force",
1346
"--quiet", "-d", NULL);
1347
if (include_untracked == INCLUDE_ALL_FILES)
1348
- argv_array_push(&cp.args, "-x");
1348
+ strvec_push(&cp.args, "-x");
1349
if (run_command(&cp)) {
1350
ret = -1;
1351
goto done;
1359
struct strbuf out = STRBUF_INIT;
1360
1361
cp_add.git_cmd = 1;
1362
- argv_array_push(&cp_add.args, "add");
1362
+ strvec_push(&cp_add.args, "add");
1363
if (!include_untracked)
1364
- argv_array_push(&cp_add.args, "-u");
1364
+ strvec_push(&cp_add.args, "-u");
1365
if (include_untracked == INCLUDE_ALL_FILES)
1366
- argv_array_push(&cp_add.args, "--force");
1367
- argv_array_push(&cp_add.args, "--");
1366
+ strvec_push(&cp_add.args, "--force");
1367
+ strvec_push(&cp_add.args, "--");
1368
add_pathspecs(&cp_add.args, ps);
1369
if (run_command(&cp_add)) {
1370
ret = -1;
1372
}
1373
1374
cp_diff.git_cmd = 1;
1375
- argv_array_pushl(&cp_diff.args, "diff-index", "-p",
1375
+ strvec_pushl(&cp_diff.args, "diff-index", "-p",
1376
"--cached", "--binary", "HEAD", "--",
1377
NULL);
1378
add_pathspecs(&cp_diff.args, ps);
1382
}
1383
1384
cp_apply.git_cmd = 1;
1385
- argv_array_pushl(&cp_apply.args, "apply", "--index",
1385
+ strvec_pushl(&cp_apply.args, "apply", "--index",
1386
"-R", NULL);
1387
if (pipe_command(&cp_apply, out.buf, out.len, NULL, 0,
1388
NULL, 0)) {
1392
} else {
1393
struct child_process cp = CHILD_PROCESS_INIT;
1394
cp.git_cmd = 1;
1395
- argv_array_pushl(&cp.args, "reset", "--hard", "-q",
1395
+ strvec_pushl(&cp.args, "reset", "--hard", "-q",
1396
"--no-recurse-submodules", NULL);
1397
if (run_command(&cp)) {
1398
ret = -1;
1404
struct child_process cp = CHILD_PROCESS_INIT;
1405
1406
cp.git_cmd = 1;
1407
- argv_array_pushl(&cp.args, "checkout", "--no-overlay",
1407
+ strvec_pushl(&cp.args, "checkout", "--no-overlay",
1408
oid_to_hex(&info.i_tree), "--", NULL);
1409
if (!ps->nr)
1410
- argv_array_push(&cp.args, ":/");
1410
+ strvec_push(&cp.args, ":/");
1411
else
1412
add_pathspecs(&cp.args, ps);
1413
if (run_command(&cp)) {
1420
struct child_process cp = CHILD_PROCESS_INIT;
1421
1422
cp.git_cmd = 1;
1423
- argv_array_pushl(&cp.args, "apply", "-R", NULL);
1423
+ strvec_pushl(&cp.args, "apply", "-R", NULL);
1424
1425
if (pipe_command(&cp, patch.buf, patch.len, NULL, 0, NULL, 0)) {
1426
if (!quiet)
1434
struct child_process cp = CHILD_PROCESS_INIT;
1435
1436
cp.git_cmd = 1;
1437
- argv_array_pushl(&cp.args, "reset", "-q", "--", NULL);
1437
+ strvec_pushl(&cp.args, "reset", "-q", "--", NULL);
1438
add_pathspecs(&cp.args, ps);
1439
if (run_command(&cp)) {
1440
ret = -1;
1560
{
1561
pid_t pid = getpid();
1562
const char *index_file;
1563
- struct argv_array args = ARGV_ARRAY_INIT;
1563
+ struct strvec args = STRVEC_INIT;
1564
1565
struct option options[] = {
1566
OPT_END()
1609
git_stash_usage, options);
1610
1611
/* Assume 'stash push' */
1612
- argv_array_push(&args, "push");
1613
- argv_array_pushv(&args, argv);
1612
+ strvec_push(&args, "push");
1613
+ strvec_pushv(&args, argv);
1614
return !!push_stash(args.argc, args.argv, prefix, 1);
1615
}