diff options
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/am.c | 31 | ||||
-rw-r--r-- | builtin/apply.c | 2 | ||||
-rw-r--r-- | builtin/blame.c | 1 | ||||
-rw-r--r-- | builtin/branch.c | 22 | ||||
-rw-r--r-- | builtin/for-each-ref.c | 14 | ||||
-rw-r--r-- | builtin/pull.c | 2 | ||||
-rw-r--r-- | builtin/rerere.c | 4 | ||||
-rw-r--r-- | builtin/show-branch.c | 6 | ||||
-rw-r--r-- | builtin/show-ref.c | 2 | ||||
-rw-r--r-- | builtin/tag.c | 46 | ||||
-rw-r--r-- | builtin/update-ref.c | 2 |
11 files changed, 75 insertions, 57 deletions
diff --git a/builtin/am.c b/builtin/am.c index 83b3d86e67..4f77e07b95 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1207,6 +1207,33 @@ static void NORETURN die_user_resolve(const struct am_state *state) exit(128); } +static void am_signoff(struct strbuf *sb) +{ + char *cp; + struct strbuf mine = STRBUF_INIT; + + /* Does it end with our own sign-off? */ + strbuf_addf(&mine, "\n%s%s\n", + sign_off_header, + fmt_name(getenv("GIT_COMMITTER_NAME"), + getenv("GIT_COMMITTER_EMAIL"))); + if (mine.len < sb->len && + !strcmp(mine.buf, sb->buf + sb->len - mine.len)) + goto exit; /* no need to duplicate */ + + /* Does it have any Signed-off-by: in the text */ + for (cp = sb->buf; + cp && *cp && (cp = strstr(cp, sign_off_header)) != NULL; + cp = strchr(cp, '\n')) { + if (sb->buf == cp || cp[-1] == '\n') + break; + } + + strbuf_addstr(sb, mine.buf + !!cp); +exit: + strbuf_release(&mine); +} + /** * Appends signoff to the "msg" field of the am_state. */ @@ -1215,7 +1242,7 @@ static void am_append_signoff(struct am_state *state) struct strbuf sb = STRBUF_INIT; strbuf_attach(&sb, state->msg, state->msg_len, state->msg_len); - append_signoff(&sb, 0, 0); + am_signoff(&sb); state->msg = strbuf_detach(&sb, &state->msg_len); } @@ -1319,7 +1346,7 @@ static int parse_mail(struct am_state *state, const char *mail) stripspace(&msg, 0); if (state->signoff) - append_signoff(&msg, 0, 0); + am_signoff(&msg); assert(!state->author_name); state->author_name = strbuf_detach(&author_name, NULL); diff --git a/builtin/apply.c b/builtin/apply.c index 54aba4e351..4aa53f7fd8 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -785,7 +785,7 @@ static int guess_p_value(const char *nameline) } /* - * Does the ---/+++ line has the POSIX timestamp after the last HT? + * Does the ---/+++ line have the POSIX timestamp after the last HT? * GNU diff puts epoch there to signal a creation/deletion event. Is * this such a timestamp? */ diff --git a/builtin/blame.c b/builtin/blame.c index 4db01c195c..6fd1a63fc7 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -2600,7 +2600,6 @@ parse_done: fewer display columns. */ blame_date_width = utf8_strwidth(_("4 years, 11 months ago")) + 1; /* add the null */ break; - case DATE_LOCAL: case DATE_NORMAL: blame_date_width = sizeof("Thu Oct 19 16:00:04 2006 -0700"); break; diff --git a/builtin/branch.c b/builtin/branch.c index ff05869949..3ba4d1bd3b 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -636,6 +636,10 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru cb.pattern = pattern; cb.ret = 0; for_each_rawref(append_ref, &cb); + /* + * The following implementation is currently duplicated in ref-filter. It + * will eventually be removed when we port branch.c to use ref-filter APIs. + */ if (merge_filter != NO_FILTER) { struct commit *filter; filter = lookup_commit_reference_gently(merge_filter_ref, 0); @@ -746,6 +750,10 @@ static void rename_branch(const char *oldname, const char *newname, int force) strbuf_release(&newsection); } +/* + * This function is duplicated in ref-filter. It will eventually be removed + * when we port branch.c to use ref-filter APIs. + */ static int opt_parse_merge_filter(const struct option *opt, const char *arg, int unset) { merge_filter = ((opt->long_name[0] == 'n') @@ -821,18 +829,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix) OPT__COLOR(&branch_use_color, N_("use colored output")), OPT_SET_INT('r', "remotes", &kinds, N_("act on remote-tracking branches"), REF_REMOTE_BRANCH), - { - OPTION_CALLBACK, 0, "contains", &with_commit, N_("commit"), - N_("print only branches that contain the commit"), - PARSE_OPT_LASTARG_DEFAULT, - parse_opt_with_commit, (intptr_t)"HEAD", - }, - { - OPTION_CALLBACK, 0, "with", &with_commit, N_("commit"), - N_("print only branches that contain the commit"), - PARSE_OPT_HIDDEN | PARSE_OPT_LASTARG_DEFAULT, - parse_opt_with_commit, (intptr_t) "HEAD", - }, + OPT_CONTAINS(&with_commit, N_("print only branches that contain the commit")), + OPT_WITH(&with_commit, N_("print only branches that contain the commit")), OPT__ABBREV(&abbrev), OPT_GROUP(N_("Specific git-branch actions:")), diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 7919206187..40f343b6a3 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -7,6 +7,9 @@ static char const * const for_each_ref_usage[] = { N_("git for-each-ref [<options>] [<pattern>]"), + N_("git for-each-ref [--points-at <object>]"), + N_("git for-each-ref [(--merged | --no-merged) [<object>]]"), + N_("git for-each-ref [--contains [<object>]]"), NULL }; @@ -34,9 +37,18 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) OPT_STRING( 0 , "format", &format, N_("format"), N_("format to use for the output")), OPT_CALLBACK(0 , "sort", sorting_tail, N_("key"), N_("field name to sort on"), &parse_opt_ref_sorting), + OPT_CALLBACK(0, "points-at", &filter.points_at, + N_("object"), N_("print only refs which points at the given object"), + parse_opt_object_name), + OPT_MERGED(&filter, N_("print only refs that are merged")), + OPT_NO_MERGED(&filter, N_("print only refs that are not merged")), + OPT_CONTAINS(&filter.with_commit, N_("print only refs which contain the commit")), OPT_END(), }; + memset(&array, 0, sizeof(array)); + memset(&filter, 0, sizeof(filter)); + parse_options(argc, argv, prefix, opts, for_each_ref_usage, 0); if (maxcount < 0) { error("invalid --count argument: `%d'", maxcount); @@ -55,8 +67,6 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) /* for warn_ambiguous_refs */ git_config(git_default_config, NULL); - memset(&array, 0, sizeof(array)); - memset(&filter, 0, sizeof(filter)); filter.name_patterns = argv; filter_refs(&array, &filter, FILTER_REFS_ALL | FILTER_REFS_INCLUDE_BROKEN); ref_array_sort(sorting, &array); diff --git a/builtin/pull.c b/builtin/pull.c index 7e3c11ea63..a39bb0a11f 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -112,7 +112,7 @@ static struct option pull_options[] = { /* Options passed to git-merge or git-rebase */ OPT_GROUP(N_("Options related to merging")), { OPTION_CALLBACK, 'r', "rebase", &opt_rebase, - N_("false|true|preserve"), + "false|true|preserve", N_("incorporate changes by rebasing rather than merging"), PARSE_OPT_OPTARG, parse_opt_rebase }, OPT_PASSTHRU('n', NULL, &opt_diffstat, NULL, diff --git a/builtin/rerere.c b/builtin/rerere.c index 12535c9b4f..8c6cb6cdc6 100644 --- a/builtin/rerere.c +++ b/builtin/rerere.c @@ -103,8 +103,8 @@ int cmd_rerere(int argc, const char **argv, const char *prefix) return 0; for (i = 0; i < merge_rr.nr; i++) { const char *path = merge_rr.items[i].string; - const char *name = (const char *)merge_rr.items[i].util; - diff_two(rerere_path(name, "preimage"), path, path, path); + const struct rerere_id *id = merge_rr.items[i].util; + diff_two(rerere_path(id, "preimage"), path, path, path); } } else usage_with_options(rerere_usage, options); diff --git a/builtin/show-branch.c b/builtin/show-branch.c index c87c46eb38..408ce70307 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -730,7 +730,6 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) if (reflog) { struct object_id oid; - char nth_desc[256]; char *ref; int base = 0; unsigned int flags = 0; @@ -769,6 +768,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) for (i = 0; i < reflog; i++) { char *logmsg; + char *nth_desc; const char *msg; unsigned long timestamp; int tz; @@ -788,8 +788,10 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) DATE_MODE(RELATIVE)), msg); free(logmsg); - sprintf(nth_desc, "%s@{%d}", *av, base+i); + + nth_desc = xstrfmt("%s@{%d}", *av, base+i); append_ref(nth_desc, &oid, 1); + free(nth_desc); } free(ref); } diff --git a/builtin/show-ref.c b/builtin/show-ref.c index dfbc314ac2..131ef28e5c 100644 --- a/builtin/show-ref.c +++ b/builtin/show-ref.c @@ -8,7 +8,7 @@ static const char * const show_ref_usage[] = { N_("git show-ref [-q | --quiet] [--verify] [--head] [-d | --dereference] [-s | --hash[=<n>]] [--abbrev[=<n>]] [--tags] [--heads] [--] [<pattern>...]"), - N_("git show-ref --exclude-existing[=pattern] < ref-list"), + N_("git show-ref --exclude-existing[=<pattern>] < <ref-list>"), NULL }; diff --git a/builtin/tag.c b/builtin/tag.c index cccca99104..aaae358c2e 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -56,6 +56,10 @@ static int match_pattern(const char **patterns, const char *ref) return 0; } +/* + * This is currently duplicated in ref-filter.c, and will eventually be + * removed as we port tag.c to use the ref-filter APIs. + */ static const unsigned char *match_points_at(const char *refname, const unsigned char *sha1) { @@ -82,6 +86,11 @@ static int in_commit_list(const struct commit_list *want, struct commit *c) return 0; } +/* + * The entire code segment for supporting the --contains option has been + * copied over to ref-filter.{c,h}. This will be deleted evetually when + * we port tag.c to use ref-filter APIs. + */ enum contains_result { CONTAINS_UNKNOWN = -1, CONTAINS_NO = 0, @@ -546,23 +555,6 @@ static int strbuf_check_tag_ref(struct strbuf *sb, const char *name) return check_refname_format(sb->buf, 0); } -static int parse_opt_points_at(const struct option *opt __attribute__((unused)), - const char *arg, int unset) -{ - unsigned char sha1[20]; - - if (unset) { - sha1_array_clear(&points_at); - return 0; - } - if (!arg) - return error(_("switch 'points-at' requires an object")); - if (get_sha1(arg, sha1)) - return error(_("malformed object name '%s'"), arg); - sha1_array_append(&points_at, sha1); - return 0; -} - static int parse_opt_sort(const struct option *opt, const char *arg, int unset) { int *sort = opt->value; @@ -606,29 +598,19 @@ int cmd_tag(int argc, const char **argv, const char *prefix) OPT_STRING('u', "local-user", &keyid, N_("key-id"), N_("use another key to sign the tag")), OPT__FORCE(&force, N_("replace the tag if exists")), - OPT_BOOL(0, "create-reflog", &create_reflog, N_("create_reflog")), + OPT_BOOL(0, "create-reflog", &create_reflog, N_("create a reflog")), OPT_GROUP(N_("Tag listing options")), OPT_COLUMN(0, "column", &colopts, N_("show tag list in columns")), + OPT_CONTAINS(&with_commit, N_("print only tags that contain the commit")), + OPT_WITH(&with_commit, N_("print only tags that contain the commit")), { OPTION_CALLBACK, 0, "sort", &tag_sort, N_("type"), N_("sort tags"), PARSE_OPT_NONEG, parse_opt_sort }, { - OPTION_CALLBACK, 0, "contains", &with_commit, N_("commit"), - N_("print only tags that contain the commit"), - PARSE_OPT_LASTARG_DEFAULT, - parse_opt_with_commit, (intptr_t)"HEAD", - }, - { - OPTION_CALLBACK, 0, "with", &with_commit, N_("commit"), - N_("print only tags that contain the commit"), - PARSE_OPT_HIDDEN | PARSE_OPT_LASTARG_DEFAULT, - parse_opt_with_commit, (intptr_t)"HEAD", - }, - { - OPTION_CALLBACK, 0, "points-at", NULL, N_("object"), - N_("print only tags of the object"), 0, parse_opt_points_at + OPTION_CALLBACK, 0, "points-at", &points_at, N_("object"), + N_("print only tags of the object"), 0, parse_opt_object_name }, OPT_END() }; diff --git a/builtin/update-ref.c b/builtin/update-ref.c index 04dd00f734..7f30d3a76f 100644 --- a/builtin/update-ref.c +++ b/builtin/update-ref.c @@ -365,7 +365,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix) N_("update <refname> not the one it points to")), OPT_BOOL('z', NULL, &end_null, N_("stdin has NUL-terminated arguments")), OPT_BOOL( 0 , "stdin", &read_stdin, N_("read updates from stdin")), - OPT_BOOL( 0 , "create-reflog", &create_reflog, N_("create_reflog")), + OPT_BOOL( 0 , "create-reflog", &create_reflog, N_("create a reflog")), OPT_END(), }; |