From: Miklos Vajna <vmiklos@frugalware.org>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 7/7] builtin-merge: avoid non-strategy git-merge commands in error message
Date: Sat, 26 Jul 2008 17:25:02 +0200 [thread overview]
Message-ID: <20080726152502.GL32057@genesis.frugalware.org> (raw)
In-Reply-To: <alpine.DEB.1.00.0807261701520.26810@eeepc-johanness>
[-- Attachment #1: Type: text/plain, Size: 2890 bytes --]
On Sat, Jul 26, 2008 at 05:08:11PM +0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > + memset(¬_strategies, 0, sizeof(struct cmdnames));
> > + for (i = 0; i < main_cmds.cnt; i++) {
>
> Looking through all the discovered git commands? Cute... But does that
> not exclude the commands that are in PATH, starting with git-merge-, even
> if they are custom strategies?
main_cmds contains only commands in /usr/libexec/git-core, while I guess
custom strategies are elsewhere in PATH, which commands are in
other_cmds, not in main_cmds.
Sample output at me:
$ git merge -s theirss c2
HEAD is now at 1f5e3cc c1
Could not find merge strategy 'theirss'.
available strategies in '/usr/libexec/git-core/'
--------------------------------------------------
octopus ours recursive resolve subtree
strategies available from elsewhere on your $PATH
---------------------------------------------------
theirs
and I have git-merge-theirs in ~/bin (which is in PATH).
>
> > + int j, found = 0;
> > + for (j = 0; j < ARRAY_SIZE(all_strategy); j++)
> > + if (!strcmp(main_cmds.names[i]->name, all_strategy[j].name))
> > + found = 1;
> > + if (!found)
> > + add_cmdname(¬_strategies, main_cmds.names[i]->name, strlen(main_cmds.names[i]->name));
>
> Better have a local variable "name" instead of writing out
> "main_cmds.names[i]->name" all the time...
Fixed.
> Oh, and you assume that the names are NUL-terminated (which I assume is
> not the case in general, as the len member is the only thing that makes
> struct cmdnames different from struct string_list.
I think the purpose of it is different, but the argument is still valie.
That len member is to be able to have ->name contain "foo.exe" while
having len at 3, so that git help -a will avoid the .exe suffixes.
Changed.
(I do not want to resend a full series yet, but I pushed out an amended
patch to repo.or.cz in the 'merge-custom' branch.)
diff --git a/builtin-merge.c b/builtin-merge.c
index 4084e07..b0d1de5 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -93,11 +93,12 @@ static struct strategy *get_strategy(const char *name)
memset(¬_strategies, 0, sizeof(struct cmdnames));
for (i = 0; i < main_cmds.cnt; i++) {
int j, found = 0;
+ char *ent = main_cmds.names[i];
for (j = 0; j < ARRAY_SIZE(all_strategy); j++)
- if (!strcmp(main_cmds.names[i]->name, all_strategy[j].name))
+ if (!strncmp(ent->name, all_strategy[j].name, ent->len))
found = 1;
if (!found)
- add_cmdname(¬_strategies, main_cmds.names[i]->name, strlen(main_cmds.names[i]->name));
+ add_cmdname(¬_strategies, ent->name, ent->len);
}
fprintf(stderr, "Could not find merge strategy '%s'.\n\n", name);
list_commands("git-merge-", "strategies", ¬_strategies);
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2008-07-26 15:26 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-21 16:10 [PATCH] builtin-merge: give a proper error message for invalid strategies in config Miklos Vajna
2008-07-22 5:01 ` Junio C Hamano
2008-07-22 5:22 ` Junio C Hamano
2008-07-22 7:39 ` Miklos Vajna
2008-07-22 8:24 ` Junio C Hamano
2008-07-22 17:05 ` [PATCH] t7601: extend the 'merge picks up the best result' test Miklos Vajna
2008-07-26 11:54 ` Miklos Vajna
2008-07-26 11:54 ` [PATCH 2/7] builtin-help: change the current directory back in list_commands_in_dir() Miklos Vajna
2008-07-26 11:54 ` [PATCH 3/7] builtin-help: make list_commands() a bit more generic Miklos Vajna
2008-07-26 11:54 ` [PATCH 4/7] builtin-merge: allow using a custom strategy Miklos Vajna
2008-07-26 11:54 ` [PATCH 5/7] Add a new test for using a custom merge strategy Miklos Vajna
2008-07-26 11:54 ` [PATCH 6/7] builtin-help: make it possible to exclude some commands in list_commands() Miklos Vajna
2008-07-26 11:54 ` [PATCH 7/7] builtin-merge: avoid non-strategy git-merge commands in error message Miklos Vajna
2008-07-26 15:08 ` Johannes Schindelin
2008-07-26 15:25 ` Miklos Vajna [this message]
2008-07-26 15:27 ` Miklos Vajna
2008-07-26 15:38 ` Johannes Schindelin
2008-07-26 16:00 ` Miklos Vajna
2008-07-26 17:01 ` Johannes Schindelin
2008-07-26 17:12 ` [PATCH] " Miklos Vajna
2008-07-26 18:28 ` [PATCH 3/7] builtin-help: make list_commands() a bit more generic Jonathan Nieder
2008-07-26 21:40 ` Miklos Vajna
2008-07-26 14:58 ` [PATCH 2/7] builtin-help: change the current directory back in list_commands_in_dir() Johannes Schindelin
2008-07-27 20:02 ` Junio C Hamano
2008-07-27 20:21 ` Johannes Schindelin
2008-07-27 20:34 ` [PATCH] Avoid chdir() " Johannes Schindelin
2008-07-26 12:33 ` [PATCH] t7601: extend the 'merge picks up the best result' test Miklos Vajna
-- strict thread matches above, loose matches on Subject: below --
2008-07-26 11:54 [PATCH 0/7] Allow custom merge strategies Miklos Vajna
2008-07-26 11:54 ` [PATCH 1/7] Make is_git_command() usable outside builtin-help Miklos Vajna
2008-07-26 18:12 ` Jonathan Nieder
2008-07-28 1:18 ` Miklos Vajna
2008-07-28 1:21 ` [PATCH 0/6] Allow custom merge strategies, take 2 Miklos Vajna
2008-07-28 1:21 ` [PATCH 1/6] builtin-help: make is_git_command() usable outside builtin-help Miklos Vajna
2008-07-28 1:21 ` [PATCH 2/6] builtin-help: make list_commands() a bit more generic Miklos Vajna
2008-07-28 1:21 ` [PATCH 3/6] builtin-help: make it possible to exclude some commands in list_commands() Miklos Vajna
2008-07-28 1:21 ` [PATCH 4/6] builtin-merge: allow using a custom strategy Miklos Vajna
2008-07-28 1:21 ` [PATCH 5/6] builtin-merge: avoid non-strategy git-merge commands in error message Miklos Vajna
2008-07-28 1:21 ` [PATCH 6/6] Add a new test for using a custom merge strategy Miklos Vajna
2008-07-28 13:12 ` Johannes Schindelin
2008-07-28 23:39 ` Miklos Vajna
2008-07-28 23:54 ` Johannes Schindelin
2008-07-28 23:58 ` Miklos Vajna
2008-07-29 0:01 ` Miklos Vajna
2008-07-28 13:06 ` [PATCH 5/6] builtin-merge: avoid non-strategy git-merge commands in error message Johannes Schindelin
2008-07-28 23:48 ` [PATCH] builtin-merge: allow using a custom strategy Miklos Vajna
2008-07-28 23:59 ` Johannes Schindelin
2008-07-28 1:36 ` [PATCH 3/6] builtin-help: make it possible to exclude some commands in list_commands() Junio C Hamano
2008-07-28 2:43 ` Johannes Schindelin
2008-07-28 3:05 ` Junio C Hamano
2008-07-28 4:29 ` Junio C Hamano
2008-07-28 9:58 ` Johannes Schindelin
2008-07-28 23:24 ` Miklos Vajna
2008-07-29 15:24 ` [PATCH 0/5] Allow custom merge strategies, take 3 Miklos Vajna
2008-07-29 15:24 ` [PATCH 1/5] builtin-help: make is_git_command() usable outside builtin-help Miklos Vajna
2008-07-29 15:25 ` [PATCH 2/5] builtin-help: make list_commands() a bit more generic Miklos Vajna
2008-07-29 15:25 ` [PATCH 3/5] builtin-help: make it possible to exclude some commands in list_commands() Miklos Vajna
2008-07-29 15:25 ` [PATCH 4/5] builtin-merge: allow using a custom strategy Miklos Vajna
2008-07-29 15:25 ` [PATCH 5/5] Add a new test for using a custom merge strategy Miklos Vajna
2008-07-29 19:47 ` [PATCH 4/5] builtin-merge: allow using a custom strategy Junio C Hamano
2008-07-29 23:16 ` [PATCH 0/4] Allow custom merge strategies, take 4 Miklos Vajna
2008-07-29 23:16 ` [PATCH 1/4] builtin-help: make some internal functions available to other builtins Miklos Vajna
2008-07-29 23:16 ` [PATCH 2/4] builtin-merge: allow using a custom strategy Miklos Vajna
2008-07-29 23:17 ` [PATCH 3/4] Add a new test for using a custom merge strategy Miklos Vajna
2008-07-29 23:17 ` [PATCH 4/4] Add a second testcase for handling invalid strategies in git-merge Miklos Vajna
2008-07-29 23:42 ` Junio C Hamano
2008-07-30 17:27 ` Miklos Vajna
2008-07-29 23:43 ` [PATCH 3/4] Add a new test for using a custom merge strategy Junio C Hamano
2008-07-30 17:25 ` Miklos Vajna
2008-07-30 6:21 ` [PATCH 1/4] builtin-help: make some internal functions available to other builtins Junio C Hamano
2008-07-29 19:46 ` [PATCH 3/5] builtin-help: make it possible to exclude some commands in list_commands() Junio C Hamano
2008-07-29 21:25 ` Miklos Vajna
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080726152502.GL32057@genesis.frugalware.org \
--to=vmiklos@frugalware.org \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).