Merge branch 'js/fuzz-commit-graph-update'
authorJunio C Hamano <gitster@pobox.com>
Sat, 9 Feb 2019 04:44:53 +0000 (20:44 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 9 Feb 2019 04:44:53 +0000 (20:44 -0800)
Update to the fuzzer.

* js/fuzz-commit-graph-update:
object: fix leak of shallow_stat
fuzz-commit-graph: initialize repo object

17 files changed:
.mailmap
Documentation/git-rebase.txt
Documentation/pretty-formats.txt
Makefile
builtin/checkout.c
builtin/rebase.c
ci/lib.sh
git-legacy-rebase.sh
remote-curl.c
t/lib-gpg.sh
t/lib-httpd.sh
t/lib-httpd/apache.conf
t/lib-httpd/error-smart-http.sh [new file with mode: 0644]
t/t3418-rebase-continue.sh
t/t5403-post-checkout-hook.sh
t/t5551-http-fetch-smart.sh
t/t9833-errors.sh
index 247a3deb7e1418f0fdcfd9719cb7f609775d2804..82cd0569d51d0a2d69b013a3322b6d5985a1927c 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -40,6 +40,8 @@ Cord Seele <cowose@gmail.com> <cowose@googlemail.com>
 Christian Couder <chriscool@tuxfamily.org> <christian.couder@gmail.com>
 Christian Stimming <stimming@tuhh.de> <chs@ckiste.goetheallee>
 Christopher Díaz Riveros <chrisadr@gentoo.org> Christopher Diaz Riveros
+Clemens Buchacher <drizzd@gmx.net> <drizzd@aon.at>
+Clemens Buchacher <drizzd@gmx.net> <clemens.buchacher@intel.com>
 Csaba Henk <csaba@gluster.com> <csaba@lowlife.hu>
 Dan Johnson <computerdruid@gmail.com>
 Dana L. How <danahow@gmail.com> <how@deathvalley.cswitch.com>
index 7e695b30e455245d8c187b7be0402e35bb83362c..daa16403ece9f0f050da5a24086e89b181d9c0fa 100644 (file)
@@ -462,12 +462,6 @@ without an explicit `--interactive`.
 +
 See also INCOMPATIBLE OPTIONS below.
 
--y <cmd>::
-       This is the same as passing `--reschedule-failed-exec` before
-       `-x <cmd>`, i.e. it appends the specified `exec` command and
-       turns on the mode where failed `exec` commands are automatically
-       rescheduled.
-
 --root::
        Rebase all commits reachable from <branch>, instead of
        limiting them with an <upstream>.  This allows you to rebase
index de6953108cbc5324b9f6e9dacf23482aa698f45a..7bfffae7652815596dcc29962e67e22efcf3075b 100644 (file)
@@ -183,7 +183,7 @@ endif::git-rev-list[]
   `color.diff`, `color.ui`, or `--color`, and respecting the `auto`
   settings of the former if we are going to a terminal). `%C(auto,...)`
   is accepted as a historical synonym for the default (e.g.,
-  `%C(auto,red)`). Specifying `%C(always,...) will show the colors
+  `%C(auto,red)`). Specifying `%C(always,...)` will show the colors
   even when color is not otherwise enabled (though consider
   just using `--color=always` to enable color for the whole output,
   including this format and anything else git might color).  `auto`
index 571160a2c4dde4b89f3cbddafdcb2d168f9446c1..0e13a5b4698a02e93c9f2c95e06b4193fe229567 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3114,6 +3114,11 @@ coverage-test: coverage-clean-results coverage-compile
        $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
                DEFAULT_TEST_TARGET=test -j1 test
 
+coverage-prove: coverage-clean-results coverage-compile
+       $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
+               DEFAULT_TEST_TARGET=prove GIT_PROVE_OPTS="$(GIT_PROVE_OPTS) -j1" \
+               -j1 test
+
 coverage-report:
        $(QUIET_GCOV)for dir in $(object_dirs); do \
                $(GCOV) $(GCOVFLAGS) --object-directory=$$dir $$dir*.c || exit; \
index ece4eb14bf1e92742b9fc0723a150e595883d8c6..24b8593b938b67baf4a662f2463efdd35562873a 100644 (file)
@@ -261,7 +261,7 @@ static int checkout_paths(const struct checkout_opts *opts,
        struct commit *head;
        int errs = 0;
        struct lock_file lock_file = LOCK_INIT;
-       int nr_checkouts = 0;
+       int nr_checkouts = 0, nr_unmerged = 0;
 
        if (opts->track != BRANCH_TRACK_UNSPECIFIED)
                die(_("'%s' cannot be used with updating paths"), "--track");
@@ -386,23 +386,28 @@ static int checkout_paths(const struct checkout_opts *opts,
                                                       &state, &nr_checkouts);
                        else if (opts->merge)
                                errs |= checkout_merged(pos, &state,
-                                                       &nr_checkouts);
+                                                       &nr_unmerged);
                        pos = skip_same_name(ce, pos) - 1;
                }
        }
        errs |= finish_delayed_checkout(&state, &nr_checkouts);
 
        if (opts->count_checkout_paths) {
+               if (nr_unmerged)
+                       fprintf_ln(stderr, Q_("Recreated %d merge conflict",
+                                             "Recreated %d merge conflicts",
+                                             nr_unmerged),
+                                  nr_unmerged);
                if (opts->source_tree)
-                       fprintf_ln(stderr, Q_("Checked out %d path out of %s",
-                                             "Checked out %d paths out of %s",
+                       fprintf_ln(stderr, Q_("Updated %d path from %s",
+                                             "Updated %d paths from %s",
                                              nr_checkouts),
                                   nr_checkouts,
                                   find_unique_abbrev(&opts->source_tree->object.oid,
                                                      DEFAULT_ABBREV));
-               else
-                       fprintf_ln(stderr, Q_("Checked out %d path out of the index",
-                                             "Checked out %d paths out of the index",
+               else if (!nr_unmerged || nr_checkouts)
+                       fprintf_ln(stderr, Q_("Updated %d path from the index",
+                                             "Updated %d paths from the index",
                                              nr_checkouts),
                                   nr_checkouts);
        }
index b9d61771ab3c17f97bce90f3f847c9284eb14a9a..96efd40901dba9424e61775e3033622ceaaba388 100644 (file)
@@ -941,23 +941,6 @@ static int parse_opt_interactive(const struct option *opt, const char *arg,
        return 0;
 }
 
-struct opt_y {
-       struct string_list *list;
-       struct rebase_options *options;
-};
-
-static int parse_opt_y(const struct option *opt, const char *arg, int unset)
-{
-       struct opt_y *o = opt->value;
-
-       if (unset || !arg)
-               return -1;
-
-       o->options->reschedule_failed_exec = 1;
-       string_list_append(o->list, arg);
-       return 0;
-}
-
 static void NORETURN error_on_missing_default_upstream(void)
 {
        struct branch *current_branch = branch_get(NULL);
@@ -1051,7 +1034,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
        struct string_list strategy_options = STRING_LIST_INIT_NODUP;
        struct object_id squash_onto;
        char *squash_onto_name = NULL;
-       struct opt_y opt_y = { .list = &exec, .options = &options };
        struct option builtin_rebase_options[] = {
                OPT_STRING(0, "onto", &options.onto_name,
                           N_("revision"),
@@ -1129,9 +1111,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
                OPT_STRING_LIST('x', "exec", &exec, N_("exec"),
                                N_("add exec lines after each commit of the "
                                   "editable list")),
-               { OPTION_CALLBACK, 'y', NULL, &opt_y, N_("<cmd>"),
-                       N_("same as --reschedule-failed-exec -x <cmd>"),
-                       PARSE_OPT_NONEG, parse_opt_y },
                OPT_BOOL(0, "allow-empty-message",
                         &options.allow_empty_message,
                         N_("allow rebasing commits with empty messages")),
index 16f4ecbc67196b19f45d4e5c2273b8ea35e0895d..288a5b3884ad825c99601ba5dc62ee81c62d7d64 100755 (executable)
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -74,6 +74,9 @@ check_unignored_build_artifacts ()
        }
 }
 
+# Clear MAKEFLAGS that may come from the outside world.
+export MAKEFLAGS=
+
 # Set 'exit on error' for all CI scripts to let the caller know that
 # something went wrong.
 # Set tracing executed commands, primarily setting environment variables
@@ -101,7 +104,7 @@ then
        BREW_INSTALL_PACKAGES="git-lfs gettext"
        export GIT_PROVE_OPTS="--timer --jobs 3 --state=failed,slow,save"
        export GIT_TEST_OPTS="--verbose-log -x --immediate"
-       export MAKEFLAGS="--jobs=2"
+       MAKEFLAGS="$MAKEFLAGS --jobs=2"
 elif test -n "$SYSTEM_COLLECTIONURI" || test -n "$SYSTEM_TASKDEFINITIONSURI"
 then
        CI_TYPE=azure-pipelines
@@ -126,7 +129,7 @@ then
        BREW_INSTALL_PACKAGES=gcc@8
        export GIT_PROVE_OPTS="--timer --jobs 10 --state=failed,slow,save"
        export GIT_TEST_OPTS="--verbose-log -x --write-junit-xml"
-       export MAKEFLAGS="--jobs=10"
+       MAKEFLAGS="$MAKEFLAGS --jobs=10"
        test windows_nt != "$CI_OS_NAME" ||
        GIT_TEST_OPTS="--no-chain-lint --no-bin-wrappers $GIT_TEST_OPTS"
 else
@@ -185,4 +188,4 @@ GIT_TEST_GETTEXT_POISON)
        ;;
 esac
 
-export MAKEFLAGS="CC=${CC:-cc}"
+MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"
index 8d6c9aca6584f76689246604abe047a85504671e..5c2c4e5276d17f257b255e85db112557d9d7fc61 100755 (executable)
@@ -26,7 +26,6 @@ f,force-rebase!    cherry-pick all commits, even if unchanged
 m,merge!           use merging strategies to rebase
 i,interactive!     let the user edit the list of commits to rebase
 x,exec=!           add exec lines after each commit of the editable list
-y=!                same as --reschedule-failed-exec -x
 k,keep-empty      preserve empty commits during rebase
 allow-empty-message allow rebasing commits with empty messages
 stat!              display a diffstat of what changed upstream
@@ -261,11 +260,6 @@ do
                cmd="${cmd}exec ${1#--exec=}${LF}"
                test -z "$interactive_rebase" && interactive_rebase=implied
                ;;
-       -y*)
-               reschedule_failed_exec=--reschedule-failed-exec
-               cmd="${cmd}exec ${1#-y}${LF}"
-               test -z "$interactive_rebase" && interactive_rebase=implied
-               ;;
        --interactive)
                interactive_rebase=explicit
                ;;
index 2e04d53ac8e79c9f5a3839a7ab97fd67f2588021..bb7421023ba584d59592124aa6f3ff2028bc5356 100644 (file)
@@ -331,9 +331,63 @@ static int get_protocol_http_header(enum protocol_version version,
        return 0;
 }
 
+static void check_smart_http(struct discovery *d, const char *service,
+                            struct strbuf *type)
+{
+       const char *p;
+       struct packet_reader reader;
+
+       /*
+        * If we don't see x-$service-advertisement, then it's not smart-http.
+        * But once we do, we commit to it and assume any other protocol
+        * violations are hard errors.
+        */
+       if (!skip_prefix(type->buf, "application/x-", &p) ||
+           !skip_prefix(p, service, &p) ||
+           strcmp(p, "-advertisement"))
+               return;
+
+       packet_reader_init(&reader, -1, d->buf, d->len,
+                          PACKET_READ_CHOMP_NEWLINE |
+                          PACKET_READ_DIE_ON_ERR_PACKET);
+       if (packet_reader_read(&reader) != PACKET_READ_NORMAL)
+               die("invalid server response; expected service, got flush packet");
+
+       if (skip_prefix(reader.line, "# service=", &p) && !strcmp(p, service)) {
+               /*
+                * The header can include additional metadata lines, up
+                * until a packet flush marker.  Ignore these now, but
+                * in the future we might start to scan them.
+                */
+               for (;;) {
+                       packet_reader_read(&reader);
+                       if (reader.pktlen <= 0) {
+                               break;
+                       }
+               }
+
+               /*
+                * v0 smart http; callers expect us to soak up the
+                * service and header packets
+                */
+               d->buf = reader.src_buffer;
+               d->len = reader.src_len;
+               d->proto_git = 1;
+
+       } else if (!strcmp(reader.line, "version 2")) {
+               /*
+                * v2 smart http; do not consume version packet, which will
+                * be handled elsewhere.
+                */
+               d->proto_git = 1;
+
+       } else {
+               die("invalid server response; got '%s'", reader.line);
+       }
+}
+
 static struct discovery *discover_refs(const char *service, int for_push)
 {
-       struct strbuf exp = STRBUF_INIT;
        struct strbuf type = STRBUF_INIT;
        struct strbuf charset = STRBUF_INIT;
        struct strbuf buffer = STRBUF_INIT;
@@ -405,47 +459,8 @@ static struct discovery *discover_refs(const char *service, int for_push)
        last->buf_alloc = strbuf_detach(&buffer, &last->len);
        last->buf = last->buf_alloc;
 
-       strbuf_addf(&exp, "application/x-%s-advertisement", service);
-       if (maybe_smart &&
-           (5 <= last->len && last->buf[4] == '#') &&
-           !strbuf_cmp(&exp, &type)) {
-               struct packet_reader reader;
-               packet_reader_init(&reader, -1, last->buf, last->len,
-                                  PACKET_READ_CHOMP_NEWLINE |
-                                  PACKET_READ_DIE_ON_ERR_PACKET);
-
-               /*
-                * smart HTTP response; validate that the service
-                * pkt-line matches our request.
-                */
-               if (packet_reader_read(&reader) != PACKET_READ_NORMAL)
-                       die("invalid server response; expected service, got flush packet");
-
-               strbuf_reset(&exp);
-               strbuf_addf(&exp, "# service=%s", service);
-               if (strcmp(reader.line, exp.buf))
-                       die("invalid server response; got '%s'", reader.line);
-               strbuf_release(&exp);
-
-               /* The header can include additional metadata lines, up
-                * until a packet flush marker.  Ignore these now, but
-                * in the future we might start to scan them.
-                */
-               for (;;) {
-                       packet_reader_read(&reader);
-                       if (reader.pktlen <= 0) {
-                               break;
-                       }
-               }
-
-               last->buf = reader.src_buffer;
-               last->len = reader.src_len;
-
-               last->proto_git = 1;
-       } else if (maybe_smart &&
-                  last->len > 5 && starts_with(last->buf + 4, "version 2")) {
-               last->proto_git = 1;
-       }
+       if (maybe_smart)
+               check_smart_http(last, service, &type);
 
        if (last->proto_git)
                last->refs = parse_git_refs(last, for_push);
@@ -453,7 +468,6 @@ static struct discovery *discover_refs(const char *service, int for_push)
                last->refs = parse_info_refs(last);
 
        strbuf_release(&refs_url);
-       strbuf_release(&exp);
        strbuf_release(&type);
        strbuf_release(&charset);
        strbuf_release(&effective_url);
index f1277bef4fa65e72607ea1f2dac326048559e6aa..8d28652b729b46cb08de8ddd4347dddda9e246a7 100755 (executable)
@@ -63,8 +63,7 @@ then
                cut -d" " -f4 |
                tr -d '\n' >"${GNUPGHOME}/trustlist.txt" &&
 
-               echo " S relax" >> ${GNUPGHOME}/trustlist.txt &&
-               (gpgconf --kill gpg-agent >/dev/null 2>&1 || : ) &&
+               echo " S relax" >>"${GNUPGHOME}/trustlist.txt" &&
                echo hello | gpgsm --homedir "${GNUPGHOME}" >/dev/null \
                        -u committer@example.com -o /dev/null --sign - 2>&1 &&
                test_set_prereq GPGSM
index e465116ef950404521ed2e119ef7cf398bf9da81..216281eabc442c2f49eed0bbf4410db9681b7698 100644 (file)
@@ -131,6 +131,7 @@ prepare_httpd() {
        mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH"
        cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH"
        install_script broken-smart-http.sh
+       install_script error-smart-http.sh
        install_script error.sh
        install_script apply-one-time-sed.sh
 
index 5d63ed90c51cf215dd24bf634f47413c2fa27368..06a81b54c75d5948b31c03152609fccb1311c12f 100644 (file)
@@ -119,6 +119,7 @@ Alias /auth/dumb/ www/auth/dumb/
 ScriptAliasMatch /error_git_upload_pack/(.*)/git-upload-pack error.sh/
 ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1
 ScriptAlias /broken_smart/ broken-smart-http.sh/
+ScriptAlias /error_smart/ error-smart-http.sh/
 ScriptAlias /error/ error.sh/
 ScriptAliasMatch /one_time_sed/(.*) apply-one-time-sed.sh/$1
 <Directory ${GIT_EXEC_PATH}>
@@ -127,6 +128,9 @@ ScriptAliasMatch /one_time_sed/(.*) apply-one-time-sed.sh/$1
 <Files broken-smart-http.sh>
        Options ExecCGI
 </Files>
+<Files error-smart-http.sh>
+       Options ExecCGI
+</Files>
 <Files error.sh>
   Options ExecCGI
 </Files>
diff --git a/t/lib-httpd/error-smart-http.sh b/t/lib-httpd/error-smart-http.sh
new file mode 100644 (file)
index 0000000..e65d447
--- /dev/null
@@ -0,0 +1,3 @@
+echo "Content-Type: application/x-git-upload-pack-advertisement"
+echo
+printf "%s" "0019ERR server-side error"
index 25aaacacfc6b7beb1e29b73678777a76c6af9f71..bdaa511bb0ae1082568e83781252f667b39cda8a 100755 (executable)
@@ -262,9 +262,6 @@ test_expect_success '--reschedule-failed-exec' '
        test_must_fail git -c rebase.rescheduleFailedExec=true \
                rebase -x false HEAD^ 2>err &&
        grep "^exec false" .git/rebase-merge/git-rebase-todo &&
-       test_i18ngrep "has been rescheduled" err &&
-       git rebase --abort &&
-       test_must_fail git rebase -y false HEAD^ 2>err &&
        test_i18ngrep "has been rescheduled" err
 '
 
index a539ffc0803a746c70d458a95f27144c9039afff..a39b3b5c78bc900ae4e9c629598381f915d291de 100755 (executable)
@@ -67,7 +67,7 @@ test_expect_success 'post-checkout is triggered on rebase with fast-forward' '
 test_expect_success 'post-checkout hook is triggered by clone' '
        mkdir -p templates/hooks &&
        write_script templates/hooks/post-checkout <<-\EOF &&
-       echo "$@" >$GIT_DIR/post-checkout.args
+       echo "$@" >"$GIT_DIR/post-checkout.args"
        EOF
        git clone --template=templates . clone3 &&
        test -f clone3/.git/post-checkout.args
index 8630b0cc39045f913987463a36388bcd72d6e248..ba83e567e5ca49c1664fe13f447e2744d55bfb3a 100755 (executable)
@@ -429,5 +429,10 @@ test_expect_success 'GIT_TRACE_CURL_NO_DATA prevents data from being traced' '
        ! grep "=> Send data" err
 '
 
+test_expect_success 'server-side error detected' '
+       test_must_fail git clone $HTTPD_URL/error_smart/repo.git 2>actual &&
+       grep "server-side error" actual
+'
+
 stop_httpd
 test_done
index 277d34701201af03d0efbcfe05336b6cfec5483b..47b312e1c9705af6f6ac6bb55ee81cb847f53d0c 100755 (executable)
@@ -45,33 +45,6 @@ test_expect_success 'ticket logged out' '
        )
 '
 
-test_expect_success 'create group with short ticket expiry' '
-       P4TICKETS="$cli/tickets" &&
-       echo "newpassword" | p4 login &&
-       p4_add_user short_expiry_user &&
-       p4 -u short_expiry_user passwd -P password &&
-       p4 group -i <<-EOF &&
-       Group: testgroup
-       Timeout: 3
-       Users: short_expiry_user
-       EOF
-
-       p4 users | grep short_expiry_user
-'
-
-test_expect_success 'git operation with expired ticket' '
-       P4TICKETS="$cli/tickets" &&
-       P4USER=short_expiry_user &&
-       echo "password" | p4 login &&
-       (
-               cd "$git" &&
-               git p4 sync &&
-               sleep 5 &&
-               test_must_fail git p4 sync 2>errmsg &&
-               grep "failure accessing depot" errmsg
-       )
-'
-
 test_expect_success 'kill p4d' '
        kill_p4d
 '