Re: [RFC PATCH v2] Allow aliases that include other aliases
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 5, 2018, 17:12 UTC
- Message-ID
- <xmqqlg8f50mq.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180905085427.4099-1-timschumi@gmx.de>
Tim Schumacher <timschumi@gmx.de> writes:
Show 21 quoted lines
> @@ -691,17 +693,34 @@ static int run_argv(int *argcp, const char ***argv)
> /* .. then try the external ones */
> execv_dashed_external(*argv);
>
> + /* Increase the array size and add the current
> + * command to it.
> + */
> + cmd_list_alloc += strlen(*argv[0]) + 1;
> + REALLOC_ARRAY(cmd_list, cmd_list_alloc);
> + cmd_list[done_alias] = *argv[0];
> +
> + /* Search the array for occurrences of that command,
> + * abort if something has been found.
> + */
> + for (int i = 0; i < done_alias; i++) {
> + if (!strcmp(cmd_list[i], *argv[0])) {
> + die("loop alias: %s is called twice",
> + cmd_list[done_alias]);
> + }
> + }
> +Wouldn't all of the above become three or four lines that is so clear that there is no need for any comment if you used string-list, perhaps?
> /* It could be an alias -- this works around the insanity > * of overriding "git log" with "git show" by having > * alias.log = show > */
/* * Style: our multi-line comment begins with and ends with * slash-asterisk and asterisk-slash on their own lines. */
Show 12 quoted lines
> - if (done_alias) > - break; > if (!handle_alias(argcp, argv)) > break; > - done_alias = 1; > + done_alias++; > } > > + free(cmd_list); > + > return done_alias; > }