From 2af24038a95a3879aa0c29d91a43180b9465247e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 27 Sep 2018 14:14:58 +0200 Subject: [PATCH 1/4] fixup! stash: convert apply to builtin When converting the `stash apply` command, we were missing at least two error messages: when the diff could not be applied with `--index`, we want to suggest to re-run the command without `--index`. While at it, and because we now can, let's also add an error message in the case that the diff could not be generated in the first place (the shell script could not do that, as it piped the output of `git diff` to `git apply`, and there is no portable way to handle errors in the command whose output is redirected). Noticed by Matthew Cheetham. Signed-off-by: Johannes Schindelin --- builtin/stash.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/builtin/stash.c b/builtin/stash.c index ed669dae0f..965e938ebd 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -414,18 +414,19 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, if (diff_tree_binary(&out, &info->w_commit)) { strbuf_release(&out); - return -1; + return error(_("Could not generate diff %s^!."), + oid_to_hex(&info->w_commit)); } ret = apply_cached(&out); strbuf_release(&out); if (ret) - return -1; + return error(_("Conflicts in index. Try without --index.")); discard_cache(); read_cache(); if (write_cache_as_tree(&index_tree, 0, NULL)) - return -1; + return error(_("Could not save index tree")); reset_head(); } From ddb6e5ca19d5cdd318bc4bcbb7f7f3fb0892c8cc Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 27 Sep 2018 15:01:01 +0200 Subject: [PATCH 2/4] fixup! rebase -i: implement the main part of interactive rebase as a builtin The `--gpg-sign` option takes an *optional* argument, not a mandatory one. This fixes https://github.com/git-for-windows/git/issues/1836. Signed-off-by: Johannes Schindelin --- builtin/rebase--interactive.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/rebase--interactive.c b/builtin/rebase--interactive.c index 551faba558..4b9d2a07cb 100644 --- a/builtin/rebase--interactive.c +++ b/builtin/rebase--interactive.c @@ -181,8 +181,9 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix) OPT_STRING(0, "upstream", &upstream, N_("upstream"), N_("the upstream commit")), OPT_STRING(0, "head-name", &head_name, N_("head-name"), N_("head name")), - OPT_STRING('S', "gpg-sign", &opts.gpg_sign, N_("gpg-sign"), - N_("GPG-sign commits")), + { OPTION_STRING, 'S', "gpg-sign", &opts.gpg_sign, N_("key-id"), + N_("GPG-sign commits"), + PARSE_OPT_OPTARG, NULL, (intptr_t) "" }, OPT_STRING(0, "strategy", &opts.strategy, N_("strategy"), N_("rebase strategy")), OPT_STRING(0, "strategy-opts", &raw_strategies, N_("strategy-opts"), From 1e6a1c510ffeae5bb0a4bda7f0528a8213728837 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 27 Sep 2018 14:48:17 +0200 Subject: [PATCH 3/4] fixup! builtin rebase: support `--gpg-sign` option The `--gpg-sign` option takes an *optional* argument, not a mandatory one. This was discovered as part of the investigation of https://github.com/git-for-windows/git/issues/1836. Signed-off-by: Johannes Schindelin --- builtin/rebase.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index a28bfbd62f..43bc6f7915 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1030,8 +1030,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) OPT_BOOL(0, "autosquash", &options.autosquash, N_("move commits that begin with " "squash!/fixup! under -i")), - OPT_STRING('S', "gpg-sign", &gpg_sign, - N_("gpg-sign?"), N_("GPG-sign commits")), + { OPTION_STRING, 'S', "gpg-sign", &gpg_sign, N_("key-id"), + N_("GPG-sign commits"), + PARSE_OPT_OPTARG, NULL, (intptr_t) "" }, OPT_STRING_LIST(0, "whitespace", &whitespace, N_("whitespace"), N_("passed to 'git apply'")), OPT_SET_INT('C', 0, &opt_c, N_("passed to 'git apply'"), From fb77ec5460b97013f9e8c77e7b30d309a36b0ee1 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 27 Sep 2018 15:29:55 +0200 Subject: [PATCH 4/4] fixup! Add a build definition for Azure DevOps In Azure Pipelines, a sane setting is to prevent secret variables from being shared with Pull Requests originating from forks. In Git, we use such a secret variable: we want to mount a file share on which previous we store outcomes of previous runs, and avoid re-running known-good phases (both for speed as well as to avoid spending resources unnecessarily). This file share should not be mounted in PRs. Signed-off-by: Johannes Schindelin --- azure-pipelines.yml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d634686b36..52251a3331 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,7 +10,7 @@ phases: name: Hosted Ubuntu 1604 steps: - bash: | - test -z "$GITFILESHAREPWD" || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 sudo apt-get update && sudo rm /var/lib/apt/lists/lock && @@ -24,7 +24,7 @@ phases: exit 1 } - test -z "$GITFILESHAREPWD" || sudo umount "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1 displayName: 'ci/run-build-and-tests.sh' env: GITFILESHAREPWD: $(gitfileshare.pwd) @@ -44,7 +44,7 @@ phases: name: Hosted Ubuntu 1604 steps: - bash: | - test -z "$GITFILESHAREPWD" || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 sudo apt-get update && sudo rm /var/lib/apt/lists/lock && @@ -56,7 +56,7 @@ phases: exit 1 } - test -z "$GITFILESHAREPWD" || sudo umount "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1 displayName: 'ci/run-build-and-tests.sh' env: GITFILESHAREPWD: $(gitfileshare.pwd) @@ -76,7 +76,7 @@ phases: name: Hosted macOS steps: - bash: | - test -z "$GITFILESHAREPWD" || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 export CC=clang @@ -86,7 +86,7 @@ phases: exit 1 } - test -z "$GITFILESHAREPWD" || umount "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || umount "$HOME/test-cache" || exit 1 displayName: 'ci/run-build-and-tests.sh' env: GITFILESHAREPWD: $(gitfileshare.pwd) @@ -106,7 +106,7 @@ phases: name: Hosted macOS steps: - bash: | - test -z "$GITFILESHAREPWD" || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 ci/install-dependencies.sh ci/run-build-and-tests.sh || { @@ -114,7 +114,7 @@ phases: exit 1 } - test -z "$GITFILESHAREPWD" || umount "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || umount "$HOME/test-cache" || exit 1 displayName: 'ci/run-build-and-tests.sh' env: GITFILESHAREPWD: $(gitfileshare.pwd) @@ -134,7 +134,7 @@ phases: name: Hosted Ubuntu 1604 steps: - bash: | - test -z "$GITFILESHAREPWD" || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 sudo apt-get update && sudo rm /var/lib/apt/lists/lock && @@ -147,7 +147,7 @@ phases: exit 1 } - test -z "$GITFILESHAREPWD" || sudo umount "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1 displayName: 'ci/run-build-and-tests.sh' env: GITFILESHAREPWD: $(gitfileshare.pwd) @@ -171,7 +171,7 @@ phases: # Helper to check the error level of the latest command (exit with error when appropriate) function c() { if (!$?) { exit(1) } } - if ("$GITFILESHAREPWD" -ne "") { + if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") { net use s: \\gitfileshare.file.core.windows.net\test-cache "$GITFILESHAREPWD" /user:AZURE\gitfileshare /persistent:no; c cmd /c mklink /d "$(Build.SourcesDirectory)\test-cache" S:\; c } @@ -223,7 +223,7 @@ phases: "@ c - if ("$GITFILESHAREPWD" -ne "") { + if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") { cmd /c rmdir "$(Build.SourcesDirectory)\test-cache" } displayName: 'build & test' @@ -245,7 +245,7 @@ phases: name: Hosted Ubuntu 1604 steps: - bash: | - test -z "$GITFILESHAREPWD" || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 sudo apt-get update && sudo rm /var/lib/apt/lists/lock && @@ -266,7 +266,7 @@ phases: sudo chmod a+r t/out/TEST-*.xml - test -z "$GITFILESHAREPWD" || sudo umount "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1 displayName: 'ci/run-linux32-docker.sh' env: GITFILESHAREPWD: $(gitfileshare.pwd) @@ -286,7 +286,7 @@ phases: name: Hosted Ubuntu 1604 steps: - bash: | - test -z "$GITFILESHAREPWD" || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 sudo apt-get update && sudo rm /var/lib/apt/lists/lock && @@ -296,7 +296,7 @@ phases: ci/run-static-analysis.sh || exit 1 - test -z "$GITFILESHAREPWD" || sudo umount "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1 displayName: 'ci/run-static-analysis.sh' env: GITFILESHAREPWD: $(gitfileshare.pwd) @@ -308,7 +308,7 @@ phases: name: Hosted Ubuntu 1604 steps: - bash: | - test -z "$GITFILESHAREPWD" || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1 sudo apt-get update && sudo rm /var/lib/apt/lists/lock && @@ -319,7 +319,7 @@ phases: ci/test-documentation.sh || exit 1 - test -z "$GITFILESHAREPWD" || sudo umount "$HOME/test-cache" || exit 1 + test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1 displayName: 'ci/test-documentation.sh' env: GITFILESHAREPWD: $(gitfileshare.pwd)