author | Junio C Hamano <gitster@pobox.com> | |
Fri, 2 Nov 2007 23:42:23 +0000 (16:42 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 2 Nov 2007 23:42:23 +0000 (16:42 -0700) |
* ph/parseopt: (24 commits)
gc: use parse_options
Fixed a command line option type for builtin-fsck.c
Make builtin-pack-refs.c use parse_options.
Make builtin-name-rev.c use parse_options.
Make builtin-count-objects.c use parse_options.
Make builtin-fsck.c use parse_options.
Update manpages to reflect new short and long option aliases
Make builtin-for-each-ref.c use parse-opts.
Make builtin-symbolic-ref.c use parse_options.
Make builtin-update-ref.c use parse_options
Make builtin-revert.c use parse_options.
Make builtin-describe.c use parse_options
Make builtin-branch.c use parse_options.
Make builtin-mv.c use parse-options
Make builtin-rm.c use parse_options.
Port builtin-add.c to use the new option parser.
parse-options: allow callbacks to take no arguments at all.
parse-options: Allow abbreviated options when unambiguous
Add shortcuts for very often used options.
parse-options: make some arguments optional, add callbacks.
...
Conflicts:
Makefile
builtin-add.c
gc: use parse_options
Fixed a command line option type for builtin-fsck.c
Make builtin-pack-refs.c use parse_options.
Make builtin-name-rev.c use parse_options.
Make builtin-count-objects.c use parse_options.
Make builtin-fsck.c use parse_options.
Update manpages to reflect new short and long option aliases
Make builtin-for-each-ref.c use parse-opts.
Make builtin-symbolic-ref.c use parse_options.
Make builtin-update-ref.c use parse_options
Make builtin-revert.c use parse_options.
Make builtin-describe.c use parse_options
Make builtin-branch.c use parse_options.
Make builtin-mv.c use parse-options
Make builtin-rm.c use parse_options.
Port builtin-add.c to use the new option parser.
parse-options: allow callbacks to take no arguments at all.
parse-options: Allow abbreviated options when unambiguous
Add shortcuts for very often used options.
parse-options: make some arguments optional, add callbacks.
...
Conflicts:
Makefile
builtin-add.c
1 | 2 | |||
---|---|---|---|---|
.gitignore | patch | | diff1 | | diff2 | | blob | history |
Makefile | patch | | diff1 | | diff2 | | blob | history |
builtin-add.c | patch | | diff1 | | diff2 | | blob | history |
builtin-revert.c | patch | | diff1 | | diff2 | | blob | history |
diff --cc .gitignore
Simple merge
diff --cc Makefile
index 71479a2a64249c2bf3f015852f1aa9aa9392d509,3c9af55f441474e0621e31f7dc4566e49fa4c9a7..042f79ef8f9e5863605e7ef19136b39b1487a07a
+++ b/Makefile
run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \
utf8.h reflog-walk.h patch-ids.h attr.h decorate.h progress.h \
- mailmap.h remote.h transport.h diffcore.h hash.h
- mailmap.h remote.h parse-options.h transport.h
++ mailmap.h remote.h parse-options.h transport.h diffcore.h hash.h
DIFF_OBJS = \
diff.o diff-lib.o diffcore-break.o diffcore-order.o \
diff --cc builtin-add.c
index dbbb05215fbcfad5d45e5d60e9d985760705d716,f61681c3ae186e1a6f96c5f7d4d6b978d0de5ddb..45b14e8a61764e18d8b89ebfef550a820ffbf831
--- 1/builtin-add.c
--- 2/builtin-add.c
+++ b/builtin-add.c
static const char ignore_error[] =
"The following paths are ignored by one of your .gitignore files:\n";
+ static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
+ static int add_interactive = 0;
+
+ static struct option builtin_add_options[] = {
+ OPT__DRY_RUN(&show_only),
+ OPT__VERBOSE(&verbose),
+ OPT_GROUP(""),
+ OPT_BOOLEAN('i', "interactive", &add_interactive, "interactive picking"),
+ OPT_BOOLEAN('f', NULL, &ignored_too, "allow adding otherwise ignored files"),
+ OPT_BOOLEAN('u', NULL, &take_worktree_changes, "update tracked files"),
+ OPT_BOOLEAN( 0 , "refresh", &refresh_only, "don't add, only refresh the index"),
+ OPT_END(),
+ };
+
int cmd_add(int argc, const char **argv, const char *prefix)
{
- int i, newfd;
- int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
+ int i, newfd, orig_argc = argc;
const char **pathspec;
struct dir_struct dir;
- int add_interactive = 0;
- for (i = 1; i < argc; i++) {
- if (!strcmp("--interactive", argv[i]) ||
- !strcmp("-i", argv[i]))
- add_interactive++;
- }
+ argc = parse_options(argc, argv, builtin_add_options,
+ builtin_add_usage, 0);
if (add_interactive) {
- if (argc != 2)
- const char *args[] = { "add--interactive", NULL };
-
+ if (add_interactive != 1 || orig_argc != 2)
die("add --interactive does not take any parameters");
- execv_git_cmd(args);
- exit(1);
+ exit(interactive_add());
}
git_config(git_add_config);
newfd = hold_locked_index(&lock_file, 1);
- for (i = 1; i < argc; i++) {
- const char *arg = argv[i];
-
- if (arg[0] != '-')
- break;
- if (!strcmp(arg, "--")) {
- i++;
- break;
- }
- if (!strcmp(arg, "-n")) {
- show_only = 1;
- continue;
- }
- if (!strcmp(arg, "-f")) {
- ignored_too = 1;
- continue;
- }
- if (!strcmp(arg, "-v")) {
- verbose = 1;
- continue;
- }
- if (!strcmp(arg, "-u")) {
- take_worktree_changes = 1;
- continue;
- }
- if (!strcmp(arg, "--refresh")) {
- refresh_only = 1;
- continue;
- }
- usage(builtin_add_usage);
- }
-
if (take_worktree_changes) {
- update(verbose, prefix, argv);
+ if (read_cache() < 0)
+ die("index file corrupt");
- add_files_to_cache(verbose, prefix, argv + i);
++ add_files_to_cache(verbose, prefix, argv);
goto finish;
}
diff --cc builtin-revert.c
Simple merge