# [PATCH 0/2] document alias accepting non-command first word

8 messages from 2019-05-31 to 2019-06-06. Participants: Denton Liu, Johannes Schindelin.
Thread: https://gitlist.dev/t/51215

## Denton Liu, 2019-05-31 20:23

Subject: [PATCH 0/2] document alias accepting non-command first word
Message-ID: <cover.1559333840.git.liu.denton@gmail.com>
URL: https://gitlist.dev/e/cover.1559333840.git.liu.denton%40gmail.com

```
When I first saw Johannes' email here[1], I was surprised that an alias
where the first-word is a command-line option to be passed into `git`
was permitted. I was only used to aliases where the first word is a
command.

Document this behaviour so that users will be able to discover that this
is a feature.

[1]: https://public-inbox.org/git/nycvar.QRO.7.76.6.1905281235280.44@tvgsbejvaqbjf.bet/



Denton Liu (2):
  config/alias.txt: change " and ' to `
  config/alias.txt: document alias accepting non-command first word

 Documentation/config/alias.txt | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

-- 
2.22.0.rc1.169.g49223abbf8


```

## Denton Liu, 2019-05-31 20:23

Subject: [PATCH 1/2] config/alias.txt: change " and ' to `
Message-ID: <6f3c18424e7199716d6128aad1dc0da9388d3cb0.1559333840.git.liu.denton@gmail.com>
URL: https://gitlist.dev/e/6f3c18424e7199716d6128aad1dc0da9388d3cb0.1559333840.git.liu.denton%40gmail.com
In-Reply-To: <cover.1559333840.git.liu.denton@gmail.com>

```
Before, the documentation would mix " and ' for code and config
snippets. Change these instances to ` so that they are marked up in
monospace.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 Documentation/config/alias.txt | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Documentation/config/alias.txt b/Documentation/config/alias.txt
index 0b14178314..5425449a50 100644
--- a/Documentation/config/alias.txt
+++ b/Documentation/config/alias.txt
@@ -1,7 +1,7 @@
 alias.*::
 	Command aliases for the linkgit:git[1] command wrapper - e.g.
-	after defining "alias.last = cat-file commit HEAD", the invocation
-	"git last" is equivalent to "git cat-file commit HEAD". To avoid
+	after defining `alias.last = cat-file commit HEAD`, the invocation
+	`git last` is equivalent to `git cat-file commit HEAD`. To avoid
 	confusion and troubles with script usage, aliases that
 	hide existing Git commands are ignored. Arguments are split by
 	spaces, the usual shell quoting and escaping is supported.
@@ -9,10 +9,10 @@ alias.*::
 +
 If the alias expansion is prefixed with an exclamation point,
 it will be treated as a shell command.  For example, defining
-"alias.new = !gitk --all --not ORIG_HEAD", the invocation
-"git new" is equivalent to running the shell command
-"gitk --all --not ORIG_HEAD".  Note that shell commands will be
+`alias.new = !gitk --all --not ORIG_HEAD`, the invocation
+`git new` is equivalent to running the shell command
+`gitk --all --not ORIG_HEAD`.  Note that shell commands will be
 executed from the top-level directory of a repository, which may
 not necessarily be the current directory.
-`GIT_PREFIX` is set as returned by running 'git rev-parse --show-prefix'
+`GIT_PREFIX` is set as returned by running `git rev-parse --show-prefix`
 from the original current directory. See linkgit:git-rev-parse[1].
-- 
2.22.0.rc1.169.g49223abbf8


```

## Denton Liu, 2019-05-31 20:23

Subject: [PATCH 2/2] config/alias.txt: document alias accepting non-command first word
Message-ID: <13d9ddd3541e3815078c4853c6f7c25cddd89126.1559333840.git.liu.denton@gmail.com>
URL: https://gitlist.dev/e/13d9ddd3541e3815078c4853c6f7c25cddd89126.1559333840.git.liu.denton%40gmail.com
In-Reply-To: <cover.1559333840.git.liu.denton@gmail.com>

```
One can see that an alias that begins with a non-command first word,
such as `loud-rebase = -c commit.verbose=true rebase`, is permitted.
However, this isn't immediately obvious to users as alias instances
typically begin with a command.

Document the fact that an alias can begin with a non-command first word
so that users will be able to discover that this is a feature.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 Documentation/config/alias.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/config/alias.txt b/Documentation/config/alias.txt
index 5425449a50..f241f03ebe 100644
--- a/Documentation/config/alias.txt
+++ b/Documentation/config/alias.txt
@@ -7,6 +7,14 @@ alias.*::
 	spaces, the usual shell quoting and escaping is supported.
 	A quote pair or a backslash can be used to quote them.
 +
+Note that the first word of an alias does not necessarily have to be a
+command. It can be a command-line option that will be passed into the
+invocation of `git`. In particular, this is useful when used with `-c`
+to pass in one-time configurations. For example,
+`loud-rebase = -c commit.verbose=true rebase` can be defined such that
+running `git loud-merge` would be equivalent to
+`git -c commit.verbose=true rebase`.
++
 If the alias expansion is prefixed with an exclamation point,
 it will be treated as a shell command.  For example, defining
 `alias.new = !gitk --all --not ORIG_HEAD`, the invocation
