Probably missed since git-merge builtin effort:
__git_merge_strategies ()
{
if [ -n "$__git_merge_strategylist" ]; then
echo "$__git_merge_strategylist"
return
fi
sed -n "/^all_strategies='/{
s/^all_strategies='//
s/'//
p
q
}" "$(git --exec-path)/git-merge"
}
It takes several seconds to finish that function.
--
Duy
@@ -37,6 +38,9 @@ include::merge-options.txt[] least one <remote>. Specifying more than one <remote> obviously means you are trying an Octopus.+--show-strategies::+ Show all available strategies. For internal use only.+ include::merge-strategies.txt[]
@@ -802,6 +802,13 @@ int cmd_merge(int argc, const char **argv, const char *prefix)constchar*best_strategy=NULL,*wt_strategy=NULL;structcommit_list**remotes=&remoteheads;+/* needed for git bash completion and similar tools */+if(argc==2&&!strcmp(argv[1],"--show-strategies")){+for(i=0;i<ARRAY_SIZE(all_strategy);i++)+printf("%s\n",all_strategy[i].name);+return0;+}+setup_work_tree();if(unmerged_cache())die("You are in the middle of a conflicted merge.");
@@ -802,6 +802,13 @@ int cmd_merge(int argc, const char **argv, const char *prefix)constchar*best_strategy=NULL,*wt_strategy=NULL;structcommit_list**remotes=&remoteheads;+/* needed for git bash completion and similar tools */+if(argc==2&&!strcmp(argv[1],"--show-strategies")){+for(i=0;i<ARRAY_SIZE(all_strategy);i++)+printf("%s\n",all_strategy[i].name);+return0;+}+setup_work_tree();if(unmerged_cache())die("You are in the middle of a conflicted merge.");
From: Johannes Sixt <hidden> Date: 2016-06-15 22:45:11
Nguyen Thai Ngoc Duy schrieb:
+--show-strategies::
+ Show all available strategies. For internal use only.
+
IMO, you don't need to declare this option as internal; offering it for
the public is fine...
+ /* needed for git bash completion and similar tools */
... which would make this comment slightly odd.
+ if (argc == 2 && !strcmp(argv[1], "--show-strategies")) {
+ for (i = 0; i < ARRAY_SIZE(all_strategy); i++)
+ printf("%s\n", all_strategy[i].name);
+ return 0;
Improved error checking, but quick and dirty:
+ if (!strcmp(argv[1], "--show-strategies")) {
+ for (i = 0; i < ARRAY_SIZE(all_strategy); i++)
+ printf("%s\n", all_strategy[i].name);
+ return argc == 2 ? 0 :
+ error("--show-strategies does not take "
+ "any arguments");
From: Johannes Sixt <hidden> Date: 2016-06-15 22:45:11
Johannes Sixt schrieb:
Nguyen Thai Ngoc Duy schrieb:
quoted
+ if (argc == 2 && !strcmp(argv[1], "--show-strategies")) {
+ for (i = 0; i < ARRAY_SIZE(all_strategy); i++)
+ printf("%s\n", all_strategy[i].name);
+ return 0;
Improved error checking, but quick and dirty:
+ if (!strcmp(argv[1], "--show-strategies")) {
Oops, not really improved. This still needs to check for argc >= 2.
+ for (i = 0; i < ARRAY_SIZE(all_strategy); i++)
+ printf("%s\n", all_strategy[i].name);
+ return argc == 2 ? 0 :
+ error("--show-strategies does not take "
+ "any arguments");
> + Show all available strategies. For internal use only.
> +
IMO, you don't need to declare this option as internal; offering it for
the public is fine...
On second thought, I don't think the patch's worth it. The code in
git-completion.bash is a hack and I replace it with another the hack.
It won't work for custom merges and git-completion.bash will need to
be synced manually anyway, so maybe this patch will do better: