git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/2] document alias accepting non-command first word
@ 2019-05-31 20:23 Denton Liu
  2019-05-31 20:23 ` [PATCH 1/2] config/alias.txt: change " and ' to ` Denton Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Denton Liu @ 2019-05-31 20:23 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Johannes Schindelin

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] config/alias.txt: change " and ' to `
  2019-05-31 20:23 [PATCH 0/2] document alias accepting non-command first word Denton Liu
@ 2019-05-31 20:23 ` Denton Liu
  2019-05-31 20:23 ` [PATCH 2/2] config/alias.txt: document alias accepting non-command first word Denton Liu
  2019-06-05 20:10 ` [PATCH v2 0/2] Doc: " Denton Liu
  2 siblings, 0 replies; 8+ messages in thread
From: Denton Liu @ 2019-05-31 20:23 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Johannes Schindelin

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] config/alias.txt: document alias accepting non-command first word
  2019-05-31 20:23 [PATCH 0/2] document alias accepting non-command first word Denton Liu
  2019-05-31 20:23 ` [PATCH 1/2] config/alias.txt: change " and ' to ` Denton Liu
@ 2019-05-31 20:23 ` Denton Liu
  2019-06-05 12:37   ` Johannes Schindelin
  2019-06-05 20:10 ` [PATCH v2 0/2] Doc: " Denton Liu
  2 siblings, 1 reply; 8+ messages in thread
From: Denton Liu @ 2019-05-31 20:23 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Johannes Schindelin

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] config/alias.txt: document alias accepting non-command first word
  2019-05-31 20:23 ` [PATCH 2/2] config/alias.txt: document alias accepting non-command first word Denton Liu
@ 2019-06-05 12:37   ` Johannes Schindelin
  0 siblings, 0 replies; 8+ messages in thread
From: Johannes Schindelin @ 2019-06-05 12:37 UTC (permalink / raw)
  To: Denton Liu; +Cc: Git Mailing List

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 0/2] Doc: document alias accepting non-command first word
  2019-05-31 20:23 [PATCH 0/2] document alias accepting non-command first word Denton Liu
  2019-05-31 20:23 ` [PATCH 1/2] config/alias.txt: change " and ' to ` Denton Liu
  2019-05-31 20:23 ` [PATCH 2/2] config/alias.txt: document alias accepting non-command first word Denton Liu
@ 2019-06-05 20:10 ` Denton Liu
  2019-06-05 20:10   ` [PATCH v2 1/2] config/alias.txt: change " and ' to ` Denton Liu
                     ` (2 more replies)
  2 siblings, 3 replies; 8+ messages in thread
From: Denton Liu @ 2019-06-05 20:10 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Johannes Schindelin

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 1/2] config/alias.txt: change " and ' to `
  2019-06-05 20:10 ` [PATCH v2 0/2] Doc: " Denton Liu
@ 2019-06-05 20:10   ` Denton Liu
  2019-06-05 20:10   ` [PATCH v2 2/2] config/alias.txt: document alias accepting non-command first word Denton Liu
  2019-06-06 12:48   ` [PATCH v2 0/2] Doc: " Johannes Schindelin
  2 siblings, 0 replies; 8+ messages in thread
From: Denton Liu @ 2019-06-05 20:10 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Johannes Schindelin

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] config/alias.txt: document alias accepting non-command first word
  2019-06-05 20:10 ` [PATCH v2 0/2] Doc: " Denton Liu
  2019-06-05 20:10   ` [PATCH v2 1/2] config/alias.txt: change " and ' to ` Denton Liu
@ 2019-06-05 20:10   ` Denton Liu
  2019-06-06 12:48   ` [PATCH v2 0/2] Doc: " Johannes Schindelin
  2 siblings, 0 replies; 8+ messages in thread
From: Denton Liu @ 2019-06-05 20:10 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Johannes Schindelin

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] Doc: document alias accepting non-command first word
  2019-06-05 20:10 ` [PATCH v2 0/2] Doc: " Denton Liu
  2019-06-05 20:10   ` [PATCH v2 1/2] config/alias.txt: change " and ' to ` Denton Liu
  2019-06-05 20:10   ` [PATCH v2 2/2] config/alias.txt: document alias accepting non-command first word Denton Liu
@ 2019-06-06 12:48   ` Johannes Schindelin
  2 siblings, 0 replies; 8+ messages in thread
From: Johannes Schindelin @ 2019-06-06 12:48 UTC (permalink / raw)
  To: Denton Liu; +Cc: Git Mailing List

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-06-06 12:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 20:23 [PATCH 0/2] document alias accepting non-command first word Denton Liu
2019-05-31 20:23 ` [PATCH 1/2] config/alias.txt: change " and ' to ` Denton Liu
2019-05-31 20:23 ` [PATCH 2/2] config/alias.txt: document alias accepting non-command first word Denton Liu
2019-06-05 12:37   ` Johannes Schindelin
2019-06-05 20:10 ` [PATCH v2 0/2] Doc: " Denton Liu
2019-06-05 20:10   ` [PATCH v2 1/2] config/alias.txt: change " and ' to ` Denton Liu
2019-06-05 20:10   ` [PATCH v2 2/2] config/alias.txt: document alias accepting non-command first word Denton Liu
2019-06-06 12:48   ` [PATCH v2 0/2] Doc: " Johannes Schindelin

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).