From: Junio C Hamano Date: Tue, 3 Oct 2017 06:42:47 +0000 (+0900) Subject: Merge branch 'bc/rev-parse-parseopt-fix' X-Git-Tag: v2.15.0-rc0~25 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b2a2c4d8099c69ec997e51cac489c0947ad17956?ds=inline;hp=-c Merge branch 'bc/rev-parse-parseopt-fix' Recent versions of "git rev-parse --parseopt" did not parse the option specification that does not have the optional flags (*=?!) correctly, which has been corrected. * bc/rev-parse-parseopt-fix: parse-options: only insert newline in help text if needed parse-options: write blank line to correct output stream t0040,t1502: Demonstrate parse_options bugs git-rebase: don't ignore unexpected command line arguments rev-parse parseopt: interpret any whitespace as start of help text rev-parse parseopt: do not search help text for flag chars t1502: demonstrate rev-parse --parseopt option mis-parsing --- b2a2c4d8099c69ec997e51cac489c0947ad17956 diff --combined builtin/rev-parse.c index b9c13d3d9d,b3f634d209..a8d7e6f7ae --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@@ -274,7 -274,7 +274,7 @@@ static int try_difference(const char *a return 0; } - if (!get_sha1_committish(this, oid.hash) && !get_sha1_committish(next, end.hash)) { + if (!get_oid_committish(this, &oid) && !get_oid_committish(next, &end)) { show_rev(NORMAL, &end, next); show_rev(symmetric ? NORMAL : REVERSED, &oid, this); if (symmetric) { @@@ -328,7 -328,7 +328,7 @@@ static int try_parent_shorthands(const return 0; *dotdot = 0; - if (get_sha1_committish(arg, oid.hash)) { + if (get_oid_committish(arg, &oid)) { *dotdot = '^'; return 0; } @@@ -387,6 -387,14 +387,14 @@@ static const char *skipspaces(const cha return s; } + static char *findspace(const char *s) + { + for (; *s; s++) + if (isspace(*s)) + return (char*)s; + return NULL; + } + static int cmd_parseopt(int argc, const char **argv, const char *prefix) { static int keep_dashdash = 0, stop_at_non_option = 0; @@@ -434,7 -442,7 +442,7 @@@ /* parse: (|,|)[*=?!]*? SP+ */ while (strbuf_getline(&sb, stdin) != EOF) { const char *s; - const char *help; + char *help; struct option *o; if (!sb.len) @@@ -444,15 -452,17 +452,17 @@@ memset(opts + onb, 0, sizeof(opts[onb])); o = &opts[onb++]; - help = strchr(sb.buf, ' '); - if (!help || *sb.buf == ' ') { + help = findspace(sb.buf); + if (!help || sb.buf == help) { o->type = OPTION_GROUP; o->help = xstrdup(skipspaces(sb.buf)); continue; } + *help = '\0'; + o->type = OPTION_CALLBACK; - o->help = xstrdup(skipspaces(help)); + o->help = xstrdup(skipspaces(help+1)); o->value = &parsed; o->flags = PARSE_OPT_NOARG; o->callback = &parseopt_dump; @@@ -702,7 -712,7 +712,7 @@@ int cmd_rev_parse(int argc, const char } if (!strcmp(arg, "--quiet") || !strcmp(arg, "-q")) { quiet = 1; - flags |= GET_SHA1_QUIETLY; + flags |= GET_OID_QUIETLY; continue; } if (opt_with_value(arg, "--short", &arg)) { @@@ -757,8 -767,8 +767,8 @@@ continue; } if (!strcmp(arg, "--bisect")) { - for_each_ref_in("refs/bisect/bad", show_reference, NULL); - for_each_ref_in("refs/bisect/good", anti_reference, NULL); + for_each_fullref_in("refs/bisect/bad", show_reference, NULL, 0); + for_each_fullref_in("refs/bisect/good", anti_reference, NULL, 0); continue; } if (opt_with_value(arg, "--branches", &arg)) { @@@ -868,11 -878,6 +878,11 @@@ : "false"); continue; } + if (!strcmp(arg, "--is-shallow-repository")) { + printf("%s\n", is_repository_shallow() ? "true" + : "false"); + continue; + } if (!strcmp(arg, "--shared-index-path")) { if (read_cache() < 0) die(_("Could not read the index")); @@@ -916,7 -921,7 +926,7 @@@ name++; type = REVERSED; } - if (!get_sha1_with_context(name, flags, oid.hash, &unused)) { + if (!get_oid_with_context(name, flags, &oid, &unused)) { if (verify) revs_count++; else diff --combined git-rebase.sh index ad8415e3cf,45f187bdbf..6344e8d5e3 --- a/git-rebase.sh +++ b/git-rebase.sh @@@ -55,10 -55,9 +55,10 @@@ LF= ' ok_to_skip_pre_rebase= resolvemsg=" -$(gettext 'When you have resolved this problem, run "git rebase --continue". -If you prefer to skip this patch, run "git rebase --skip" instead. -To check out the original branch and stop rebasing, run "git rebase --abort".') +$(gettext 'Resolve all conflicts manually, mark them as resolved with +"git add/rm ", then run "git rebase --continue". +You can instead skip this commit: run "git rebase --skip". +To abort and get back to the state before "git rebase", run "git rebase --abort".') " unset onto unset restrict_revision @@@ -74,7 -73,6 +74,7 @@@ test "$(git config --bool rebase.stat) autostash="$(git config --bool rebase.autostash || echo false)" fork_point=auto git_am_opt= +git_format_patch_opt= rebase_root= force_rebase= allow_rerere_autoupdate= @@@ -350,6 -348,9 +350,9 @@@ d shift break ;; + *) + usage + ;; esac shift done @@@ -446,11 -447,6 +449,11 @@@ els state_dir="$apply_dir" fi +if test -t 2 && test -z "$GIT_QUIET" +then + git_format_patch_opt="$git_format_patch_opt --progress" +fi + if test -z "$rebase_root" then case "$#" in