summaryrefslogtreecommitdiff
path: root/builtin/commit.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/commit.c')
-rw-r--r--builtin/commit.c80
1 files changed, 58 insertions, 22 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index ef5e622c07..66bd91fd52 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -44,7 +44,7 @@
#include "trailer.h"
static const char * const builtin_commit_usage[] = {
- N_("git commit [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend]\n"
+ N_("git commit [-a | --interactive | --patch] [-s] [-v] [-u[<mode>]] [--amend]\n"
" [--dry-run] [(-c | -C | --squash) <commit> | --fixup [(amend|reword):]<commit>]\n"
" [-F <file> | -m <msg>] [--reset-author] [--allow-empty]\n"
" [--allow-empty-message] [--no-verify] [-e] [--author=<author>]\n"
@@ -352,6 +352,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
struct pathspec pathspec;
int refresh_flags = REFRESH_QUIET;
const char *ret;
+ char *path = NULL;
if (is_status)
refresh_flags |= REFRESH_UNMERGED;
@@ -524,9 +525,9 @@ static const char *prepare_index(const char **argv, const char *prefix,
if (write_locked_index(the_repository->index, &index_lock, 0))
die(_("unable to write new index file"));
- hold_lock_file_for_update(&false_lock,
- git_path("next-index-%"PRIuMAX,
- (uintmax_t) getpid()),
+ path = repo_git_path(the_repository, "next-index-%"PRIuMAX,
+ (uintmax_t) getpid());
+ hold_lock_file_for_update(&false_lock, path,
LOCK_DIE_ON_ERROR);
create_base_index(current_head);
@@ -542,6 +543,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
out:
string_list_clear(&partial, 0);
clear_pathspec(&pathspec);
+ free(path);
return ret;
}
@@ -1540,17 +1542,34 @@ struct repository *repo UNUSED)
STATUS_FORMAT_LONG),
OPT_BOOL('z', "null", &s.null_termination,
N_("terminate entries with NUL")),
- { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg,
- N_("mode"),
- N_("show untracked files, optional modes: all, normal, no. (Default: all)"),
- PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
- { OPTION_STRING, 0, "ignored", &ignored_arg,
- N_("mode"),
- N_("show ignored files, optional modes: traditional, matching, no. (Default: traditional)"),
- PARSE_OPT_OPTARG, NULL, (intptr_t)"traditional" },
- { OPTION_STRING, 0, "ignore-submodules", &ignore_submodule_arg, N_("when"),
- N_("ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)"),
- PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
+ {
+ .type = OPTION_STRING,
+ .short_name = 'u',
+ .long_name = "untracked-files",
+ .value = &untracked_files_arg,
+ .argh = N_("mode"),
+ .help = N_("show untracked files, optional modes: all, normal, no. (Default: all)"),
+ .flags = PARSE_OPT_OPTARG,
+ .defval = (intptr_t)"all",
+ },
+ {
+ .type = OPTION_STRING,
+ .long_name = "ignored",
+ .value = &ignored_arg,
+ .argh = N_("mode"),
+ .help = N_("show ignored files, optional modes: traditional, matching, no. (Default: traditional)"),
+ .flags = PARSE_OPT_OPTARG,
+ .defval = (intptr_t)"traditional",
+ },
+ {
+ .type = OPTION_STRING,
+ .long_name = "ignore-submodules",
+ .value = &ignore_submodule_arg,
+ .argh = N_("when"),
+ .help = N_("ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)"),
+ .flags = PARSE_OPT_OPTARG,
+ .defval = (intptr_t)"all",
+ },
OPT_COLUMN(0, "column", &s.colopts, N_("list untracked files in columns")),
OPT_BOOL(0, "no-renames", &no_renames, N_("do not detect renames")),
OPT_CALLBACK_F('M', "find-renames", &rename_score_arg,
@@ -1559,8 +1578,8 @@ struct repository *repo UNUSED)
OPT_END(),
};
- if (argc == 2 && !strcmp(argv[1], "-h"))
- usage_with_options(builtin_status_usage, builtin_status_options);
+ show_usage_with_options_if_asked(argc, argv,
+ builtin_status_usage, builtin_status_options);
prepare_repo_settings(the_repository);
the_repository->settings.command_requires_full_index = 0;
@@ -1686,8 +1705,16 @@ int cmd_commit(int argc,
OPT_BOOL('e', "edit", &edit_flag, N_("force edit of commit")),
OPT_CLEANUP(&cleanup_arg),
OPT_BOOL(0, "status", &include_status, N_("include status in commit message template")),
- { OPTION_STRING, 'S', "gpg-sign", &sign_commit, N_("key-id"),
- N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
+ {
+ .type = OPTION_STRING,
+ .short_name = 'S',
+ .long_name = "gpg-sign",
+ .value = &sign_commit,
+ .argh = N_("key-id"),
+ .help = N_("GPG sign commit"),
+ .flags = PARSE_OPT_OPTARG,
+ .defval = (intptr_t) "",
+ },
/* end commit message options */
OPT_GROUP(N_("Commit contents options")),
@@ -1712,7 +1739,16 @@ int cmd_commit(int argc,
N_("terminate entries with NUL")),
OPT_BOOL(0, "amend", &amend, N_("amend previous commit")),
OPT_BOOL(0, "no-post-rewrite", &no_post_rewrite, N_("bypass post-rewrite hook")),
- { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, N_("mode"), N_("show untracked files, optional modes: all, normal, no. (Default: all)"), PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
+ {
+ .type = OPTION_STRING,
+ .short_name = 'u',
+ .long_name = "untracked-files",
+ .value = &untracked_files_arg,
+ .argh = N_("mode"),
+ .help = N_("show untracked files, optional modes: all, normal, no. (Default: all)"),
+ .flags = PARSE_OPT_OPTARG,
+ .defval = (intptr_t)"all",
+ },
OPT_PATHSPEC_FROM_FILE(&pathspec_from_file),
OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul),
/* end commit contents options */
@@ -1736,8 +1772,8 @@ int cmd_commit(int argc,
struct strbuf err = STRBUF_INIT;
int ret = 0;
- if (argc == 2 && !strcmp(argv[1], "-h"))
- usage_with_options(builtin_commit_usage, builtin_commit_options);
+ show_usage_with_options_if_asked(argc, argv,
+ builtin_commit_usage, builtin_commit_options);
prepare_repo_settings(the_repository);
the_repository->settings.command_requires_full_index = 0;