1 #define USE_THE_REPOSITORY_VARIABLE
3 #include "git-compat-util.h"
7 #include "run-command.h"
8 #include "levenshtein.h"
11 #include "command-list.h"
12 #include "string-list.h"
16 #include "parse-options.h"
18 #include "fsmonitor-ipc.h"
19 #include "repository.h"
22 #include "git-curl-compat.h" /* For LIBCURL_VERSION only */
25 struct category_description
{
29 static uint32_t common_mask
=
30 CAT_init
| CAT_worktree
| CAT_info
|
31 CAT_history
| CAT_remote
;
32 static struct category_description common_categories
[] = {
33 { CAT_init
, N_("start a working area (see also: git help tutorial)") },
34 { CAT_worktree
, N_("work on the current change (see also: git help everyday)") },
35 { CAT_info
, N_("examine the history and state (see also: git help revisions)") },
36 { CAT_history
, N_("grow, mark and tweak your common history") },
37 { CAT_remote
, N_("collaborate (see also: git help workflows)") },
40 static struct category_description main_categories
[] = {
41 { CAT_mainporcelain
, N_("Main Porcelain Commands") },
42 { CAT_ancillarymanipulators
, N_("Ancillary Commands / Manipulators") },
43 { CAT_ancillaryinterrogators
, N_("Ancillary Commands / Interrogators") },
44 { CAT_foreignscminterface
, N_("Interacting with Others") },
45 { CAT_plumbingmanipulators
, N_("Low-level Commands / Manipulators") },
46 { CAT_plumbinginterrogators
, N_("Low-level Commands / Interrogators") },
47 { CAT_synchingrepositories
, N_("Low-level Commands / Syncing Repositories") },
48 { CAT_purehelpers
, N_("Low-level Commands / Internal Helpers") },
49 { CAT_userinterfaces
, N_("User-facing repository, command and file interfaces") },
50 { CAT_developerinterfaces
, N_("Developer-facing file formats, protocols and other interfaces") },
54 static const char *drop_prefix(const char *name
, uint32_t category
)
61 case CAT_userinterfaces
:
62 case CAT_developerinterfaces
:
69 if (skip_prefix(name
, prefix
, &new_name
))
75 static void extract_cmds(struct cmdname_help
**p_cmds
, uint32_t mask
)
78 struct cmdname_help
*cmds
;
80 if (ARRAY_SIZE(command_list
) == 0)
81 BUG("empty command_list[] is a sign of broken generate-cmdlist.sh");
83 ALLOC_ARRAY(cmds
, ARRAY_SIZE(command_list
) + 1);
85 for (i
= 0; i
< ARRAY_SIZE(command_list
); i
++) {
86 const struct cmdname_help
*cmd
= command_list
+ i
;
88 if (!(cmd
->category
& mask
))
92 cmds
[nr
].name
= drop_prefix(cmd
->name
, cmd
->category
);
100 static void print_command_list(const struct cmdname_help
*cmds
,
101 uint32_t mask
, int longest
)
105 for (i
= 0; cmds
[i
].name
; i
++) {
106 if (cmds
[i
].category
& mask
) {
107 size_t len
= strlen(cmds
[i
].name
);
108 printf(" %s ", cmds
[i
].name
);
110 mput_char(' ', longest
- len
);
111 puts(_(cmds
[i
].help
));
116 static int cmd_name_cmp(const void *elem1
, const void *elem2
)
118 const struct cmdname_help
*e1
= elem1
;
119 const struct cmdname_help
*e2
= elem2
;
121 return strcmp(e1
->name
, e2
->name
);
124 static void print_cmd_by_category(const struct category_description
*catdesc
,
127 struct cmdname_help
*cmds
;
132 for (i
= 0; catdesc
[i
].desc
; i
++)
133 mask
|= catdesc
[i
].category
;
135 extract_cmds(&cmds
, mask
);
137 for (i
= 0; cmds
[i
].name
; i
++, nr
++) {
138 if (longest
< strlen(cmds
[i
].name
))
139 longest
= strlen(cmds
[i
].name
);
141 QSORT(cmds
, nr
, cmd_name_cmp
);
143 for (i
= 0; catdesc
[i
].desc
; i
++) {
144 uint32_t mask
= catdesc
[i
].category
;
145 const char *desc
= catdesc
[i
].desc
;
150 print_command_list(cmds
, mask
, longest
);
154 *longest_p
= longest
;
157 void add_cmdname(struct cmdnames
*cmds
, const char *name
, int len
)
160 FLEX_ALLOC_MEM(ent
, name
, name
, len
);
163 ALLOC_GROW(cmds
->names
, cmds
->cnt
+ 1, cmds
->alloc
);
164 cmds
->names
[cmds
->cnt
++] = ent
;
167 void cmdnames_release(struct cmdnames
*cmds
)
170 for (i
= 0; i
< cmds
->cnt
; ++i
)
171 free(cmds
->names
[i
]);
177 static int cmdname_compare(const void *a_
, const void *b_
)
179 struct cmdname
*a
= *(struct cmdname
**)a_
;
180 struct cmdname
*b
= *(struct cmdname
**)b_
;
181 return strcmp(a
->name
, b
->name
);
184 static void uniq(struct cmdnames
*cmds
)
191 for (i
= j
= 1; i
< cmds
->cnt
; i
++) {
192 if (!strcmp(cmds
->names
[i
]->name
, cmds
->names
[j
-1]->name
))
193 free(cmds
->names
[i
]);
195 cmds
->names
[j
++] = cmds
->names
[i
];
201 void exclude_cmds(struct cmdnames
*cmds
, struct cmdnames
*excludes
)
207 while (ci
< cmds
->cnt
&& ei
< excludes
->cnt
) {
208 cmp
= strcmp(cmds
->names
[ci
]->name
, excludes
->names
[ei
]->name
);
210 cmds
->names
[cj
++] = cmds
->names
[ci
++];
213 free(cmds
->names
[ci
++]);
218 while (ci
< cmds
->cnt
)
219 cmds
->names
[cj
++] = cmds
->names
[ci
++];
224 static void pretty_print_cmdnames(struct cmdnames
*cmds
, unsigned int colopts
)
226 struct string_list list
= STRING_LIST_INIT_NODUP
;
227 struct column_options copts
;
230 for (i
= 0; i
< cmds
->cnt
; i
++)
231 string_list_append(&list
, cmds
->names
[i
]->name
);
233 * always enable column display, we only consult column.*
234 * about layout strategy and stuff
236 colopts
= (colopts
& ~COL_ENABLE_MASK
) | COL_ENABLED
;
237 memset(&copts
, 0, sizeof(copts
));
240 print_columns(&list
, colopts
, &copts
);
241 string_list_clear(&list
, 0);
244 static void list_commands_in_dir(struct cmdnames
*cmds
,
248 DIR *dir
= opendir(path
);
250 struct strbuf buf
= STRBUF_INIT
;
258 strbuf_addf(&buf
, "%s/", path
);
261 while ((de
= readdir(dir
)) != NULL
) {
265 if (!skip_prefix(de
->d_name
, prefix
, &ent
))
268 strbuf_setlen(&buf
, len
);
269 strbuf_addstr(&buf
, de
->d_name
);
270 if (!is_executable(buf
.buf
))
273 entlen
= strlen(ent
);
274 strip_suffix(ent
, ".exe", &entlen
);
276 add_cmdname(cmds
, ent
, entlen
);
279 strbuf_release(&buf
);
282 void load_command_list(const char *prefix
,
283 struct cmdnames
*main_cmds
,
284 struct cmdnames
*other_cmds
)
286 const char *env_path
= getenv("PATH");
287 const char *exec_path
= git_exec_path();
289 load_builtin_commands(prefix
, main_cmds
);
292 list_commands_in_dir(main_cmds
, exec_path
, prefix
);
293 QSORT(main_cmds
->names
, main_cmds
->cnt
, cmdname_compare
);
298 char *paths
, *path
, *colon
;
299 path
= paths
= xstrdup(env_path
);
301 if ((colon
= strchr(path
, PATH_SEP
)))
303 if (!exec_path
|| strcmp(path
, exec_path
))
304 list_commands_in_dir(other_cmds
, path
, prefix
);
312 QSORT(other_cmds
->names
, other_cmds
->cnt
, cmdname_compare
);
315 exclude_cmds(other_cmds
, main_cmds
);
318 static int get_colopts(const char *var
, const char *value
,
319 const struct config_context
*ctx UNUSED
, void *data
)
321 unsigned int *colopts
= data
;
323 if (starts_with(var
, "column."))
324 return git_column_config(var
, value
, "help", colopts
);
329 void list_commands(struct cmdnames
*main_cmds
, struct cmdnames
*other_cmds
)
331 unsigned int colopts
= 0;
332 git_config(get_colopts
, &colopts
);
334 if (main_cmds
->cnt
) {
335 const char *exec_path
= git_exec_path();
336 printf_ln(_("available git commands in '%s'"), exec_path
);
338 pretty_print_cmdnames(main_cmds
, colopts
);
342 if (other_cmds
->cnt
) {
343 puts(_("git commands available from elsewhere on your $PATH"));
345 pretty_print_cmdnames(other_cmds
, colopts
);
350 void list_common_cmds_help(void)
352 puts(_("These are common Git commands used in various situations:"));
354 print_cmd_by_category(common_categories
, NULL
);
357 void list_all_main_cmds(struct string_list
*list
)
359 struct cmdnames main_cmds
, other_cmds
;
362 memset(&main_cmds
, 0, sizeof(main_cmds
));
363 memset(&other_cmds
, 0, sizeof(other_cmds
));
364 load_command_list("git-", &main_cmds
, &other_cmds
);
366 for (i
= 0; i
< main_cmds
.cnt
; i
++)
367 string_list_append(list
, main_cmds
.names
[i
]->name
);
369 cmdnames_release(&main_cmds
);
370 cmdnames_release(&other_cmds
);
373 void list_all_other_cmds(struct string_list
*list
)
375 struct cmdnames main_cmds
, other_cmds
;
378 memset(&main_cmds
, 0, sizeof(main_cmds
));
379 memset(&other_cmds
, 0, sizeof(other_cmds
));
380 load_command_list("git-", &main_cmds
, &other_cmds
);
382 for (i
= 0; i
< other_cmds
.cnt
; i
++)
383 string_list_append(list
, other_cmds
.names
[i
]->name
);
385 cmdnames_release(&main_cmds
);
386 cmdnames_release(&other_cmds
);
389 void list_cmds_by_category(struct string_list
*list
,
392 int i
, n
= ARRAY_SIZE(command_list
);
395 for (i
= 0; category_names
[i
]; i
++) {
396 if (!strcmp(cat
, category_names
[i
])) {
402 die(_("unsupported command listing type '%s'"), cat
);
404 for (i
= 0; i
< n
; i
++) {
405 struct cmdname_help
*cmd
= command_list
+ i
;
407 if (!(cmd
->category
& cat_id
))
409 string_list_append(list
, drop_prefix(cmd
->name
, cmd
->category
));
413 void list_cmds_by_config(struct string_list
*list
)
415 const char *cmd_list
;
417 if (git_config_get_string_tmp("completion.commands", &cmd_list
))
420 string_list_sort(list
);
421 string_list_remove_duplicates(list
, 0);
424 struct strbuf sb
= STRBUF_INIT
;
425 const char *p
= strchrnul(cmd_list
, ' ');
427 strbuf_add(&sb
, cmd_list
, p
- cmd_list
);
428 if (sb
.buf
[0] == '-')
429 string_list_remove(list
, sb
.buf
+ 1, 0);
431 string_list_insert(list
, sb
.buf
);
439 void list_guides_help(void)
441 struct category_description catdesc
[] = {
442 { CAT_guide
, N_("The Git concept guides are:") },
445 print_cmd_by_category(catdesc
, NULL
);
449 void list_user_interfaces_help(void)
451 struct category_description catdesc
[] = {
452 { CAT_userinterfaces
, N_("User-facing repository, command and file interfaces:") },
455 print_cmd_by_category(catdesc
, NULL
);
459 void list_developer_interfaces_help(void)
461 struct category_description catdesc
[] = {
462 { CAT_developerinterfaces
, N_("File formats, protocols and other developer interfaces:") },
465 print_cmd_by_category(catdesc
, NULL
);
469 static int get_alias(const char *var
, const char *value
,
470 const struct config_context
*ctx UNUSED
, void *data
)
472 struct string_list
*list
= data
;
474 if (skip_prefix(var
, "alias.", &var
)) {
476 return config_error_nonbool(var
);
477 string_list_append(list
, var
)->util
= xstrdup(value
);
483 static void list_all_cmds_help_external_commands(void)
485 struct string_list others
= STRING_LIST_INIT_DUP
;
488 list_all_other_cmds(&others
);
490 printf("\n%s\n", _("External commands"));
491 for (i
= 0; i
< others
.nr
; i
++)
492 printf(" %s\n", others
.items
[i
].string
);
493 string_list_clear(&others
, 0);
496 static void list_all_cmds_help_aliases(int longest
)
498 struct string_list alias_list
= STRING_LIST_INIT_DUP
;
499 struct cmdname_help
*aliases
;
502 git_config(get_alias
, &alias_list
);
503 string_list_sort(&alias_list
);
505 for (i
= 0; i
< alias_list
.nr
; i
++) {
506 size_t len
= strlen(alias_list
.items
[i
].string
);
512 printf("\n%s\n", _("Command aliases"));
513 ALLOC_ARRAY(aliases
, alias_list
.nr
+ 1);
514 for (i
= 0; i
< alias_list
.nr
; i
++) {
515 aliases
[i
].name
= alias_list
.items
[i
].string
;
516 aliases
[i
].help
= alias_list
.items
[i
].util
;
517 aliases
[i
].category
= 1;
519 aliases
[alias_list
.nr
].name
= NULL
;
520 print_command_list(aliases
, 1, longest
);
523 string_list_clear(&alias_list
, 1);
526 void list_all_cmds_help(int show_external_commands
, int show_aliases
)
530 puts(_("See 'git help <command>' to read about a specific subcommand"));
532 print_cmd_by_category(main_categories
, &longest
);
534 if (show_external_commands
)
535 list_all_cmds_help_external_commands();
537 list_all_cmds_help_aliases(longest
);
540 int is_in_cmdlist(struct cmdnames
*c
, const char *s
)
543 for (i
= 0; i
< c
->cnt
; i
++)
544 if (!strcmp(s
, c
->names
[i
]->name
))
549 static int autocorrect
;
550 static struct cmdnames aliases
;
552 #define AUTOCORRECT_PROMPT (-3)
553 #define AUTOCORRECT_NEVER (-2)
554 #define AUTOCORRECT_IMMEDIATELY (-1)
556 static int git_unknown_cmd_config(const char *var
, const char *value
,
557 const struct config_context
*ctx
,
562 if (!strcmp(var
, "help.autocorrect")) {
564 return config_error_nonbool(var
);
565 if (!strcmp(value
, "never")) {
566 autocorrect
= AUTOCORRECT_NEVER
;
567 } else if (!strcmp(value
, "immediate")) {
568 autocorrect
= AUTOCORRECT_IMMEDIATELY
;
569 } else if (!strcmp(value
, "prompt")) {
570 autocorrect
= AUTOCORRECT_PROMPT
;
572 int v
= git_config_int(var
, value
, ctx
->kvi
);
573 autocorrect
= (v
< 0)
574 ? AUTOCORRECT_IMMEDIATELY
: v
;
577 /* Also use aliases for command lookup */
578 if (skip_prefix(var
, "alias.", &p
))
579 add_cmdname(&aliases
, p
, strlen(p
));
584 static int levenshtein_compare(const void *p1
, const void *p2
)
586 const struct cmdname
*const *c1
= p1
, *const *c2
= p2
;
587 const char *s1
= (*c1
)->name
, *s2
= (*c2
)->name
;
590 return l1
!= l2
? l1
- l2
: strcmp(s1
, s2
);
593 static void add_cmd_list(struct cmdnames
*cmds
, struct cmdnames
*old
)
596 ALLOC_GROW(cmds
->names
, cmds
->cnt
+ old
->cnt
, cmds
->alloc
);
598 for (i
= 0; i
< old
->cnt
; i
++)
599 cmds
->names
[cmds
->cnt
++] = old
->names
[i
];
600 FREE_AND_NULL(old
->names
);
604 /* An empirically derived magic number */
605 #define SIMILARITY_FLOOR 7
606 #define SIMILAR_ENOUGH(x) ((x) < SIMILARITY_FLOOR)
608 static const char bad_interpreter_advice
[] =
609 N_("'%s' appears to be a git command, but we were not\n"
610 "able to execute it. Maybe git-%s is broken?");
612 const char *help_unknown_cmd(const char *cmd
)
614 int i
, n
, best_similarity
= 0;
615 struct cmdnames main_cmds
, other_cmds
;
616 struct cmdname_help
*common_cmds
;
618 memset(&main_cmds
, 0, sizeof(main_cmds
));
619 memset(&other_cmds
, 0, sizeof(other_cmds
));
620 memset(&aliases
, 0, sizeof(aliases
));
622 read_early_config(the_repository
, git_unknown_cmd_config
, NULL
);
625 * Disable autocorrection prompt in a non-interactive session
627 if ((autocorrect
== AUTOCORRECT_PROMPT
) && (!isatty(0) || !isatty(2)))
628 autocorrect
= AUTOCORRECT_NEVER
;
630 if (autocorrect
== AUTOCORRECT_NEVER
) {
631 fprintf_ln(stderr
, _("git: '%s' is not a git command. See 'git --help'."), cmd
);
635 load_command_list("git-", &main_cmds
, &other_cmds
);
637 add_cmd_list(&main_cmds
, &aliases
);
638 add_cmd_list(&main_cmds
, &other_cmds
);
639 QSORT(main_cmds
.names
, main_cmds
.cnt
, cmdname_compare
);
642 extract_cmds(&common_cmds
, common_mask
);
644 /* This abuses cmdname->len for levenshtein distance */
645 for (i
= 0, n
= 0; i
< main_cmds
.cnt
; i
++) {
646 int cmp
= 0; /* avoid compiler stupidity */
647 const char *candidate
= main_cmds
.names
[i
]->name
;
650 * An exact match means we have the command, but
651 * for some reason exec'ing it gave us ENOENT; probably
652 * it's a bad interpreter in the #! line.
654 if (!strcmp(candidate
, cmd
))
655 die(_(bad_interpreter_advice
), cmd
, cmd
);
657 /* Does the candidate appear in common_cmds list? */
658 while (common_cmds
[n
].name
&&
659 (cmp
= strcmp(common_cmds
[n
].name
, candidate
)) < 0)
661 if (common_cmds
[n
].name
&& !cmp
) {
662 /* Yes, this is one of the common commands */
663 n
++; /* use the entry from common_cmds[] */
664 if (starts_with(candidate
, cmd
)) {
665 /* Give prefix match a very good score */
666 main_cmds
.names
[i
]->len
= 0;
671 main_cmds
.names
[i
]->len
=
672 levenshtein(cmd
, candidate
, 0, 2, 1, 3) + 1;
674 FREE_AND_NULL(common_cmds
);
676 QSORT(main_cmds
.names
, main_cmds
.cnt
, levenshtein_compare
);
679 die(_("Uh oh. Your system reports no Git commands at all."));
681 /* skip and count prefix matches */
682 for (n
= 0; n
< main_cmds
.cnt
&& !main_cmds
.names
[n
]->len
; n
++)
683 ; /* still counting */
685 if (main_cmds
.cnt
<= n
) {
686 /* prefix matches with everything? that is too ambiguous */
687 best_similarity
= SIMILARITY_FLOOR
+ 1;
689 /* count all the most similar ones */
690 for (best_similarity
= main_cmds
.names
[n
++]->len
;
691 (n
< main_cmds
.cnt
&&
692 best_similarity
== main_cmds
.names
[n
]->len
);
694 ; /* still counting */
696 if (autocorrect
&& n
== 1 && SIMILAR_ENOUGH(best_similarity
)) {
697 const char *assumed
= main_cmds
.names
[0]->name
;
698 main_cmds
.names
[0] = NULL
;
699 cmdnames_release(&main_cmds
);
701 _("WARNING: You called a Git command named '%s', "
702 "which does not exist."),
704 if (autocorrect
== AUTOCORRECT_IMMEDIATELY
)
706 _("Continuing under the assumption that "
709 else if (autocorrect
== AUTOCORRECT_PROMPT
) {
711 struct strbuf msg
= STRBUF_INIT
;
712 strbuf_addf(&msg
, _("Run '%s' instead [y/N]? "), assumed
);
713 answer
= git_prompt(msg
.buf
, PROMPT_ECHO
);
714 strbuf_release(&msg
);
715 if (!(starts_with(answer
, "y") ||
716 starts_with(answer
, "Y")))
720 _("Continuing in %0.1f seconds, "
721 "assuming that you meant '%s'."),
722 (float)autocorrect
/10.0, assumed
);
723 sleep_millisec(autocorrect
* 100);
728 fprintf_ln(stderr
, _("git: '%s' is not a git command. See 'git --help'."), cmd
);
730 if (SIMILAR_ENOUGH(best_similarity
)) {
732 Q_("\nThe most similar command is",
733 "\nThe most similar commands are",
736 for (i
= 0; i
< n
; i
++)
737 fprintf(stderr
, "\t%s\n", main_cmds
.names
[i
]->name
);
743 void get_version_info(struct strbuf
*buf
, int show_build_options
)
746 * The format of this string should be kept stable for compatibility
747 * with external projects that rely on the output of "git version".
749 * Always show the version, even if other options are given.
751 strbuf_addf(buf
, "git version %s\n", git_version_string
);
753 if (show_build_options
) {
754 strbuf_addf(buf
, "cpu: %s\n", GIT_HOST_CPU
);
755 if (git_built_from_commit_string
[0])
756 strbuf_addf(buf
, "built from commit: %s\n",
757 git_built_from_commit_string
);
759 strbuf_addstr(buf
, "no commit associated with this build\n");
760 strbuf_addf(buf
, "sizeof-long: %d\n", (int)sizeof(long));
761 strbuf_addf(buf
, "sizeof-size_t: %d\n", (int)sizeof(size_t));
762 strbuf_addf(buf
, "shell-path: %s\n", SHELL_PATH
);
763 /* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */
765 if (fsmonitor_ipc__is_supported())
766 strbuf_addstr(buf
, "feature: fsmonitor--daemon\n");
767 #if defined LIBCURL_VERSION
768 strbuf_addf(buf
, "libcurl: %s\n", LIBCURL_VERSION
);
770 #if defined OPENSSL_VERSION_TEXT
771 strbuf_addf(buf
, "OpenSSL: %s\n", OPENSSL_VERSION_TEXT
);
773 #if defined ZLIB_VERSION
774 strbuf_addf(buf
, "zlib: %s\n", ZLIB_VERSION
);
779 int cmd_version(int argc
, const char **argv
, const char *prefix
, struct repository
*repository UNUSED
)
781 struct strbuf buf
= STRBUF_INIT
;
782 int build_options
= 0;
783 const char * const usage
[] = {
784 N_("git version [--build-options]"),
787 struct option options
[] = {
788 OPT_BOOL(0, "build-options", &build_options
,
789 "also print build options"),
793 argc
= parse_options(argc
, argv
, prefix
, options
, usage
, 0);
795 get_version_info(&buf
, build_options
);
796 printf("%s", buf
.buf
);
798 strbuf_release(&buf
);
803 struct similar_ref_cb
{
804 const char *base_ref
;
805 struct string_list
*similar_refs
;
808 static int append_similar_ref(const char *refname
, const char *referent UNUSED
,
809 const struct object_id
*oid UNUSED
,
810 int flags UNUSED
, void *cb_data
)
812 struct similar_ref_cb
*cb
= (struct similar_ref_cb
*)(cb_data
);
813 char *branch
= strrchr(refname
, '/') + 1;
815 /* A remote branch of the same name is deemed similar */
816 if (starts_with(refname
, "refs/remotes/") &&
817 !strcmp(branch
, cb
->base_ref
))
818 string_list_append_nodup(cb
->similar_refs
,
819 refs_shorten_unambiguous_ref(get_main_ref_store(the_repository
), refname
, 1));
823 static struct string_list
guess_refs(const char *ref
)
825 struct similar_ref_cb ref_cb
;
826 struct string_list similar_refs
= STRING_LIST_INIT_DUP
;
828 ref_cb
.base_ref
= ref
;
829 ref_cb
.similar_refs
= &similar_refs
;
830 refs_for_each_ref(get_main_ref_store(the_repository
),
831 append_similar_ref
, &ref_cb
);
835 NORETURN
void help_unknown_ref(const char *ref
, const char *cmd
,
839 struct string_list suggested_refs
= guess_refs(ref
);
841 fprintf_ln(stderr
, _("%s: %s - %s"), cmd
, ref
, error
);
843 if (suggested_refs
.nr
> 0) {
845 Q_("\nDid you mean this?",
846 "\nDid you mean one of these?",
848 for (i
= 0; i
< suggested_refs
.nr
; i
++)
849 fprintf(stderr
, "\t%s\n", suggested_refs
.items
[i
].string
);
852 string_list_clear(&suggested_refs
, 0);