Skip to content

Commit 89cc5e5

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 36a7463 + eb23dcd commit 89cc5e5

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
@@ -872,6 +872,8 @@ int cmd_main(int argc, const char **argv)
872872
* that one cannot handle it.
873873
*/
874874
if (skip_prefix(cmd, "git-", &cmd)) {
875+
warn_on_dashed_git(argv[0]);
876+
875877
argv[0] = cmd;
876878
handle_builtin(argc, argv);
877879
die(_("cannot handle %s as a builtin"), cmd);

help.c

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

help.h

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

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

0 commit comments

Comments
 (0)