Skip to content

Commit 90a34de

Browse files
committed
Merge branch 'jc/war-on-dashed-git' into seen
The first step to remove on-disk binaries for built-in subcommands by soliciting objections. * jc/war-on-dashed-git: git: catch an attempt to run "git-foo"
2 parents 6c4d314 + eb23dcd commit 90a34de

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

command-list.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
# mainporcelain commands are completable so you don't need this
4040
# attribute.
4141
#
42+
# "onpath" attribute is used to mark that the command MUST appear
43+
# on $PATH (typically in /usr/bin) due to protocol requirement.
44+
#
4245
# As part of the Git man page list, the man(5/7) guides are also
4346
# specified here, which can only have "guide" attribute and nothing
4447
# else.
@@ -145,7 +148,7 @@ git-quiltimport foreignscminterface
145148
git-range-diff mainporcelain
146149
git-read-tree plumbingmanipulators
147150
git-rebase mainporcelain history
148-
git-receive-pack synchelpers
151+
git-receive-pack synchelpers onpath
149152
git-reflog ancillarymanipulators complete
150153
git-remote ancillarymanipulators complete
151154
git-repack ancillarymanipulators complete
@@ -160,7 +163,7 @@ git-rev-parse plumbinginterrogators
160163
git-rm mainporcelain worktree
161164
git-send-email foreignscminterface complete
162165
git-send-pack synchingrepositories
163-
git-shell synchelpers
166+
git-shell synchelpers onpath
164167
git-shortlog mainporcelain
165168
git-show mainporcelain info
166169
git-show-branch ancillaryinterrogators complete
@@ -183,8 +186,8 @@ git-unpack-objects plumbingmanipulators
183186
git-update-index plumbingmanipulators
184187
git-update-ref plumbingmanipulators
185188
git-update-server-info synchingrepositories
186-
git-upload-archive synchelpers
187-
git-upload-pack synchelpers
189+
git-upload-archive synchelpers onpath
190+
git-upload-pack synchelpers onpath
188191
git-var plumbinginterrogators
189192
git-verify-commit ancillaryinterrogators
190193
git-verify-pack plumbinginterrogators

git.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,8 @@ int cmd_main(int argc, const char **argv)
853853
* that one cannot handle it.
854854
*/
855855
if (skip_prefix(cmd, "git-", &cmd)) {
856+
warn_on_dashed_git(argv[0]);
857+
856858
argv[0] = cmd;
857859
handle_builtin(argc, argv);
858860
die(_("cannot handle %s as a builtin"), cmd);

help.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,3 +720,37 @@ NORETURN void help_unknown_ref(const char *ref, const char *cmd,
720720
string_list_clear(&suggested_refs, 0);
721721
exit(1);
722722
}
723+
724+
static struct cmdname_help *find_cmdname_help(const char *name)
725+
{
726+
int i;
727+
728+
for (i = 0; i < ARRAY_SIZE(command_list); i++) {
729+
if (!strcmp(command_list[i].name, name))
730+
return &command_list[i];
731+
}
732+
return NULL;
733+
}
734+
735+
void warn_on_dashed_git(const char *cmd)
736+
{
737+
struct cmdname_help *cmdname;
738+
static const char *still_in_use_var = "GIT_I_STILL_USE_DASHED_GIT";
739+
static const char *still_in_use_msg =
740+
N_("Use of '%s' in the dashed-form is nominated for removal.\n"
741+
"If you still use it, export '%s=true'\n"
742+
"and send an e-mail to <[email protected]>\n"
743+
"to let us know and stop our removal plan. Thanks.\n");
744+
745+
if (!cmd)
746+
return; /* git-help is OK */
747+
748+
cmdname = find_cmdname_help(cmd);
749+
if (cmdname && (cmdname->category & CAT_onpath))
750+
return; /* git-upload-pack and friends are OK */
751+
752+
if (!git_env_bool(still_in_use_var, 0)) {
753+
fprintf(stderr, _(still_in_use_msg), cmd, still_in_use_var);
754+
exit(1);
755+
}
756+
}

help.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ void get_version_info(struct strbuf *buf, int show_build_options);
4545
*/
4646
NORETURN void help_unknown_ref(const char *ref, const char *cmd, const char *error);
4747

48+
/* When the cmd_main() sees "git-foo", check if the user intended */
49+
void warn_on_dashed_git(const char *);
50+
4851
static inline void list_config_item(struct string_list *list,
4952
const char *prefix,
5053
const char *str)

0 commit comments

Comments
 (0)