-- 
2.22.0.rc1.169.g49223abbf8


```

## Johannes Schindelin, 2019-06-05 12:37

Subject: Re: [PATCH 2/2] config/alias.txt: document alias accepting non-command first word
Message-ID: <nycvar.QRO.7.76.6.1906051434500.1775@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.1906051434500.1775%40tvgsbejvaqbjf.bet
In-Reply-To: <13d9ddd3541e3815078c4853c6f7c25cddd89126.1559333840.git.liu.denton@gmail.com>

```
Hi Denton,

On Fri, 31 May 2019, Denton Liu wrote:

> One can see that an alias that begins with a non-command first word,
> such as `loud-rebase = -c commit.verbose=true rebase`, is permitted.
> However, this isn't immediately obvious to users as alias instances
> typically begin with a command.
>
> Document the fact that an alias can begin with a non-command first word
> so that users will be able to discover that this is a feature.

You caught me.

Granted, back in 2006, when I introduced that feature, we were not *quite*
as diligent about documenting new features as we are today (see
4ab243a944a6 (Allow an alias to start with "-p", 2006-07-24)).

I like your patch! Maybe you would like to mention `-p`, too, as a
possible use case, as that was the original reason I introduced the
feature? (To this day, the first thing I do on a new machine *right* after
installing Git is to call `git config --global alias.ps '-p status'`)

I'd be fine with these two patches as-are, of course.

Thank you!
Dscho

>
> Signed-off-by: Denton Liu <liu.denton@gmail.com>
> ---
>  Documentation/config/alias.txt | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/Documentation/config/alias.txt b/Documentation/config/alias.txt
> index 5425449a50..f241f03ebe 100644
> --- a/Documentation/config/alias.txt
> +++ b/Documentation/config/alias.txt
> @@ -7,6 +7,14 @@ alias.*::
>  	spaces, the usual shell quoting and escaping is supported.
>  	A quote pair or a backslash can be used to quote them.
>  +
> +Note that the first word of an alias does not necessarily have to be a
> +command. It can be a command-line option that will be passed into the
> +invocation of `git`. In particular, this is useful when used with `-c`
> +to pass in one-time configurations. For example,
> +`loud-rebase = -c commit.verbose=true rebase` can be defined such that
> +running `git loud-merge` would be equivalent to
> +`git -c commit.verbose=true rebase`.
> ++
>  If the alias expansion is prefixed with an exclamation point,
>  it will be treated as a shell command.  For example, defining
>  `alias.new = !gitk --all --not ORIG_HEAD`, the invocation
> --
> 2.22.0.rc1.169.g49223abbf8
>
>

```

## Denton Liu, 2019-06-05 20:10

Subject: [PATCH v2 0/2] Doc: document alias accepting non-command first word
Message-ID: <cover.1559755652.git.liu.denton@gmail.com>
URL: https://gitlist.dev/e/cover.1559755652.git.liu.denton%40gmail.com
In-Reply-To: <cover.1559333840.git.liu.denton@gmail.com>

```
Thanks for the review, Johannes. I think it's a good idea to add another
alias for `-p` so included that suggestion. Also, while I was at it, I
found a typo so I fixed that too.

Changes since v1:

* s/loud-merge/loud-rebase/
* Add `-p` as another example since that was Dscho's original use-case


Denton Liu (2):
  config/alias.txt: change " and ' to `
  config/alias.txt: document alias accepting non-command first word

 Documentation/config/alias.txt | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

Interdiff against v1:
diff --git a/Documentation/config/alias.txt b/Documentation/config/alias.txt
index f241f03ebe..f1ca739d57 100644
--- a/Documentation/config/alias.txt
+++ b/Documentation/config/alias.txt
@@ -10,10 +10,12 @@ alias.*::
 Note that the first word of an alias does not necessarily have to be a
 command. It can be a command-line option that will be passed into the
 invocation of `git`. In particular, this is useful when used with `-c`
-to pass in one-time configurations. For example,
+to pass in one-time configurations or `-p` to force pagination. For example,
 `loud-rebase = -c commit.verbose=true rebase` can be defined such that
-running `git loud-merge` would be equivalent to
-`git -c commit.verbose=true rebase`.
+running `git loud-rebase` would be equivalent to
+`git -c commit.verbose=true rebase`. Also, `ps = -p status` would be a
+helpful alias since `git ps` would paginate the output of `git status`
+where the original command does not.
 +
 If the alias expansion is prefixed with an exclamation point,
 it will be treated as a shell command.  For example, defining
-- 
2.22.0.rc1.169.g49223abbf8


