[PATCH 2/2] alias: Move checking code into a seperate function

2018-10-21 Thread Tim Schumacher
We can save a few indentations (and possibly brain cells of people
that don't care about that code) by moving the code that checks for
a looping alias (and that prints the error message if one is found)
into a seperate function.

This restores a lot of readablility to the run_argv() function as
well, because it was only concerned with the high-level routing of
the command and alias logic before.
---
 git.c | 40 +++-
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/git.c b/git.c
index 0f77bce7d..b6fdd9708 100644
--- a/git.c
+++ b/git.c
@@ -710,11 +710,32 @@ static void add_cmd_history(struct strbuf *env, struct 
string_list *cmd_list,
setenv(COMMAND_HISTORY_ENVIRONMENT, env->buf, 1);
 }
 
+static void cmd_unique_or_die(struct string_list *cmd_list, const char *cmd)
+{
+   struct string_list_item *seen;
+
+   seen = unsorted_string_list_lookup(cmd_list, cmd);
+   if (!seen)
+   return;
+
+   int i;
+   struct strbuf sb = STRBUF_INIT;
+   for (i = 0; i < cmd_list->nr; i++) {
+   struct string_list_item *item = _list->items[i];
+   strbuf_addf(, "\n  %s", item->string);
+   if (item == seen)
+   strbuf_addstr(, " <==");
+   else if (i == cmd_list->nr - 1)
+   strbuf_addstr(, " ==>");
+   }
+   die(_("alias loop detected: expansion of '%s' does not terminate:%s"),
+   cmd_list->items[0].string, sb.buf);
+}
+
 static int run_argv(int *argcp, const char ***argv)
 {
int done_alias = 0;
struct string_list cmd_list = STRING_LIST_INIT_DUP;
-   struct string_list_item *seen;
struct strbuf env = STRBUF_INIT;
 
init_cmd_history(, _list);
@@ -739,22 +760,7 @@ static int run_argv(int *argcp, const char ***argv)
/* .. then try the external ones */
execv_dashed_external(*argv);
 
-   seen = unsorted_string_list_lookup(_list, *argv[0]);
-   if (seen) {
-   int i;
-   struct strbuf sb = STRBUF_INIT;
-   for (i = 0; i < cmd_list.nr; i++) {
-   struct string_list_item *item = 
_list.items[i];
-
-   strbuf_addf(, "\n  %s", item->string);
-   if (item == seen)
-   strbuf_addstr(, " <==");
-   else if (i == cmd_list.nr - 1)
-   strbuf_addstr(, " ==>");
-   }
-   die(_("alias loop detected: expansion of '%s' does"
- " not terminate:%s"), cmd_list.items[0].string, 
sb.buf);
-   }
+   cmd_unique_or_die(_list, *argv[0]);
 
add_cmd_history(, _list, *argv[0]);
 
-- 
2.19.1.450.ga4b8ab536



[PATCH 1/2] alias: Rework comment about processing aliases

2018-10-21 Thread Tim Schumacher
The old comment's message wasn't really clear and it was in a weird
location for it to talk about the alias handling process as a whole.

Rephrase and move it to the top of the while() loop to make the
message more clear.
---
 git.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/git.c b/git.c
index 6a81ed6fc..0f77bce7d 100644
--- a/git.c
+++ b/git.c
@@ -718,6 +718,11 @@ static int run_argv(int *argcp, const char ***argv)
struct strbuf env = STRBUF_INIT;
 
init_cmd_history(, _list);
+
+   /*
+* Check if argv[0] is a command before seeing if it is an
+* alias to avoid taking over existing commands
+*/
while (1) {
/*
 * If we tried alias and futzed with our environment,
@@ -753,11 +758,6 @@ static int run_argv(int *argcp, const char ***argv)
 
add_cmd_history(, _list, *argv[0]);
 
-   /*
-* It could be an alias -- this works around the insanity
-* of overriding "git log" with "git show" by having
-* alias.log = show
-*/
if (!handle_alias(argcp, argv))
break;
done_alias = 1;
-- 
2.19.1.450.ga4b8ab536



Re: What's cooking in git.git (Oct 2018, #01; Wed, 10)

2018-10-10 Thread Tim Schumacher

On 10.10.18 07:43, Junio C Hamano wrote:

* ts/alias-of-alias (2018-09-17) 3 commits
   (merged to 'next' on 2018-10-09 at ac19b4730b)
  + t0014: introduce an alias testing suite
  + alias: show the call history when an alias is looping
  + alias: add support for aliases of an alias

  An alias that expands to another alias has so far been forbidden,
  but now it is allowed to create such an alias.

  Will merge to 'master'.

Oh well, I still have the changed comment stored locally.
I guess that has to wait for another time.

Anyways, thanks for pulling this in.

PS: I hope that this E-Mail is formatted correctly. Thunderbird
received an update and now it doesn't show me plain text when
composing an E-Mail.


Re: [RFC PATCH v4 1/3] Add support for nested aliases

2018-09-21 Thread Tim Schumacher

On 17.09.18 17:37, Junio C Hamano wrote:

Tim Schumacher  writes:


On 08.09.18 15:28, Duy Nguyen wrote:

On Sat, Sep 8, 2018 at 12:44 AM Tim Schumacher  wrote:

+   /*
+* It could be an alias -- this works around the insanity
   * of overriding "git log" with "git show" by having
   * alias.log = show
   */


I think this comment block is about the next two lines you just
deleted. So delete it to instead of fixing style.


I think that comment is talking about the code that is handing the alias,
so it still would be valid.


"this" in "this works around" refers to the fact that we first check
the builtins and on-GIT_EXEC_PATH commands before trying an alias,
which is an effective way to forbid an alias from taking over
existing command names.  So it is not about a particular code but is
about how the two sections of code are laid out.

It probably will make it clear if we reworded and made it a comment
about the whole while() loop may make sense, i.e.

/*
 * Check if av[0] is a command before seeing if it is an
 * alias to avoid the insanity of overriding ...
 */
while (1) {
...



Imho, the "insanity" part makes the intention of that comment unclear, even if
it is located at the top of the while() loop. Giving an example is nice, but 
wouldn't
it be better to say something like the following?

/*
 * Check if av[0] is a command before seeing if it is an
 * alias to avoid taking over existing commands
 */


but that can be done after the dust settles as a clean-up, I would
think.



I'll keep the changed comment in my local repository for now and publish it 
together
with other changes in v6, but I assume there won't be much additional feedback.


[PATCH v5 3/3] t0014: Introduce an alias testing suite

2018-09-16 Thread Tim Schumacher
Introduce a testing suite that is dedicated to aliases.
For now, check only if nested aliases work and if looping
aliases are detected successfully.

The looping aliases check for mixed execution is there but
disabled, because it is blocking the test suite for a full
minute. As soon as there is a solution for loops using
external commands, it should be enabled.

Signed-off-by: Tim Schumacher 
---
Changes since v4:
 - Actually execute a command in the first two cases
 - Remove the "setup code"
 - Use i18ngrep to match the part of a message
 - Comment out the last test

 t/t0014-alias.sh | 40 
 1 file changed, 40 insertions(+)
 create mode 100755 t/t0014-alias.sh

diff --git a/t/t0014-alias.sh b/t/t0014-alias.sh
new file mode 100755
index 0..a070e645d
--- /dev/null
+++ b/t/t0014-alias.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+test_description='git command aliasing'
+
+. ./test-lib.sh
+
+test_expect_success 'nested aliases - internal execution' '
+   git config alias.nested-internal-1 nested-internal-2 &&
+   git config alias.nested-internal-2 status &&
+   git nested-internal-1 >output &&
+   test_i18ngrep "^On branch " output
+'
+
+test_expect_success 'nested aliases - mixed execution' '
+   git config alias.nested-external-1 nested-external-2 &&
+   git config alias.nested-external-2 "!git nested-external-3" &&
+   git config alias.nested-external-3 status &&
+   git nested-external-1 >output &&
+   test_i18ngrep "^On branch " output
+'
+
+test_expect_success 'looping aliases - internal execution' '
+   git config alias.loop-internal-1 loop-internal-2 &&
+   git config alias.loop-internal-2 loop-internal-3 &&
+   git config alias.loop-internal-3 loop-internal-2 &&
+   test_must_fail git loop-internal-1 2>output &&
+   test_i18ngrep "^fatal: alias loop detected: expansion of" output
+'
+
+# This test is disabled until external loops are fixed, because would block
+# the test suite for a full minute.
+#
+#test_expect_failure 'looping aliases - mixed execution' '
+#  git config alias.loop-mixed-1 loop-mixed-2 &&
+#  git config alias.loop-mixed-2 "!git loop-mixed-1" &&
+#  test_must_fail git loop-mixed-1 2>output &&
+#  test_i18ngrep "^fatal: alias loop detected: expansion of" output
+#'
+
+test_done
-- 
2.19.0.rc2.1.g4c98b8d69.dirty



[PATCH v5 2/3] Show the call history when an alias is looping

2018-09-16 Thread Tim Schumacher
Just printing the command that the user entered is not particularly
helpful when trying to find the alias that causes the loop.

Print the history of substituted commands to help the user find the
offending alias. Mark the entrypoint of the loop with "<==" and the
last command (which looped back to the entrypoint) with "==>".

Signed-off-by: Tim Schumacher 
---
No changes since v4.

 git.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/git.c b/git.c
index 15727c17f..a20eb4fa1 100644
--- a/git.c
+++ b/git.c
@@ -675,6 +675,7 @@ static int run_argv(int *argcp, const char ***argv)
 {
int done_alias = 0;
struct string_list cmd_list = STRING_LIST_INIT_NODUP;
+   struct string_list_item *seen;
 
while (1) {
/*
@@ -692,9 +693,21 @@ static int run_argv(int *argcp, const char ***argv)
/* .. then try the external ones */
execv_dashed_external(*argv);
 
-   if (unsorted_string_list_has_string(_list, *argv[0])) {
+   seen = unsorted_string_list_lookup(_list, *argv[0]);
+   if (seen) {
+   int i;
+   struct strbuf sb = STRBUF_INIT;
+   for (i = 0; i < cmd_list.nr; i++) {
+   struct string_list_item *item = 
_list.items[i];
+
+   strbuf_addf(, "\n  %s", item->string);
+   if (item == seen)
+   strbuf_addstr(, " <==");
+   else if (i == cmd_list.nr - 1)
+   strbuf_addstr(, " ==>");
+   }
die(_("alias loop detected: expansion of '%s' does"
- " not terminate"), cmd_list.items[0].string);
+ " not terminate:%s"), cmd_list.items[0].string, 
sb.buf);
}
 
string_list_append(_list, *argv[0]);
-- 
2.19.0.rc2.1.g4c98b8d69.dirty



[PATCH v5 1/3] Add support for nested aliases

2018-09-16 Thread Tim Schumacher
Aliases can only contain non-alias git commands and their
arguments, not other user-defined aliases. Resolving further
(nested) aliases is prevented by breaking the loop after the
first alias was processed. Git then fails with a command-not-found
error.

Allow resolving nested aliases by not breaking the loop in
run_argv() after the first alias was processed. Instead, continue
the loop until `handle_alias()` fails, which means that there are
no further aliases that can be processed. Prevent looping aliases
by storing substituted commands in `cmd_list` and checking if
a command has been substituted previously.

While we're at it, fix a styling issue just below the added code.

Signed-off-by: Tim Schumacher 
---
Changes since v3:
 - Print the command that the user entered instead of the command
   which caused the loop (and a nicer, more explanatory error message)
 - Use unsorted_string_list_has_string() instead of the sorted version
 - Fix a code style issue just below the modified code
 - done_alias is a simple boolean again (instead of a counter)

Changes since v4: None.

 git.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/git.c b/git.c
index c27c38738..15727c17f 100644
--- a/git.c
+++ b/git.c
@@ -674,6 +674,7 @@ static void execv_dashed_external(const char **argv)
 static int run_argv(int *argcp, const char ***argv)
 {
int done_alias = 0;
+   struct string_list cmd_list = STRING_LIST_INIT_NODUP;
 
while (1) {
/*
@@ -691,17 +692,25 @@ static int run_argv(int *argcp, const char ***argv)
/* .. then try the external ones */
execv_dashed_external(*argv);
 
-   /* It could be an alias -- this works around the insanity
+   if (unsorted_string_list_has_string(_list, *argv[0])) {
+   die(_("alias loop detected: expansion of '%s' does"
+ " not terminate"), cmd_list.items[0].string);
+   }
+
+   string_list_append(_list, *argv[0]);
+
+   /*
+* It could be an alias -- this works around the insanity
 * of overriding "git log" with "git show" by having
 * alias.log = show
 */
-   if (done_alias)
-   break;
if (!handle_alias(argcp, argv))
break;
done_alias = 1;
}
 
+   string_list_clear(_list, 0);
+
return done_alias;
 }
 
-- 
2.19.0.rc2.1.g4c98b8d69.dirty



Re: [RFC PATCH v4 1/3] Add support for nested aliases

2018-09-16 Thread Tim Schumacher

On 08.09.18 15:28, Duy Nguyen wrote:

On Sat, Sep 8, 2018 at 12:44 AM Tim Schumacher  wrote:

+   /*
+* It could be an alias -- this works around the insanity
  * of overriding "git log" with "git show" by having
  * alias.log = show
  */


I think this comment block is about the next two lines you just
deleted. So delete it to instead of fixing style.


I think that comment is talking about the code that is handing the alias,
so it still would be valid.
The check might have peen placed in between to keep it logically grouped.




-   if (done_alias)
-   break;
 if (!handle_alias(argcp, argv))
 break;
 done_alias = 1;
 }


Re: [RFC PATCH v4 3/3] t0014: Introduce alias testing suite

2018-09-14 Thread Tim Schumacher

On 08.09.18 01:38, Eric Sunshine wrote:

On Fri, Sep 7, 2018 at 6:44 PM Tim Schumacher  wrote:

Introduce a testing suite that is dedicated to aliases.
For now, check only if nested aliases work and if looping
aliases are detected successfully.

The looping aliases check for mixed execution is there but
expected to fail because there is no check in place yet.

Signed-off-by: Tim Schumacher 
---
Unfortunately I don't have a fix for the last one yet, so I
marked it as expect_failure. The problem is that the test suite
is waiting a full minute until it aborts the running command
(which I guess should not take that long, as it blocks the whole
test suite for that span of time).

Should I try to decrease the timeout or should I remove that
test completely until I manage to get external calls fixed?


Perhaps just comment out that test for now and add a comment above it
explaining why it's commented out.


That will probably be the easiest thing to do. I commented it out for
now, added a short information about that to the code itself and a longer
explanation to the commit message.




As a last thing, is there any better way to use single quotes
than to write '"'"'? It isn't that bad, but it is hard to read,
especially for bash newcomers.


You should backslash-escape the quotes ("foo \'bar\' baz"), however,
in this case, it would make sense to use regex's with 'grep' to check
that you got the expected error message rather than reproducing the
message literally here in the script.


Backslash-escaping didn't work, that resulted in some parsing error.
I'm using i18ngrep now to search for the part of a message, which
eliminates the need for quotes completely.



More below.


diff --git a/t/t0014-alias.sh b/t/t0014-alias.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='git command aliasing'
+
+. ./test-lib.sh
+
+test_expect_success 'setup environment' '
+   git init
+'


"git init" is invoked automatically by the test framework, so no need
for this test. You can drop it.


+test_expect_success 'nested aliases - internal execution' '
+   git config alias.nested-internal-1 nested-internal-2 &&
+   git config alias.nested-internal-2 status
+'


This isn't actually testing anything, is it? It's setting up the
aliases but never actually invoking them. I would have expected the
next line to actually run a command ("git nested-internal-1") and the
line after that to check that you got the expected output (whatever
"git status" would emit). Output from "git status" isn't necessarily
the easiest to test, though, so perhaps pick a different Git command
for testing (something for which the result can be very easily checked
-- maybe "git rm" or such).


Whoops, I didn't know when that went missing. I added it into a new version
of this patch.

Also, I decided to keep `git status`, because it seemed to be the only
command which doesn't need any files to produce some checkable output.
Checking the "On branch" message should be enough to confirm that the
command works as intended.




+test_expect_success 'nested aliases - mixed execution' '
+   git config alias.nested-external-1 "!git nested-external-2" &&
+   git config alias.nested-external-2 status
+'


Same observation.


+test_expect_success 'looping aliases - internal execution' '
+   git config alias.loop-internal-1 loop-internal-2 &&
+   git config alias.loop-internal-2 loop-internal-3 &&
+   git config alias.loop-internal-3 loop-internal-2 &&
+   test_must_fail git loop-internal-1 2>output &&
+   grep -q "fatal: alias loop detected: expansion of '"'"'loop-internal-1'"'"' does not 
terminate" output &&


Don't bother using -q with 'grep'. Output is hidden already by the
test framework in normal mode, and not hidden when running in verbose
mode. And, the output of 'grep' might be helpful when debugging the
test if something goes wrong.

As noted above, you can use regex to match the expected error rather
than exactly duplicating the text of the message.

Finally, use 'test_i18ngrep' instead of 'grep' in order to play nice
with localization.


+   rm output


Tests don't normally bother cleaning up their output files like this
since such output can be helpful when debugging the test if something
goes wrong. (You'd want to use test_when_finished to cleanup anyhow,
but you don't need it in this case.)


I incorporated both of these suggestions.




+'




This is the first multi-patch series that I submitted, so I'm unsure if I
should send the updated patch only or if I should send the complete series
again as v5. Any pointers to what the correct procedure for this case is would
be appreciated.

Thanks for looking at this.

Tim


[RFC PATCH v4 3/3] t0014: Introduce alias testing suite

2018-09-07 Thread Tim Schumacher
Introduce a testing suite that is dedicated to aliases.
For now, check only if nested aliases work and if looping
aliases are detected successfully.

The looping aliases check for mixed execution is there but
expected to fail because there is no check in place yet.

Signed-off-by: Tim Schumacher 
---

Those are the tests that I've come up with. It consists of tests
for nested aliases and looping aliases, both with internal calls
and external calls.

Unfortunately I don't have a fix for the last one yet, so I
marked it as expect_failure. The problem is that the test suite
is waiting a full minute until it aborts the running command
(which I guess should not take that long, as it blocks the whole
test suite for that span of time).

Should I try to decrease the timeout or should I remove that
test completely until I manage to get external calls fixed?

As a last thing, is there any better way to use single quotes
than to write '"'"'? It isn't that bad, but it is hard to read,
especially for bash newcomers.

 t/t0014-alias.sh | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100755 t/t0014-alias.sh

diff --git a/t/t0014-alias.sh b/t/t0014-alias.sh
new file mode 100755
index 0..6c1e34694
--- /dev/null
+++ b/t/t0014-alias.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='git command aliasing'
+
+. ./test-lib.sh
+
+test_expect_success 'setup environment' '
+   git init
+'
+
+test_expect_success 'nested aliases - internal execution' '
+   git config alias.nested-internal-1 nested-internal-2 &&
+   git config alias.nested-internal-2 status
+'
+
+test_expect_success 'nested aliases - mixed execution' '
+   git config alias.nested-external-1 "!git nested-external-2" &&
+   git config alias.nested-external-2 status
+'
+
+test_expect_success 'looping aliases - internal execution' '
+   git config alias.loop-internal-1 loop-internal-2 &&
+   git config alias.loop-internal-2 loop-internal-3 &&
+   git config alias.loop-internal-3 loop-internal-2 &&
+   test_must_fail git loop-internal-1 2>output &&
+   grep -q "fatal: alias loop detected: expansion of 
'"'"'loop-internal-1'"'"' does not terminate" output &&
+   rm output
+'
+
+test_expect_failure 'looping aliases - mixed execution' '
+   git config alias.loop-mixed-1 loop-mixed-2 &&
+   git config alias.loop-mixed-2 "!git loop-mixed-1" &&
+   test_must_fail git loop-mixed-1 2>output &&
+   grep -q "fatal: alias loop detected: expansion of 
'"'"'loop-mixed-1'"'"' does not terminate" output &&
+   rm output
+'
+
+test_done
-- 
2.19.0.rc2.1.g4c98b8d69.dirty



[RFC PATCH v4 2/3] Show the call history when an alias is looping

2018-09-07 Thread Tim Schumacher
Just printing the command that the user entered is not particularly
helpful when trying to find the alias that causes the loop.

Print the history of substituted commands to help the user find the
offending alias. Mark the entrypoint of the loop with "<==" and the
last command (which looped back to the entrypoint) with "==>".

Signed-off-by: Tim Schumacher 
---

I now went with Peff's suggested code and I added in an arrow that points
away from the last command (which caused the loop). A "full" arrow (i.e.
starts at the last command, goes upwards and ends at the entrypoint) would
be more obvious/better, but adding much more code just for having a
vertical line wasn't worth it for me.

 git.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/git.c b/git.c
index 15727c17f..a20eb4fa1 100644
--- a/git.c
+++ b/git.c
@@ -675,6 +675,7 @@ static int run_argv(int *argcp, const char ***argv)
 {
int done_alias = 0;
struct string_list cmd_list = STRING_LIST_INIT_NODUP;
+   struct string_list_item *seen;
 
while (1) {
/*
@@ -692,9 +693,21 @@ static int run_argv(int *argcp, const char ***argv)
/* .. then try the external ones */
execv_dashed_external(*argv);
 
-   if (unsorted_string_list_has_string(_list, *argv[0])) {
+   seen = unsorted_string_list_lookup(_list, *argv[0]);
+   if (seen) {
+   int i;
+   struct strbuf sb = STRBUF_INIT;
+   for (i = 0; i < cmd_list.nr; i++) {
+   struct string_list_item *item = 
_list.items[i];
+
+   strbuf_addf(, "\n  %s", item->string);
+   if (item == seen)
+   strbuf_addstr(, " <==");
+   else if (i == cmd_list.nr - 1)
+   strbuf_addstr(, " ==>");
+   }
die(_("alias loop detected: expansion of '%s' does"
- " not terminate"), cmd_list.items[0].string);
+ " not terminate:%s"), cmd_list.items[0].string, 
sb.buf);
}
 
string_list_append(_list, *argv[0]);
-- 
2.19.0.rc2.1.g4c98b8d69.dirty



[RFC PATCH v4 1/3] Add support for nested aliases

2018-09-07 Thread Tim Schumacher
Aliases can only contain non-alias git commands and their
arguments, not other user-defined aliases. Resolving further
(nested) aliases is prevented by breaking the loop after the
first alias was processed. Git then fails with a command-not-found
error.

Allow resolving nested aliases by not breaking the loop in
run_argv() after the first alias was processed. Instead, continue
the loop until `handle_alias()` fails, which means that there are
no further aliases that can be processed. Prevent looping aliases
by storing substituted commands in `cmd_list` and checking if
a command has been substituted previously.

While we're at it, fix a styling issue just below the added code.

Signed-off-by: Tim Schumacher 
---
Changes since v3:
 - Print the command that the user entered instead of the command
   which caused the loop (and a nicer, more explanatory error message)
 - Use unsorted_string_list_has_string() instead of the sorted version
 - Fix a code style issue just below the modified code
 - done_alias is a simple boolean again (instead of a counter)

 git.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/git.c b/git.c
index c27c38738..15727c17f 100644
--- a/git.c
+++ b/git.c
@@ -674,6 +674,7 @@ static void execv_dashed_external(const char **argv)
 static int run_argv(int *argcp, const char ***argv)
 {
int done_alias = 0;
+   struct string_list cmd_list = STRING_LIST_INIT_NODUP;
 
while (1) {
/*
@@ -691,17 +692,25 @@ static int run_argv(int *argcp, const char ***argv)
/* .. then try the external ones */
execv_dashed_external(*argv);
 
-   /* It could be an alias -- this works around the insanity
+   if (unsorted_string_list_has_string(_list, *argv[0])) {
+   die(_("alias loop detected: expansion of '%s' does"
+ " not terminate"), cmd_list.items[0].string);
+   }
+
+   string_list_append(_list, *argv[0]);
+
+   /*
+* It could be an alias -- this works around the insanity
 * of overriding "git log" with "git show" by having
 * alias.log = show
 */
-   if (done_alias)
-   break;
if (!handle_alias(argcp, argv))
break;
done_alias = 1;
}
 
+   string_list_clear(_list, 0);
+
return done_alias;
 }
 
-- 
2.19.0.rc2.1.g4c98b8d69.dirty



Re: [PATCH v3] Allow aliases that include other aliases

2018-09-06 Thread Tim Schumacher

On 06.09.18 20:40, Junio C Hamano wrote:

Jeff King  writes:


On Thu, Sep 06, 2018 at 12:16:58PM +0200, Tim Schumacher wrote:


@@ -691,17 +692,23 @@ static int run_argv(int *argcp, const char ***argv)
/* .. then try the external ones */
execv_dashed_external(*argv);
  
-		/* It could be an alias -- this works around the insanity

+   if (string_list_has_string(_list, *argv[0]))
+   die(_("loop alias: %s is called twice"), *argv[0]);


I pointed this out in my response to Ævar, but I want to make sure it
gets seen. This call assumes the list is sorted, but...


+   string_list_append(_list, *argv[0]);


This will create an unsorted list. You'd have to use
string_list_insert() here for a sorted list, or
unsorted_string_list_has_string() in the earlier call.


Correct.

Also, normal users who have never seen this loop that implements
alias expansion would not have a clue when they see "called twice".

I actually think the caller should also pass cmd to run_argv() and
then we should use it (and not argv[]) in this die() message.


Could we just save the first element of the original argv for that
purpose? Or alternatively, use the first stored element in the
command list?


When
the original command was foo that is aliased to bar, which in turn
is aliased to baz, which in turn is aliased to bar, especially that
"git foo" invocation was in a random script written six weeks ago by
the user, it would be a lot more helpful to see

 "alias loop detected: expansion of 'git foo' does not terminate"

than

 "loop alias: bar is called twice".

given that 'bar' is not something the user called, or written in the
script she wrote six weeks ago.


Indeed, printing the command that the user called is a better message
than the command that is the entry-point of the loop. I'll change it
in v4.




It's unfortunate that string_list makes this so easy to get wrong.


+
+   /*
+* It could be an alias -- this works around the insanity
 * of overriding "git log" with "git show" by having
 * alias.log = show
 */
-   if (done_alias)
-   break;
if (!handle_alias(argcp, argv))
break;
-   done_alias = 1;
+   done_alias++;


I don't think anybody cares about done_alias being an accurate count.
Should we just leave this as-is?


Good point.  The only caller treats it as a bool (i.e. "should the
failure be reported as failure to expand an alias cmd which resulted
in (updated) argv[0] that is not a git command?").



As the string-list has its own counter, I guess the done_alias variable
can be reverted to a simple 0/1 value.


Re: [PATCH v3] Allow aliases that include other aliases

2018-09-06 Thread Tim Schumacher

On 06.09.18 16:57, Jeff King wrote:

On Thu, Sep 06, 2018 at 04:01:39PM +0200, Ævar Arnfjörð Bjarmason wrote:


If we don't have some test for these sort of aliasing loops that fails
now, we really should add that in a 1/2 and fix it in this patch in 2/2.


Yes, I'd agree that this is worth adding a test (especially if the
output routines get more complex).


I'll try to come up with a few tests (or one at this point, as we only have
a solution for internal aliases so far) and put them as 1/2. However, I don't 
know
what file I should put those tests into. t0001-init and t1300-config both seem
to test aliases, but I'm unsure if the new tests should go into one of those
files or a completely new one that is dedicated to aliases.




That makes sense from an implementaion perspective, i.e. we lookup "bar"
twice. But let's do better. If I have aliase like:

 a = b
 b = c
 c = d
 d = e
 e = c

It should be telling me that my "e" expansion looped back to the "c = d"
expansion. Here's a patch to implement that, feel free to either squash
it in with my Signed-Off-By, or tacked onto a v4 version of this,
whichever you think makes sense:


I don't have a strong opinion on whether this is worth it, but I think
your implementation could be a little simpler:


diff --git a/git.c b/git.c
index 64f5fbd572..38f1033e52 100644
--- a/git.c
+++ b/git.c
@@ -692,8 +692,64 @@ static int run_argv(int *argcp, const char ***argv)
/* .. then try the external ones */
execv_dashed_external(*argv);

-   if (string_list_has_string(_list, *argv[0]))
-   die(_("loop alias: %s is called twice"), *argv[0]);
+   if (string_list_has_string(_list, *argv[0])) {
+   struct strbuf sb = STRBUF_INIT;
+   int i, seen_at_idx = -1;
+
+   /*
+* Find the re-entry point for the alias
+* loop. TODO: There really should be a
+* "return the index of the first matching"
+* helper in string-list.c.
+*/
+   for (i = 0; i < cmd_list.nr; i++) {
+   if (!strcmp(*argv[0], cmd_list.items[i].string))
+   seen_at_idx = i;
+   }
+   assert(seen_at_idx != -1);


The string-list code doesn't generally deal in indices. You can use
string_list_find_insert_index(), but its return value is a little funky
for the existing case. You can also just do:

   struct string_list_item *seen;
   ...
   seen = string_list_lookup(_list, *argv[0]);
   if (seen) {
/* we have a loop */
int idx = seen - cmd_list.items;

That's a little intimate with the string-list implementation as an array
of string_list, but it's already pretty standard to walk over and
dereference that list (including in your patch). But also see below.

Side note: there's actually a bigger problem with the original patch:
the string list is unsorted (because it uses string_list_append(), and
which is why your linear walk works here). But string_list_has_string()
assumes it is sorted.  So I think we'd actually want to use
unsorted_string_list_has_string() or unsorted_string_list_lookup().


I'll update v4 to use use unsorted_string_list_has_string().



+   for (i = 1; i < cmd_list.nr; i++) {
+   if (i - 1 == seen_at_idx)
+   /*
+* TRANSLATORS: This is a the
+* re-enttry point in the list
+* printed out by the "alias
+* loop" message below.
+*/
+   strbuf_addf(, _("%d. %s = %s <== The 
re-entry point in the loop\n"),
+   i,
+   cmd_list.items[i - 
1].string,
+   cmd_list.items[i].string);


This is always going to show the right-hand of the equals as the
left-hand on the next line. Would it be simpler to just show the list?
Likewise, the last item in the list is always going to be "where the
loop started". Do we need to say that?

E.g., something like:

   seen = unsorted_string_list_lookup(_list, *argv[0]);
   if (seen) {
   for (i = 0; i < cmd_list.nr; i++) {
struct string_list *item = cmd_list.items[i];

strbuf_addf(, "  %s", item->string);
if (item == seen)
strbuf_add(, " <==");
strbuf_addch(, '\n');
  }
  /* We never added this to the list, but we were about to */
  strbuf_addch("  %s\n", seen->string);
  die(...);
   

[PATCH v3] Allow aliases that include other aliases

2018-09-06 Thread Tim Schumacher
Aliases can only contain non-alias git commands and their
arguments, not other user-defined aliases. Resolving further
(nested) aliases is prevented by breaking the loop after the
first alias was processed. Git then fails with a command-not-found
error.

Allow resolving nested aliases by not breaking the loop in
run_argv() after the first alias was processed. Instead, continue
incrementing `done_alias` until `handle_alias()` fails, which means that
there are no further aliases that can be processed. Prevent looping
aliases by storing substituted commands in `cmd_list` and checking if
a command has been substituted previously.

While we're at it, fix a styling issue just below the added code.
---
 git.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/git.c b/git.c
index c27c38738..64f5fbd57 100644
--- a/git.c
+++ b/git.c
@@ -674,6 +674,7 @@ static void execv_dashed_external(const char **argv)
 static int run_argv(int *argcp, const char ***argv)
 {
int done_alias = 0;
+   struct string_list cmd_list = STRING_LIST_INIT_NODUP;
 
while (1) {
/*
@@ -691,17 +692,23 @@ static int run_argv(int *argcp, const char ***argv)
/* .. then try the external ones */
execv_dashed_external(*argv);
 
-   /* It could be an alias -- this works around the insanity
+   if (string_list_has_string(_list, *argv[0]))
+   die(_("loop alias: %s is called twice"), *argv[0]);
+
+   string_list_append(_list, *argv[0]);
+
+   /*
+* It could be an alias -- this works around the insanity
 * of overriding "git log" with "git show" by having
 * alias.log = show
 */
-   if (done_alias)
-   break;
if (!handle_alias(argcp, argv))
break;
-   done_alias = 1;
+   done_alias++;
}
 
+   string_list_clear(_list, 0);
+
return done_alias;
 }
 
-- 
2.19.0.rc1.2.g8008c49c4.dirty



Re: [RFC PATCH v2] Allow aliases that include other aliases

2018-09-05 Thread Tim Schumacher

On 05.09.18 19:34, Jeff King wrote:

On Wed, Sep 05, 2018 at 10:54:27AM +0200, Tim Schumacher wrote:


Aliases can only contain non-alias git commands and their
arguments, not other user-defined aliases. Resolving further
(nested) aliases is prevented by breaking the loop after the
first alias was processed. Git then fails with a command-not-found
error.

Allow resolving nested aliases by not breaking the loop in
run_argv() after the first alias was processed. Instead, continue
incrementing `done_alias` until `handle_alias()` fails, which means that
there are no further aliases that can be processed. Prevent looping
aliases by storing substituted commands in `cmd_list` and checking if
a command has been substituted previously.
---

This is what I've come up with to prevent looping aliases. I'm not too
happy with the number of indentations needed, but this seemed to be the
easiest way to search an array for a value.


I think this approach is OK, though I wonder if we'd also be fine with
just:

   if (done_alias++ > 100)
die("woah, is your alias looping?");

The point is just to prevent a runaway infinite loop, and this does that
while keeping the cost very low for the common case (not that one string
insertion is probably breaking the bank).


I'd opt to use the list-approach instead of aborting when the
counter reaches 100 (or any other value), because it aborts
at the earliest known looping point. I didn't run any tests
comparing both solutions, but I assume the list would perform
faster than the hard-limit, even if it requires slightly more
memory and lines of code.

I hope that I can put the string-list struct to some use,
so that the solution using lists becomes an equally good
solution code-wise.



It could also extend to ! aliases if we wanted (i.e., my '!git foo'
example from earlier), but you'd have to carry the counter through the
environment between processes.


That is a question about "shooting oneself in the foot" again,
but I think trying to prevent that would require more changes
than I can make, and it is definitely out-of-scope for this
patch.



-Peff


Thanks for reviewing,

Tim


Re: [RFC PATCH v2] Allow aliases that include other aliases

2018-09-05 Thread Tim Schumacher

On 05.09.18 19:12, Junio C Hamano wrote:

Tim Schumacher  writes:


@@ -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?


Whoops, I didn't know that string-list existed. I'll try reworking the
code to use that. Concerning the comments: I planned to remove them
anyways since the code should be simple enough to be understood without
them already.




/* 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.
 */


I wasn't sure if I should have changed that (because I didn't introduce
that comment), but I can fix it in v3.




-   if (done_alias)
-   break;
if (!handle_alias(argcp, argv))
break;
-   done_alias = 1;
+   done_alias++;
}
  
+	free(cmd_list);

+
return done_alias;
  }




Re: [RFC PATCH v2] Allow aliases that include other aliases

2018-09-05 Thread Tim Schumacher

On 05.09.18 17:48, Duy Nguyen wrote:

On Wed, Sep 5, 2018 at 10:56 AM Tim Schumacher  wrote:


Aliases can only contain non-alias git commands and their
arguments, not other user-defined aliases. Resolving further
(nested) aliases is prevented by breaking the loop after the
first alias was processed. Git then fails with a command-not-found
error.

Allow resolving nested aliases by not breaking the loop in
run_argv() after the first alias was processed. Instead, continue
incrementing `done_alias` until `handle_alias()` fails, which means that
there are no further aliases that can be processed. Prevent looping
aliases by storing substituted commands in `cmd_list` and checking if
a command has been substituted previously.
---

This is what I've come up with to prevent looping aliases. I'm not too
happy with the number of indentations needed, but this seemed to be the
easiest way to search an array for a value.


You can just make all the new code a separate function, which reduces
indentation.


That would solve the issue, but I'm not sure if it is worth introducing
a new function exclusively for that. I didn't find anything about a
maximum indentation level in the code guidelines and since the new
parts stay within the width limit (and is imo still readable), would it
be ok to keep it like that?



There's another thing I wanted (but probably a wrong thing to want):
if I define alias 'foo' in ~/.gitconfig, then I'd like to modify it in
some project by redefining it as alias.foo='foo --something' in
$GIT_DIR/config. This results in alias loop, but the loop is broken by
looking up 'foo' from a higher level config file instead.

This is not easy to do, and as I mentioned, I'm not even sure if it's
a sane thing to do.


The alias system is using the default functions of the config system,
I assume that adding such a functionality is not possible, at least not
without breaking compatibility.




+   /* Increase the array size and add the current
+* command to it.
+*/


I think this is pretty clear from the code, you don't need to add a
comment to explain how the next few lines work. Same comment for the
next comment block.


I'll remove them in v3.




+   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",


Please wrap the string in _() so that it can be translated in
different languages.


I'll do that in v3 as well.




+   cmd_list[done_alias]);
+   }
+   }
+


Thanks for reviewing!

Tim


[RFC PATCH v2] Allow aliases that include other aliases

2018-09-05 Thread Tim Schumacher
Aliases can only contain non-alias git commands and their
arguments, not other user-defined aliases. Resolving further
(nested) aliases is prevented by breaking the loop after the
first alias was processed. Git then fails with a command-not-found
error.

Allow resolving nested aliases by not breaking the loop in
run_argv() after the first alias was processed. Instead, continue
incrementing `done_alias` until `handle_alias()` fails, which means that
there are no further aliases that can be processed. Prevent looping
aliases by storing substituted commands in `cmd_list` and checking if
a command has been substituted previously.
---

This is what I've come up with to prevent looping aliases. I'm not too
happy with the number of indentations needed, but this seemed to be the
easiest way to search an array for a value.

---
 git.c | 25 ++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/git.c b/git.c
index c27c38738..fd90a3341 100644
--- a/git.c
+++ b/git.c
@@ -674,6 +674,8 @@ static void execv_dashed_external(const char **argv)
 static int run_argv(int *argcp, const char ***argv)
 {
int done_alias = 0;
+   const char **cmd_list = NULL;
+   int cmd_list_alloc = 0;
 
while (1) {
/*
@@ -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]);
+   }
+   }
+
/* It could be an alias -- this works around the insanity
 * of overriding "git log" with "git show" by having
 * alias.log = show
 */
-   if (done_alias)
-   break;
if (!handle_alias(argcp, argv))
break;
-   done_alias = 1;
+   done_alias++;
}
 
+   free(cmd_list);
+
return done_alias;
 }
 
-- 
2.19.0.rc1.2.g8f4faccc1



[RFC PATCH] Allow aliases that include other aliases

2018-09-04 Thread Tim Schumacher
Aliases can only contain non-alias git commands and arguments,
but not other user-defined aliases. Resolving nested aliases
is prevented by breaking the loop after the first alias was
processed, git then fails with a command-not-found error.

Allow resolving nested aliases by not breaking the loop in
run_argv() after the first alias was processed. Instead, continue
incrementing done_alias until handle_alias() fails, which means
that there are no further aliases that can be processed.

---

I submitted this as RFC because I'm not sure whether disallowing
nested aliases was an intentional design choice. The done_alias
check implies that disallowing is intended, but the direct
recursion check for aliases that call themselves opposes that.

Furthermore, including this patch allows creating a looping state,
since the recursion check only checks if an alias is directly calling
itself.
One solution would be to break the loop as soon as done_alias reaches
a certain value, but that requires setting an arbitrary point of "too
many recursions".
A list of already resolved aliases and breaking the loop as soon as
an alias is resolved twice would probably do the trick, but
implementing that is well beyond the point of what I'm capable of
doing.

---
 git.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/git.c b/git.c
index c27c38738..9d3cf5797 100644
--- a/git.c
+++ b/git.c
@@ -695,11 +695,9 @@ static int run_argv(int *argcp, const char ***argv)
 * of overriding "git log" with "git show" by having
 * alias.log = show
 */
-   if (done_alias)
-   break;
if (!handle_alias(argcp, argv))
break;
-   done_alias = 1;
+   done_alias++;
}
 
return done_alias;
-- 
2.19.0.rc1.2.g7460ee143



Re: [PATCH v3] doc: Don't echo sed command for manpage-base-url.xsl

2018-08-29 Thread Tim Schumacher

On 29.08.18 18:55, Jonathan Nieder wrote:

Tim Schumacher wrote:


Subject: doc: Don't echo sed command for manpage-base-url.xsl


Cribbing from my review of v2: a description like

Documentation/Makefile: make manpage-base-url.xsl generation quieter

would make it more obvious what this does when viewed in "git log
--oneline".


imho, the "Documentation/Makefile" is a bit too long (about 1/3 of the
first line). Would it be advisable to keep the previous prefix of "doc"
(which would shorten down the line from 68 characters down to 49) and
to use only the second part of your proposed first line? Depending on
the response I would address this in v4 of this patch.




Previously, the sed command for generating manpage-base-url.xsl
was printed to the console when being run.

Make the console output for this rule similiar to all the
other rules by printing a short status message instead of
the whole command.

Signed-off-by: Tim Schumacher 
---
  Documentation/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)


Oh!  Ignore my reply to v2; looks like you anticipated what I was
going to suggest already.  For next time, if you include a note about
what changed between versions after the --- delimiter, that can help
save some time.



The change to QUIET_GEN was proposed by Junio, but that E-Mail
wasn't CC'ed to the mailing list, probably due to him typing
the response on a phone.

I originally included a note about the change as well, but I
forgot to copy it over to the new patch after I generated a
second version of v3.


With or without the suggested commit message tweak,

Reviewed-by: Jonathan Nieder 

Thank you.



Thanks for the review!


[PATCH v3] doc: Don't echo sed command for manpage-base-url.xsl

2018-08-29 Thread Tim Schumacher
Previously, the sed command for generating manpage-base-url.xsl
was printed to the console when being run.

Make the console output for this rule similiar to all the
other rules by printing a short status message instead of
the whole command.

Signed-off-by: Tim Schumacher 
---
 Documentation/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index a42dcfc74..95f6a321f 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -344,7 +344,7 @@ $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
mv $@+ $@
 
 manpage-base-url.xsl: manpage-base-url.xsl.in
-   sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
+   $(QUIET_GEN)sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
 
 %.1 %.5 %.7 : %.xml manpage-base-url.xsl
$(QUIET_XMLTO)$(RM) $@ && \
-- 
2.19.0.rc1.1.g093671f86



[PATCH v2] doc: Don't echo sed command for manpage-base-url.xsl

2018-08-29 Thread Tim Schumacher
Previously, the sed command for generating manpage-base-url.xsl
was printed to the console when being run.

Make the console output for this rule similiar to all the
other rules by printing a short status message instead of
the whole command.

Signed-off-by: Tim Schumacher 
---

To Junio C Hamano:
The rule does now print "SED manpage-base-url.xsl"
to the console, which is similiar to other QUIET_$TOOL
rules.

To Eric Sunshine:
I reworded the commit message to focus more on _why_
the patch is relevant.

---

 Documentation/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index a42dcfc74..cbf33c5a7 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -225,6 +225,7 @@ ifndef V
QUIET_XSLTPROC  = @echo '   ' XSLTPROC $@;
QUIET_GEN   = @echo '   ' GEN $@;
QUIET_LINT  = @echo '   ' LINT $@;
+   QUIET_SED   = @echo '   ' SED $@;
QUIET_STDERR= 2> /dev/null
QUIET_SUBDIR0   = +@subdir=
QUIET_SUBDIR1   = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
@@ -344,7 +345,7 @@ $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
mv $@+ $@
 
 manpage-base-url.xsl: manpage-base-url.xsl.in
-   sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
+   $(QUIET_SED)sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
 
 %.1 %.5 %.7 : %.xml manpage-base-url.xsl
$(QUIET_XMLTO)$(RM) $@ && \
-- 
2.19.0.rc1.1.g093671f86



[PATCH] doc: Don't echo sed command for manpage-base-url.xsl

2018-08-28 Thread Tim Schumacher
Previously, the sed command for generating manpage-base-url.xsl
was printed to the console when being run.

For the purpose of silencing it, define a $(QUIET) variable which
contains an '@' if verbose mode isn't enabled and which is empty
otherwise. This just silences the command invocation without doing
anything else.

Signed-off-by: Tim Schumacher 
---
 Documentation/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index a42dcfc74..45454e9b5 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -217,6 +217,7 @@ endif
 
 ifneq ($(findstring $(MAKEFLAGS),s),s)
 ifndef V
+   QUIET   = @
QUIET_ASCIIDOC  = @echo '   ' ASCIIDOC $@;
QUIET_XMLTO = @echo '   ' XMLTO $@;
QUIET_DB2TEXI   = @echo '   ' DB2TEXI $@;
@@ -344,7 +345,7 @@ $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
mv $@+ $@
 
 manpage-base-url.xsl: manpage-base-url.xsl.in
-   sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
+   $(QUIET)sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
 
 %.1 %.5 %.7 : %.xml manpage-base-url.xsl
$(QUIET_XMLTO)$(RM) $@ && \
-- 
2.19.0.rc0