document alias accepting non-command first word
cover document alias accepting non-command first word
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/[email protected]/
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(-)
Signature · 1 line
2.22.0.rc1.169.g49223abbf8
PATCH 1/2 config/alias.txt: change " and ' to `
Before, the documentation would mix " and ' for code and config snippets. Change these instances to ` so that they are marked up in monospace.
--- Documentation/config/alias.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Documentation/config/alias.txt +6 -6
@@ -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].
Signature · 1 line
2.22.0.rc1.169.g49223abbf8
PATCH 2/2 config/alias.txt: document alias accepting non-command first word
In reply to Denton LiuOne 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.
--- Documentation/config/alias.txt | 8 ++++++++ 1 file changed, 8 insertions(+)
Documentation/config/alias.txt +8 -0
@@ -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
Signature · 1 line
2.22.0.rc1.169.g49223abbf8
Re: [PATCH 2/2] config/alias.txt: document alias accepting non-command first word
Hi Denton,
Quoted 7 lines · Denton Liu
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
Quoted 29 lines
Signed-off-by Denton Liu <[email protected]>--- Documentation/config/alias.txt | 8 ++++++++ 1 file changed, 8 insertions(+)Documentation/config/alias.txt +8
-1@@ -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
v2 cover Doc: document alias accepting non-command first word
In reply to Denton LiuThanks 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:
Documentation/config/alias.txt +5 -3
@@ -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
Signature · 1 line
2.22.0.rc1.169.g49223abbf8
PATCH v2 1/2 config/alias.txt: change " and ' to `
Before, the documentation would mix " and ' for code and config snippets. Change these instances to ` so that they are marked up in monospace.
--- Documentation/config/alias.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Documentation/config/alias.txt +6 -6
@@ -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].
Signature · 1 line
2.22.0.rc1.169.g49223abbf8
PATCH v2 2/2 config/alias.txt: document alias accepting non-command first word
In reply to Denton LiuOne 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.
--- Documentation/config/alias.txt | 10 ++++++++++ 1 file changed, 10 insertions(+)
Documentation/config/alias.txt +10 -0
@@ -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
Signature · 1 line
2.22.0.rc1.169.g49223abbf8
Re: [PATCH v2 0/2] Doc: document alias accepting non-command first word
In reply to Denton LiuHi Denton,
Quoted 8 lines · Denton Liu
Thanks for the review, Johannes. I think it's a good idea to add another alias for
-pso 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-pas another example since that was Dscho's original use-case
Looks good to me!
Dscho