```

## Denton Liu, 2019-06-05 20:10

Subject: [PATCH v2 1/2] config/alias.txt: change " and ' to `
Message-ID: <bdc99e133258e01bc6d88ac66de22c15f9aa70c8.1559755652.git.liu.denton@gmail.com>
URL: https://gitlist.dev/e/bdc99e133258e01bc6d88ac66de22c15f9aa70c8.1559755652.git.liu.denton%40gmail.com
In-Reply-To: <cover.1559755652.git.liu.denton@gmail.com>

```
Before, the documentation would mix " and ' for code and config
snippets. Change these instances to ` so that they are marked up in
monospace.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 Documentation/config/alias.txt | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Documentation/config/alias.txt b/Documentation/config/alias.txt
index 0b14178314..5425449a50 100644
--- a/Documentation/config/alias.txt
+++ b/Documentation/config/alias.txt
@@ -1,7 +1,7 @@
 alias.*::
 	Command aliases for the linkgit:git[1] command wrapper - e.g.
-	after defining "alias.last = cat-file commit HEAD", the invocation
-	"git last" is equivalent to "git cat-file commit HEAD". To avoid
+	after defining `alias.last = cat-file commit HEAD`, the invocation
+	`git last` is equivalent to `git cat-file commit HEAD`. To avoid
 	confusion and troubles with script usage, aliases that
 	hide existing Git commands are ignored. Arguments are split by
 	spaces, the usual shell quoting and escaping is supported.
@@ -9,10 +9,10 @@ alias.*::
 +
 If the alias expansion is prefixed with an exclamation point,
 it will be treated as a shell command.  For example, defining
-"alias.new = !gitk --all --not ORIG_HEAD", the invocation
-"git new" is equivalent to running the shell command
-"gitk --all --not ORIG_HEAD".  Note that shell commands will be
+`alias.new = !gitk --all --not ORIG_HEAD`, the invocation
+`git new` is equivalent to running the shell command
+`gitk --all --not ORIG_HEAD`.  Note that shell commands will be
 executed from the top-level directory of a repository, which may
 not necessarily be the current directory.
-`GIT_PREFIX` is set as returned by running 'git rev-parse --show-prefix'
+`GIT_PREFIX` is set as returned by running `git rev-parse --show-prefix`
 from the original current directory. See linkgit:git-rev-parse[1].
-- 
2.22.0.rc1.169.g49223abbf8


```

## Denton Liu, 2019-06-05 20:10

Subject: [PATCH v2 2/2] config/alias.txt: document alias accepting non-command first word
Message-ID: <44c4e1c560de607f30eb87234611a5bbc00620a7.1559755652.git.liu.denton@gmail.com>
URL: https://gitlist.dev/e/44c4e1c560de607f30eb87234611a5bbc00620a7.1559755652.git.liu.denton%40gmail.com
In-Reply-To: <cover.1559755652.git.liu.denton@gmail.com>

```
One can see that an alias that begins with a non-command first word,
such as `loud-rebase = -c commit.verbose=true rebase`, is permitted.
However, this isn't immediately obvious to users as alias instances
typically begin with a command.

Document the fact that an alias can begin with a non-command first word
so that users will be able to discover that this is a feature.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 Documentation/config/alias.txt | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/config/alias.txt b/Documentation/config/alias.txt
index 5425449a50..f1ca739d57 100644
--- a/Documentation/config/alias.txt
+++ b/Documentation/config/alias.txt
@@ -7,6 +7,16 @@ alias.*::
 	spaces, the usual shell quoting and escaping is supported.
 	A quote pair or a backslash can be used to quote them.
 +
+Note that the first word of an alias does not necessarily have to be a
+command. It can be a command-line option that will be passed into the
+invocation of `git`. In particular, this is useful when used with `-c`
+to pass in one-time configurations or `-p` to force pagination. For example,
+`loud-rebase = -c commit.verbose=true rebase` can be defined such that
+running `git loud-rebase` would be equivalent to
+`git -c commit.verbose=true rebase`. Also, `ps = -p status` would be a
+helpful alias since `git ps` would paginate the output of `git status`
+where the original command does not.
++
 If the alias expansion is prefixed with an exclamation point,
 it will be treated as a shell command.  For example, defining
 `alias.new = !gitk --all --not ORIG_HEAD`, the invocation
-- 
2.22.0.rc1.169.g49223abbf8


```

## Johannes Schindelin, 2019-06-06 12:48

Subject: Re: [PATCH v2 0/2] Doc: document alias accepting non-command first word
Message-ID: <nycvar.QRO.7.76.6.1906061448350.42@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.1906061448350.42%40tvgsbejvaqbjf.bet
In-Reply-To: <cover.1559755652.git.liu.denton@gmail.com>

```
Hi Denton,

On Wed, 5 Jun 2019, Denton Liu wrote:

> Thanks for the review, Johannes. I think it's a good idea to add another
> alias for `-p` so included that suggestion. Also, while I was at it, I
> found a typo so I fixed that too.
>
> Changes since v1:
>
> * s/loud-merge/loud-rebase/
> * Add `-p` as another example since that was Dscho's original use-case

Looks good to me!
Dscho

```
