On Thu, Nov 22, 2007 at 01:02:52AM +0100, Wincent Colaiuta wrote:
-int interactive_add(const char *path)
+int interactive_add(const char **argv, int argc)
{
- const char *argv[3] = { "add--interactive", path, NULL };
-
- return run_command_v_opt(argv, RUN_GIT_CMD);
+ int status;
+ const char **args = xmalloc(sizeof(const char *) * (argc + 1));
+ args[0] = "add--interactive";
+ memcpy((void *)args + sizeof(const char *), argv, sizeof(const char *) * argc);
The source for the memcpy (argv) is sometimes NULL. The standard forbids
this, even when the size field is 0. I have no idea if any reasonable
implementations actually care.
But...
+ if (argc > 0)
+ exit(interactive_add(argv, argc));
else
- exit(interactive_add(NULL));
+ exit(interactive_add(NULL, 0));
There really is no reason to pass NULL at all (since the argc limits us
anyway), so we can just get rid of the conditional and simplify to:
exit(interactive_add(argv, argc));
for both cases.
-Peff