mirror of
https://github.com/git/git
synced 2024-09-18 07:51:35 +00:00
Merge branch 'rj/doc-rev-parse'
* rj/doc-rev-parse: rev-parse(1): logically group options rev-parse: remove restrictions on some options
This commit is contained in:
commit
e30db6dbcf
|
@ -24,9 +24,23 @@ distinguish between them.
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
Operation Modes
|
||||||
|
~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Each of these options must appear first on the command line.
|
||||||
|
|
||||||
--parseopt::
|
--parseopt::
|
||||||
Use 'git rev-parse' in option parsing mode (see PARSEOPT section below).
|
Use 'git rev-parse' in option parsing mode (see PARSEOPT section below).
|
||||||
|
|
||||||
|
--sq-quote::
|
||||||
|
Use 'git rev-parse' in shell quoting mode (see SQ-QUOTE
|
||||||
|
section below). In contrast to the `--sq` option below, this
|
||||||
|
mode does only quoting. Nothing else is done to command input.
|
||||||
|
|
||||||
|
Options for --parseopt
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
--keep-dashdash::
|
--keep-dashdash::
|
||||||
Only meaningful in `--parseopt` mode. Tells the option parser to echo
|
Only meaningful in `--parseopt` mode. Tells the option parser to echo
|
||||||
out the first `--` met instead of skipping it.
|
out the first `--` met instead of skipping it.
|
||||||
|
@ -36,10 +50,8 @@ OPTIONS
|
||||||
the first non-option argument. This can be used to parse sub-commands
|
the first non-option argument. This can be used to parse sub-commands
|
||||||
that take options themselves.
|
that take options themselves.
|
||||||
|
|
||||||
--sq-quote::
|
Options for Filtering
|
||||||
Use 'git rev-parse' in shell quoting mode (see SQ-QUOTE
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
section below). In contrast to the `--sq` option below, this
|
|
||||||
mode does only quoting. Nothing else is done to command input.
|
|
||||||
|
|
||||||
--revs-only::
|
--revs-only::
|
||||||
Do not output flags and parameters not meant for
|
Do not output flags and parameters not meant for
|
||||||
|
@ -55,6 +67,9 @@ OPTIONS
|
||||||
--no-flags::
|
--no-flags::
|
||||||
Do not output flag parameters.
|
Do not output flag parameters.
|
||||||
|
|
||||||
|
Options for Output
|
||||||
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
--default <arg>::
|
--default <arg>::
|
||||||
If there is no parameter given by the user, use `<arg>`
|
If there is no parameter given by the user, use `<arg>`
|
||||||
instead.
|
instead.
|
||||||
|
@ -110,6 +125,17 @@ can be used.
|
||||||
strip '{caret}' prefix from the object names that already have
|
strip '{caret}' prefix from the object names that already have
|
||||||
one.
|
one.
|
||||||
|
|
||||||
|
--abbrev-ref[=(strict|loose)]::
|
||||||
|
A non-ambiguous short name of the objects name.
|
||||||
|
The option core.warnAmbiguousRefs is used to select the strict
|
||||||
|
abbreviation mode.
|
||||||
|
|
||||||
|
--short::
|
||||||
|
--short=number::
|
||||||
|
Instead of outputting the full SHA-1 values of object names try to
|
||||||
|
abbreviate them to a shorter unique name. When no length is specified
|
||||||
|
7 is used. The minimum length is 4.
|
||||||
|
|
||||||
--symbolic::
|
--symbolic::
|
||||||
Usually the object names are output in SHA-1 form (with
|
Usually the object names are output in SHA-1 form (with
|
||||||
possible '{caret}' prefix); this option makes them output in a
|
possible '{caret}' prefix); this option makes them output in a
|
||||||
|
@ -123,16 +149,8 @@ can be used.
|
||||||
unfortunately named tag "master"), and show them as full
|
unfortunately named tag "master"), and show them as full
|
||||||
refnames (e.g. "refs/heads/master").
|
refnames (e.g. "refs/heads/master").
|
||||||
|
|
||||||
--abbrev-ref[=(strict|loose)]::
|
Options for Objects
|
||||||
A non-ambiguous short name of the objects name.
|
~~~~~~~~~~~~~~~~~~~
|
||||||
The option core.warnAmbiguousRefs is used to select the strict
|
|
||||||
abbreviation mode.
|
|
||||||
|
|
||||||
--disambiguate=<prefix>::
|
|
||||||
Show every object whose name begins with the given prefix.
|
|
||||||
The <prefix> must be at least 4 hexadecimal digits long to
|
|
||||||
avoid listing each and every object in the repository by
|
|
||||||
mistake.
|
|
||||||
|
|
||||||
--all::
|
--all::
|
||||||
Show all refs found in `refs/`.
|
Show all refs found in `refs/`.
|
||||||
|
@ -155,18 +173,20 @@ shown. If the pattern does not contain a globbing character (`?`,
|
||||||
character (`?`, `*`, or `[`), it is turned into a prefix
|
character (`?`, `*`, or `[`), it is turned into a prefix
|
||||||
match by appending `/*`.
|
match by appending `/*`.
|
||||||
|
|
||||||
--show-toplevel::
|
--disambiguate=<prefix>::
|
||||||
Show the absolute path of the top-level directory.
|
Show every object whose name begins with the given prefix.
|
||||||
|
The <prefix> must be at least 4 hexadecimal digits long to
|
||||||
|
avoid listing each and every object in the repository by
|
||||||
|
mistake.
|
||||||
|
|
||||||
--show-prefix::
|
Options for Files
|
||||||
When the command is invoked from a subdirectory, show the
|
~~~~~~~~~~~~~~~~~
|
||||||
path of the current directory relative to the top-level
|
|
||||||
directory.
|
|
||||||
|
|
||||||
--show-cdup::
|
--local-env-vars::
|
||||||
When the command is invoked from a subdirectory, show the
|
List the GIT_* environment variables that are local to the
|
||||||
path of the top-level directory relative to the current
|
repository (e.g. GIT_DIR or GIT_WORK_TREE, but not GIT_EDITOR).
|
||||||
directory (typically a sequence of "../", or an empty string).
|
Only the names of the variables are listed, not their value,
|
||||||
|
even if they are set.
|
||||||
|
|
||||||
--git-dir::
|
--git-dir::
|
||||||
Show `$GIT_DIR` if defined. Otherwise show the path to
|
Show `$GIT_DIR` if defined. Otherwise show the path to
|
||||||
|
@ -188,17 +208,27 @@ print a message to stderr and exit with nonzero status.
|
||||||
--is-bare-repository::
|
--is-bare-repository::
|
||||||
When the repository is bare print "true", otherwise "false".
|
When the repository is bare print "true", otherwise "false".
|
||||||
|
|
||||||
--local-env-vars::
|
--resolve-git-dir <path>::
|
||||||
List the GIT_* environment variables that are local to the
|
Check if <path> is a valid repository or a gitfile that
|
||||||
repository (e.g. GIT_DIR or GIT_WORK_TREE, but not GIT_EDITOR).
|
points at a valid repository, and print the location of the
|
||||||
Only the names of the variables are listed, not their value,
|
repository. If <path> is a gitfile then the resolved path
|
||||||
even if they are set.
|
to the real repository is printed.
|
||||||
|
|
||||||
--short::
|
--show-cdup::
|
||||||
--short=number::
|
When the command is invoked from a subdirectory, show the
|
||||||
Instead of outputting the full SHA-1 values of object names try to
|
path of the top-level directory relative to the current
|
||||||
abbreviate them to a shorter unique name. When no length is specified
|
directory (typically a sequence of "../", or an empty string).
|
||||||
7 is used. The minimum length is 4.
|
|
||||||
|
--show-prefix::
|
||||||
|
When the command is invoked from a subdirectory, show the
|
||||||
|
path of the current directory relative to the top-level
|
||||||
|
directory.
|
||||||
|
|
||||||
|
--show-toplevel::
|
||||||
|
Show the absolute path of the top-level directory.
|
||||||
|
|
||||||
|
Other Options
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
--since=datestring::
|
--since=datestring::
|
||||||
--after=datestring::
|
--after=datestring::
|
||||||
|
@ -213,12 +243,6 @@ print a message to stderr and exit with nonzero status.
|
||||||
<args>...::
|
<args>...::
|
||||||
Flags and parameters to be parsed.
|
Flags and parameters to be parsed.
|
||||||
|
|
||||||
--resolve-git-dir <path>::
|
|
||||||
Check if <path> is a valid repository or a gitfile that
|
|
||||||
points at a valid repository, and print the location of the
|
|
||||||
repository. If <path> is a gitfile then the resolved path
|
|
||||||
to the real repository is printed.
|
|
||||||
|
|
||||||
|
|
||||||
include::revisions.txt[]
|
include::revisions.txt[]
|
||||||
|
|
||||||
|
|
|
@ -486,21 +486,6 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
||||||
if (argc > 1 && !strcmp("--sq-quote", argv[1]))
|
if (argc > 1 && !strcmp("--sq-quote", argv[1]))
|
||||||
return cmd_sq_quote(argc - 2, argv + 2);
|
return cmd_sq_quote(argc - 2, argv + 2);
|
||||||
|
|
||||||
if (argc == 2 && !strcmp("--local-env-vars", argv[1])) {
|
|
||||||
int i;
|
|
||||||
for (i = 0; local_repo_env[i]; i++)
|
|
||||||
printf("%s\n", local_repo_env[i]);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc > 2 && !strcmp(argv[1], "--resolve-git-dir")) {
|
|
||||||
const char *gitdir = resolve_gitdir(argv[2]);
|
|
||||||
if (!gitdir)
|
|
||||||
die("not a gitdir '%s'", argv[2]);
|
|
||||||
puts(gitdir);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc > 1 && !strcmp("-h", argv[1]))
|
if (argc > 1 && !strcmp("-h", argv[1]))
|
||||||
usage(builtin_rev_parse_usage);
|
usage(builtin_rev_parse_usage);
|
||||||
|
|
||||||
|
@ -661,6 +646,12 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
||||||
for_each_remote_ref(show_reference, NULL);
|
for_each_remote_ref(show_reference, NULL);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(arg, "--local-env-vars")) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; local_repo_env[i]; i++)
|
||||||
|
printf("%s\n", local_repo_env[i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!strcmp(arg, "--show-toplevel")) {
|
if (!strcmp(arg, "--show-toplevel")) {
|
||||||
const char *work_tree = get_git_work_tree();
|
const char *work_tree = get_git_work_tree();
|
||||||
if (work_tree)
|
if (work_tree)
|
||||||
|
@ -711,6 +702,13 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
||||||
printf("%s%s.git\n", cwd, len && cwd[len-1] != '/' ? "/" : "");
|
printf("%s%s.git\n", cwd, len && cwd[len-1] != '/' ? "/" : "");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(arg, "--resolve-git-dir")) {
|
||||||
|
const char *gitdir = resolve_gitdir(argv[i+1]);
|
||||||
|
if (!gitdir)
|
||||||
|
die("not a gitdir '%s'", argv[i+1]);
|
||||||
|
puts(gitdir);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!strcmp(arg, "--is-inside-git-dir")) {
|
if (!strcmp(arg, "--is-inside-git-dir")) {
|
||||||
printf("%s\n", is_inside_git_dir() ? "true"
|
printf("%s\n", is_inside_git_dir() ? "true"
|
||||||
: "false");
|
: "false");
|
||||||
|
|
Loading…
Reference in a new issue