mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-12 05:26:05 +00:00
Add -u option to add example.
This commit is contained in:
parent
e8fa14d3a3
commit
24d2322096
@ -6,6 +6,7 @@
|
|||||||
enum print_options {
|
enum print_options {
|
||||||
SKIP = 1,
|
SKIP = 1,
|
||||||
VERBOSE = 2,
|
VERBOSE = 2,
|
||||||
|
UPDATE = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct print_payload {
|
struct print_payload {
|
||||||
@ -67,7 +68,7 @@ int main (int argc, char** argv)
|
|||||||
struct print_payload payload = {0};
|
struct print_payload payload = {0};
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
fprintf(stderr, "usage: add [-n|--dry-run] [-v|--verbose] file-spec [file-spec] [...]\n");
|
fprintf(stderr, "usage: add [-n|--dry-run] [-v|--verbose] [-u|--update] file-spec [file-spec] [...]\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +82,9 @@ int main (int argc, char** argv)
|
|||||||
else if(!strcmp(argv[i], "--dry-run") || !strcmp(argv[i], "-n")) {
|
else if(!strcmp(argv[i], "--dry-run") || !strcmp(argv[i], "-n")) {
|
||||||
options |= SKIP;
|
options |= SKIP;
|
||||||
}
|
}
|
||||||
|
else if(!strcmp(argv[i], "--update") || !strcmp(argv[i], "-u")) {
|
||||||
|
options |= UPDATE;
|
||||||
|
}
|
||||||
else if(!strcmp(argv[i], "--")) {
|
else if(!strcmp(argv[i], "--")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -111,7 +115,12 @@ int main (int argc, char** argv)
|
|||||||
|
|
||||||
payload.options = options;
|
payload.options = options;
|
||||||
payload.repo = repo;
|
payload.repo = repo;
|
||||||
git_index_add_all(index, &array, 0, matched_cb, &payload);
|
|
||||||
|
if (options&UPDATE) {
|
||||||
|
git_index_update_all(index, &array, matched_cb, &payload);
|
||||||
|
} else {
|
||||||
|
git_index_add_all(index, &array, 0, matched_cb, &payload);
|
||||||
|
}
|
||||||
|
|
||||||
git_index_write(index);
|
git_index_write(index);
|
||||||
git_index_free(index);
|
git_index_free(index);
|
||||||
|
Loading…
Reference in New Issue
Block a user