From patchwork Wed Aug 26 01:17:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 11737043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 56BE21751 for ; Wed, 26 Aug 2020 01:17:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 30F1720737 for ; Wed, 26 Aug 2020 01:17:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="ZlbRakK7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726719AbgHZBRa (ORCPT ); Tue, 25 Aug 2020 21:17:30 -0400 Received: from pb-smtp21.pobox.com ([173.228.157.53]:55282 "EHLO pb-smtp21.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726627AbgHZBR1 (ORCPT ); Tue, 25 Aug 2020 21:17:27 -0400 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 89D2BE64AC; Tue, 25 Aug 2020 21:17:25 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=AZA8eK+RMPJ/B0VPtL6OkzKSA EQ=; b=ZlbRakK7qU6MjSZMKH+8XxQOAM4Ev/yXKWkSRP4WzYcrYZXdU6xv4/Cc/ RXvLOWLCrFLypwknAb8/3XbqqIkLmcTCC66vUP3xFZkzuFCym8RZHXCsJhLEZv5L 0d/+81i2KsBRbd2WT3nAd7sqJ5gjuIED1yl3IenFy46sSHpw7U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; q=dns; s=sasl; b=BCCqiM+vilKm1i4e/mJ OdKba7CIbXMZ1UsK9MV3fKaukStSsBoKCZbdFDguXg0X0JB++ryGWy/vBSBVMyq+ enWHCctt31xiKYuMzvkDewqpUTpPBVNs/3g5wCJ3YsB1ofXya3hphkHkPhbpoWsE mzudQAazvhSKEeqHiOhf1chA= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 6AA86E64AB; Tue, 25 Aug 2020 21:17:25 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [34.75.7.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id E2BC1E64AA; Tue, 25 Aug 2020 21:17:22 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Cc: Johannes Schindelin , Jeff King Subject: [PATCH v1 1/3] transport-helper: do not run git-remote-ext etc. in dashed form Date: Tue, 25 Aug 2020 18:17:16 -0700 Message-Id: <20200826011718.3186597-2-gitster@pobox.com> X-Mailer: git-send-email 2.28.0-454-g5f859b1948 In-Reply-To: <20200826011718.3186597-1-gitster@pobox.com> References: <20200826011718.3186597-1-gitster@pobox.com> MIME-Version: 1.0 X-Pobox-Relay-ID: E5013D9C-E739-11EA-A9D9-843F439F7C89-77302942!pb-smtp21.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Runing them as "git remote-ext" and letting "git" dispatch to "remote-ext" would just be fine and is more idiomatic. Signed-off-by: Junio C Hamano Signed-off-by: Johannes Schindelin --- transport-helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/transport-helper.c b/transport-helper.c index defafbf4c1..fae3d99500 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -128,7 +128,8 @@ static struct child_process *get_helper(struct transport *transport) helper->in = -1; helper->out = -1; helper->err = 0; - strvec_pushf(&helper->args, "git-remote-%s", data->name); + strvec_push(&helper->args, "git"); + strvec_pushf(&helper->args, "remote-%s", data->name); strvec_push(&helper->args, transport->remote->name); strvec_push(&helper->args, remove_ext_force(transport->url)); helper->git_cmd = 0; From patchwork Wed Aug 26 01:17:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 11737045 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0C55722 for ; Wed, 26 Aug 2020 01:17:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1DE52074A for ; Wed, 26 Aug 2020 01:17:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="Ia/gAKdm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726730AbgHZBRd (ORCPT ); Tue, 25 Aug 2020 21:17:33 -0400 Received: from pb-smtp20.pobox.com ([173.228.157.52]:61832 "EHLO pb-smtp20.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726711AbgHZBRc (ORCPT ); Tue, 25 Aug 2020 21:17:32 -0400 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id B0F7FE1012; Tue, 25 Aug 2020 21:17:28 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=5tvPmnN8ArcMbDSyfcJPpxgMO mU=; b=Ia/gAKdmctfrBuVRZ2651Hd/CDq75JMrZG3QtUIT74OOGVjYBux+y7cSG NULa+DCg7Vk5tBPv5lvRmWwApdZCzg4i573os2yiX2KQpWffOcknIiz76NnjND9l CgjSXdyKtbhq6aIKrLKCwx6TL1rXxhkHaf46Lgp1qjCD2idqY8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; q=dns; s=sasl; b=cGux4OoPU3Jl4M+cyQm A//H7uL6ZvkfVXY8USLxlgFWnf5kKD5I/Fa8wldpdjJYHdZexg52ZmbbwrS0O1Px LhtV2psREowd4L4s4PITrts2H7vEGBfJpSnlGb/BuKygEcLcK18NEpjSSc1PDjIx T3MRM2PeuT4W9+Nd3WKOfgXg= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id AA10BE1011; Tue, 25 Aug 2020 21:17:28 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [34.75.7.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id 29869E1010; Tue, 25 Aug 2020 21:17:26 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Cc: Johannes Schindelin , Jeff King Subject: [PATCH v1 2/3] cvsexportcommit: do not run git programs in dashed form Date: Tue, 25 Aug 2020 18:17:17 -0700 Message-Id: <20200826011718.3186597-3-gitster@pobox.com> X-Mailer: git-send-email 2.28.0-454-g5f859b1948 In-Reply-To: <20200826011718.3186597-1-gitster@pobox.com> References: <20200826011718.3186597-1-gitster@pobox.com> MIME-Version: 1.0 X-Pobox-Relay-ID: E6EFA3C8-E739-11EA-969D-F0EA2EB3C613-77302942!pb-smtp20.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This ancient script runs "git-foo" all over the place. A strange thing is that it has t9200 tests successfully running, even though it does not seem to futz with PATH to prepend $(git --exec-path) output. It is tempting to declare that the command must be unused, but that is left to another topic. Signed-off-by: Junio C Hamano --- git-cvsexportcommit.perl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl index 0ae8bce3fb..289d4bc684 100755 --- a/git-cvsexportcommit.perl +++ b/git-cvsexportcommit.perl @@ -30,7 +30,7 @@ # Remember where GIT_DIR is before changing to CVS checkout unless ($ENV{GIT_DIR}) { # No GIT_DIR set. Figure it out for ourselves - my $gd =`git-rev-parse --git-dir`; + my $gd =`git rev-parse --git-dir`; chomp($gd); $ENV{GIT_DIR} = $gd; } @@ -66,7 +66,7 @@ # resolve target commit my $commit; $commit = pop @ARGV; -$commit = safe_pipe_capture('git-rev-parse', '--verify', "$commit^0"); +$commit = safe_pipe_capture('git', 'rev-parse', '--verify', "$commit^0"); chomp $commit; if ($?) { die "The commit reference $commit did not resolve!"; @@ -76,7 +76,7 @@ my $parent; if (@ARGV) { $parent = pop @ARGV; - $parent = safe_pipe_capture('git-rev-parse', '--verify', "$parent^0"); + $parent = safe_pipe_capture('git', 'rev-parse', '--verify', "$parent^0"); chomp $parent; if ($?) { die "The parent reference did not resolve!"; @@ -84,7 +84,7 @@ } # find parents from the commit itself -my @commit = safe_pipe_capture('git-cat-file', 'commit', $commit); +my @commit = safe_pipe_capture('git', 'cat-file', 'commit', $commit); my @parents; my $committer; my $author; @@ -162,9 +162,9 @@ close MSG; if ($parent eq $noparent) { - `git-diff-tree --binary -p --root $commit >.cvsexportcommit.diff`;# || die "Cannot diff"; + `git diff-tree --binary -p --root $commit >.cvsexportcommit.diff`;# || die "Cannot diff"; } else { - `git-diff-tree --binary -p $parent $commit >.cvsexportcommit.diff`;# || die "Cannot diff"; + `git diff-tree --binary -p $parent $commit >.cvsexportcommit.diff`;# || die "Cannot diff"; } ## apply non-binary changes @@ -178,7 +178,7 @@ print "Checking if patch will apply\n"; my @stat; -open APPLY, "GIT_INDEX_FILE=$tmpdir/index git-apply $context --summary --numstat<.cvsexportcommit.diff|" || die "cannot patch"; +open APPLY, "GIT_INDEX_FILE=$tmpdir/index git apply $context --summary --numstat<.cvsexportcommit.diff|" || die "cannot patch"; @stat=; close APPLY || die "Cannot patch"; my (@bfiles,@files,@afiles,@dfiles); @@ -333,7 +333,7 @@ if ($opt_W) { system("git checkout -q $commit^0") && die "cannot patch"; } else { - `GIT_INDEX_FILE=$tmpdir/index git-apply $context --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch"; + `GIT_INDEX_FILE=$tmpdir/index git apply $context --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch"; } print "Patch applied successfully. Adding new files and directories to CVS\n"; From patchwork Wed Aug 26 01:17:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 11737049 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B223513A4 for ; Wed, 26 Aug 2020 01:17:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 917B920737 for ; Wed, 26 Aug 2020 01:17:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="DRTrHp8U" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726739AbgHZBRf (ORCPT ); Tue, 25 Aug 2020 21:17:35 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:57642 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726716AbgHZBRd (ORCPT ); Tue, 25 Aug 2020 21:17:33 -0400 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 4DD3482FD9; Tue, 25 Aug 2020 21:17:29 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=V/fm9Ajw39oPmWmHUp0JYLwHZ kw=; b=DRTrHp8ULAy+Pwnr2PL4WGzzxuVNNcgc6qvJp6QeYjFukmrHbquCxJpd/ oPIBDCcC9FMCfYvlo14AV7G2JnIG1KwwaTLdi7pMCzjc3kTG0+WNeTYkPVTpByYq 5r6oa1vMgqAIp9lJjGaNNVPLUOL/kW9//DaDeBxYAEJCNz18wA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; q=dns; s=sasl; b=IdK0xSlXY1vGYnhWlFB K7bJzjpPp3JZkpMWAca15Y+g+ZH1bxWKBFk3Rc86bENpCcROCd0iyHx6KCqEE4sZ e0ih5f3cz9k1rzcH3VfxqEGtpH0HuP9vUCmH8AWAwApdKMk2gPbmPgNN6djMkOOk zGhwnsh0zUErgsdrXRyOf5XQ= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 4561F82FD8; Tue, 25 Aug 2020 21:17:29 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [34.75.7.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id C215E82FD7; Tue, 25 Aug 2020 21:17:28 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Cc: Johannes Schindelin , Jeff King Subject: [PATCH v1 3/3] git: catch an attempt to run "git-foo" Date: Tue, 25 Aug 2020 18:17:18 -0700 Message-Id: <20200826011718.3186597-4-gitster@pobox.com> X-Mailer: git-send-email 2.28.0-454-g5f859b1948 In-Reply-To: <20200826011718.3186597-1-gitster@pobox.com> References: <20200826011718.3186597-1-gitster@pobox.com> MIME-Version: 1.0 X-Pobox-Relay-ID: E880DC16-E739-11EA-8984-2F5D23BA3BAF-77302942!pb-smtp2.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org If we were to propose removing "git-foo" binaries from the filesystem for built-in commands, we should first see if there are users who will be affected by such a move. When cmd_main() detects we were called not as "git", but as "git-foo", give an error message to ask the user to let us know and stop our removal plan, unless we are running a selected few programs that MUST be callable in the dashed form (e.g. "git-upload-pack"). Those who are always using "git foo" form will not be affected, but those who trusted the promise we made to them 12 years ago that by prepending the output of $(git --exec-path) to the list of directories on their $PATH, they can safely keep writing "git-cat-file" will be negatively affected as all their scripts assuming the promise will be kept are now broken. Signed-off-by: Junio C Hamano Signed-off-by: Johannes Schindelin Signed-off-by: Johannes Schindelin --- command-list.txt | 11 +++++++---- git.c | 2 ++ help.c | 34 ++++++++++++++++++++++++++++++++++ help.h | 3 +++ 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/command-list.txt b/command-list.txt index e5901f2213..1238f6ec8b 100644 --- a/command-list.txt +++ b/command-list.txt @@ -39,6 +39,9 @@ # mainporcelain commands are completable so you don't need this # attribute. # +# "onpath" attribute is used to mark that the command MUST appear +# on $PATH (typically in /usr/bin) due to protocol requirement. +# # As part of the Git man page list, the man(5/7) guides are also # specified here, which can only have "guide" attribute and nothing # else. @@ -144,7 +147,7 @@ git-quiltimport foreignscminterface git-range-diff mainporcelain git-read-tree plumbingmanipulators git-rebase mainporcelain history -git-receive-pack synchelpers +git-receive-pack synchelpers onpath git-reflog ancillarymanipulators complete git-remote ancillarymanipulators complete git-repack ancillarymanipulators complete @@ -159,7 +162,7 @@ git-rev-parse plumbinginterrogators git-rm mainporcelain worktree git-send-email foreignscminterface complete git-send-pack synchingrepositories -git-shell synchelpers +git-shell synchelpers onpath git-shortlog mainporcelain git-show mainporcelain info git-show-branch ancillaryinterrogators complete @@ -182,8 +185,8 @@ git-unpack-objects plumbingmanipulators git-update-index plumbingmanipulators git-update-ref plumbingmanipulators git-update-server-info synchingrepositories -git-upload-archive synchelpers -git-upload-pack synchelpers +git-upload-archive synchelpers onpath +git-upload-pack synchelpers onpath git-var plumbinginterrogators git-verify-commit ancillaryinterrogators git-verify-pack plumbinginterrogators diff --git a/git.c b/git.c index 8bd1d7551d..927018bda7 100644 --- a/git.c +++ b/git.c @@ -839,6 +839,8 @@ int cmd_main(int argc, const char **argv) * that one cannot handle it. */ if (skip_prefix(cmd, "git-", &cmd)) { + warn_on_dashed_git(argv[0]); + argv[0] = cmd; handle_builtin(argc, argv); die(_("cannot handle %s as a builtin"), cmd); diff --git a/help.c b/help.c index d478afb2af..490d2bc3ae 100644 --- a/help.c +++ b/help.c @@ -720,3 +720,37 @@ NORETURN void help_unknown_ref(const char *ref, const char *cmd, string_list_clear(&suggested_refs, 0); exit(1); } + +static struct cmdname_help *find_cmdname_help(const char *name) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(command_list); i++) { + if (!strcmp(command_list[i].name, name)) + return &command_list[i]; + } + return NULL; +} + +void warn_on_dashed_git(const char *cmd) +{ + struct cmdname_help *cmdname; + static const char *still_in_use_var = "GIT_I_STILL_USE_DASHED_GIT"; + static const char *still_in_use_msg = + N_("Use of '%s' in the dashed-form is nominated for removal.\n" + "If you still use it, export '%s=true'\n" + "and send an e-mail to \n" + "to let us know and stop our removal plan. Thanks.\n"); + + if (!cmd) + return; /* git-help is OK */ + + cmdname = find_cmdname_help(cmd); + if (cmdname && (cmdname->category & CAT_onpath)) + return; /* git-upload-pack and friends are OK */ + + if (!git_env_bool(still_in_use_var, 0)) { + fprintf(stderr, _(still_in_use_msg), cmd, still_in_use_var); + exit(1); + } +} diff --git a/help.h b/help.h index dc02458855..d3de5e0d69 100644 --- a/help.h +++ b/help.h @@ -45,6 +45,9 @@ void get_version_info(struct strbuf *buf, int show_build_options); */ NORETURN void help_unknown_ref(const char *ref, const char *cmd, const char *error); +/* When the cmd_main() sees "git-foo", check if the user intended */ +void warn_on_dashed_git(const char *); + static inline void list_config_item(struct string_list *list, const char *prefix, const char *str)