From e000c61525c62bb52b9d8a1b479e88d91667608a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 4 Feb 2020 19:36:46 +0100 Subject: [PATCH] vfs: disable `git update-git-for-windows` If a user runs git update-git-for-windows, then they will upgrade to a version that does not support microsoft/vfsforgit or microsoft/scalar. Therefore, let's prevent this. This addresses https://github.com/microsoft/git/issues/241 --- builtin.h | 1 + git.c | 2 ++ help.c | 16 ++++++++++++++++ t/t0402-block-command-on-gvfs.sh | 7 +++++++ 4 files changed, 26 insertions(+) diff --git a/builtin.h b/builtin.h index a5ae15bfe5..3583148a08 100644 --- a/builtin.h +++ b/builtin.h @@ -220,6 +220,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix); int cmd_tar_tree(int argc, const char **argv, const char *prefix); int cmd_unpack_file(int argc, const char **argv, const char *prefix); int cmd_unpack_objects(int argc, const char **argv, const char *prefix); +int cmd_update(int argc, const char **argv, const char *prefix); int cmd_update_index(int argc, const char **argv, const char *prefix); int cmd_update_ref(int argc, const char **argv, const char *prefix); int cmd_update_server_info(int argc, const char **argv, const char *prefix); diff --git a/git.c b/git.c index 5475492223..d2f80313a9 100644 --- a/git.c +++ b/git.c @@ -658,6 +658,8 @@ static struct cmd_struct commands[] = { { "tag", cmd_tag, RUN_SETUP | DELAY_PAGER_CONFIG }, { "unpack-file", cmd_unpack_file, RUN_SETUP | NO_PARSEOPT }, { "unpack-objects", cmd_unpack_objects, RUN_SETUP | NO_PARSEOPT }, + { "update", cmd_update }, + { "update-git-for-windows", cmd_update }, { "update-index", cmd_update_index, RUN_SETUP }, { "update-ref", cmd_update_ref, RUN_SETUP }, { "update-server-info", cmd_update_server_info, RUN_SETUP }, diff --git a/help.c b/help.c index 44cee69c11..640aa87257 100644 --- a/help.c +++ b/help.c @@ -720,3 +720,19 @@ NORETURN void help_unknown_ref(const char *ref, const char *cmd, string_list_clear(&suggested_refs, 0); exit(1); } + +int cmd_update(int argc, const char **argv, const char *prefix) +{ + const char * const usage[] = { + N_("git update-git-for-windows []\n" + "\t(not supported in this build of Git for Windows)"), + NULL + }; + struct option options[] = { + OPT_END() + }; + + argc = parse_options(argc, argv, prefix, options, usage, 0); + + die(_("git %s is not supported in VFSforGit"), argv[0]); +} diff --git a/t/t0402-block-command-on-gvfs.sh b/t/t0402-block-command-on-gvfs.sh index 3370abad46..fd30430b09 100755 --- a/t/t0402-block-command-on-gvfs.sh +++ b/t/t0402-block-command-on-gvfs.sh @@ -36,4 +36,11 @@ test_expect_success 'test gc --auto succeeds when disabled via config' ' git gc --auto ' +test_expect_success 'update-git-for-windows disabled' ' + test_must_fail git update 2>out && + test_i18ngrep VFS out && + test_must_fail git update-git-for-windows 2>out && + test_i18ngrep VFS out +' + test_done