Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Documentation/RelNotes/2.52.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Git v2.52 Release Notes
UI, Workflows & Features
------------------------

* The "list" subcommand of "git refs" acts as a front-end for
"git for-each-ref".


Performance, Internal Implementation, Development Support etc.
--------------------------------------------------------------
Expand All @@ -21,6 +24,7 @@ Performance, Internal Implementation, Development Support etc.
contained wildcards; now they take advantage of the filter when
they can.


Fixes since v2.51
-----------------

Expand Down Expand Up @@ -52,7 +56,26 @@ including security updates, are included in this release.
been fixed.
(merge f6ecb603ff en/ort-rename-fixes later to maint).

* "git jump" (in contrib/) fails to parse the diff header correctly
when a file has a space in its name, which has been corrected.
(merge 621ce9c1c6 gh/git-jump-pathname-with-sp later to maint).

* "git diff --no-index" run inside a subdirectory under control of a
Git repository operated at the top of the working tree and stripped
the prefix from the output, and oddballs like "-" (stdin) did not
work correctly because of it. Correct the set-up by undoing what
the set-up sequence did to cwd and prefix.
(merge e1d3d61a45 jc/diff-no-index-in-subdir later to maint).

* Various options to "git diff" that makes comparison ignore certain
aspects of the differences (like "space changes are ignored",
"differences in lines that match these regular expressions are
ignored") did not work well with "--name-only" and friends.
(merge b55e6d36eb ly/diff-name-only-with-diff-from-content later to maint).

* Other code cleanup, docfix, build fix, etc.
(merge 823d537fa7 kh/doc-git-log-markup-fix later to maint).
(merge cf7efa4f33 rj/t6137-cygwin-fix later to maint).
(merge 529a60a885 ua/t1517-short-help-tests later to maint).
(merge 22d421fed9 ac/deglobal-fmt-merge-log-config later to maint).
(merge 741f36c7d9 kr/clone-synopsis-fix later to maint).
88 changes: 88 additions & 0 deletions Documentation/for-each-ref-options.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<pattern>...::
If one or more patterns are given, only refs are shown that
match against at least one pattern, either using fnmatch(3) or
literally, in the latter case matching completely or from the
beginning up to a slash.

--stdin::
If `--stdin` is supplied, then the list of patterns is read from
standard input instead of from the argument list.

--count=<count>::
By default the command shows all refs that match
`<pattern>`. This option makes it stop after showing
that many refs.

--sort=<key>::
A field name to sort on. Prefix `-` to sort in
descending order of the value. When unspecified,
`refname` is used. You may use the --sort=<key> option
multiple times, in which case the last key becomes the primary
key.

--format=<format>::
A string that interpolates `%(fieldname)` from a ref being shown and
the object it points at. In addition, the string literal `%%`
renders as `%` and `%xx` - where `xx` are hex digits - renders as
the character with hex code `xx`. For example, `%00` interpolates to
`\0` (NUL), `%09` to `\t` (TAB), and `%0a` to `\n` (LF).
+
When unspecified, `<format>` defaults to `%(objectname) SPC %(objecttype)
TAB %(refname)`.

--color[=<when>]::
Respect any colors specified in the `--format` option. The
`<when>` field must be one of `always`, `never`, or `auto` (if
`<when>` is absent, behave as if `always` was given).

--shell::
--perl::
--python::
--tcl::
If given, strings that substitute `%(fieldname)`
placeholders are quoted as string literals suitable for
the specified host language. This is meant to produce
a scriptlet that can directly be `eval`ed.

--points-at=<object>::
Only list refs which points at the given object.

--merged[=<object>]::
Only list refs whose tips are reachable from the
specified commit (HEAD if not specified).

--no-merged[=<object>]::
Only list refs whose tips are not reachable from the
specified commit (HEAD if not specified).

--contains[=<object>]::
Only list refs which contain the specified commit (HEAD if not
specified).

--no-contains[=<object>]::
Only list refs which don't contain the specified commit (HEAD
if not specified).

--ignore-case::
Sorting and filtering refs are case insensitive.

--omit-empty::
Do not print a newline after formatted refs where the format expands
to the empty string.

--exclude=<pattern>::
If one or more patterns are given, only refs which do not match
any excluded pattern(s) are shown. Matching is done using the
same rules as `<pattern>` above.

--include-root-refs::
List root refs (HEAD and pseudorefs) apart from regular refs.

--start-after=<marker>::
Allows paginating the output by skipping references up to and including the
specified marker. When paging, it should be noted that references may be
deleted, modified or added between invocations. Output will only yield those
references which follow the marker lexicographically. Output begins from the
first reference that would come after the marker alphabetically. Cannot be
used with `--sort=<key>` or `--stdin` options, or the _<pattern>_ argument(s)
to limit the refs.
2 changes: 1 addition & 1 deletion Documentation/git-clone.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ git clone [--template=<template-directory>]
[--depth <depth>] [--[no-]single-branch] [--[no-]tags]
[--recurse-submodules[=<pathspec>]] [--[no-]shallow-submodules]
[--[no-]remote-submodules] [--jobs <n>] [--sparse] [--[no-]reject-shallow]
[--filter=<filter-spec>] [--also-filter-submodules]] [--] <repository>
[--filter=<filter-spec> [--also-filter-submodules]] [--] <repository>
[<directory>]

DESCRIPTION
Expand Down
89 changes: 1 addition & 88 deletions Documentation/git-for-each-ref.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,94 +28,7 @@ host language allowing their direct evaluation in that language.

OPTIONS
-------
<pattern>...::
If one or more patterns are given, only refs are shown that
match against at least one pattern, either using fnmatch(3) or
literally, in the latter case matching completely or from the
beginning up to a slash.

--stdin::
If `--stdin` is supplied, then the list of patterns is read from
standard input instead of from the argument list.

--count=<count>::
By default the command shows all refs that match
`<pattern>`. This option makes it stop after showing
that many refs.

--sort=<key>::
A field name to sort on. Prefix `-` to sort in
descending order of the value. When unspecified,
`refname` is used. You may use the --sort=<key> option
multiple times, in which case the last key becomes the primary
key.

--format=<format>::
A string that interpolates `%(fieldname)` from a ref being shown and
the object it points at. In addition, the string literal `%%`
renders as `%` and `%xx` - where `xx` are hex digits - renders as
the character with hex code `xx`. For example, `%00` interpolates to
`\0` (NUL), `%09` to `\t` (TAB), and `%0a` to `\n` (LF).
+
When unspecified, `<format>` defaults to `%(objectname) SPC %(objecttype)
TAB %(refname)`.

--color[=<when>]::
Respect any colors specified in the `--format` option. The
`<when>` field must be one of `always`, `never`, or `auto` (if
`<when>` is absent, behave as if `always` was given).

--shell::
--perl::
--python::
--tcl::
If given, strings that substitute `%(fieldname)`
placeholders are quoted as string literals suitable for
the specified host language. This is meant to produce
a scriptlet that can directly be `eval`ed.

--points-at=<object>::
Only list refs which points at the given object.

--merged[=<object>]::
Only list refs whose tips are reachable from the
specified commit (HEAD if not specified).

--no-merged[=<object>]::
Only list refs whose tips are not reachable from the
specified commit (HEAD if not specified).

--contains[=<object>]::
Only list refs which contain the specified commit (HEAD if not
specified).

--no-contains[=<object>]::
Only list refs which don't contain the specified commit (HEAD
if not specified).

--ignore-case::
Sorting and filtering refs are case insensitive.

--omit-empty::
Do not print a newline after formatted refs where the format expands
to the empty string.

--exclude=<pattern>::
If one or more patterns are given, only refs which do not match
any excluded pattern(s) are shown. Matching is done using the
same rules as `<pattern>` above.

--include-root-refs::
List root refs (HEAD and pseudorefs) apart from regular refs.

--start-after=<marker>::
Allows paginating the output by skipping references up to and including the
specified marker. When paging, it should be noted that references may be
deleted, modified or added between invocations. Output will only yield those
references which follow the marker lexicographically. Output begins from the
first reference that would come after the marker alphabetically. Cannot be
used with `--sort=<key>` or `--stdin` options, or the _<pattern>_ argument(s)
to limit the refs.
include::for-each-ref-options.adoc[]

FIELD NAMES
-----------
Expand Down
16 changes: 16 additions & 0 deletions Documentation/git-refs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ SYNOPSIS
[synopsis]
git refs migrate --ref-format=<format> [--no-reflog] [--dry-run]
git refs verify [--strict] [--verbose]
git refs list [--count=<count>] [--shell|--perl|--python|--tcl]
[(--sort=<key>)...] [--format=<format>]
[--include-root-refs] [--points-at=<object>]
[--merged[=<object>]] [--no-merged[=<object>]]
[--contains[=<object>]] [--no-contains[=<object>]]
[(--exclude=<pattern>)...] [--start-after=<marker>]
[ --stdin | <pattern>... ]

DESCRIPTION
-----------
Expand All @@ -26,6 +33,11 @@ migrate::
verify::
Verify reference database consistency.

list::
List references in the repository with support for filtering,
formatting, and sorting. This subcommand is an alias for
linkgit:git-for-each-ref[1] and offers identical functionality.

OPTIONS
-------

Expand Down Expand Up @@ -57,6 +69,10 @@ The following options are specific to 'git refs verify':
--verbose::
When verifying the reference database consistency, be chatty.

The following options are specific to 'git refs list':

include::for-each-ref-options.adoc[]

KNOWN LIMITATIONS
-----------------

Expand Down
15 changes: 15 additions & 0 deletions builtin/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,21 @@ int cmd_diff(int argc,

init_diff_ui_defaults();
repo_config(the_repository, git_diff_ui_config, NULL);

/*
* If we are ignoring the fact that our current directory may
* be part of a working tree controlled by a Git repository to
* pretend to be a "better GNU diff", we should undo the
* effect of the setup code that did a chdir() to the top of
* the working tree. Where we came from is recorded in the
* prefix.
*/
if (no_index && prefix) {
if (chdir(prefix))
die(_("cannot come back to cwd"));
prefix = NULL;
}

prefix = precompose_argv_prefix(argc, argv, prefix);

repo_init_revisions(the_repository, &rev, prefix);
Expand Down
6 changes: 3 additions & 3 deletions builtin/fmt-merge-msg.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "fmt-merge-msg.h"
Expand All @@ -13,12 +12,13 @@ static const char * const fmt_merge_msg_usage[] = {
int cmd_fmt_merge_msg(int argc,
const char **argv,
const char *prefix,
struct repository *repo UNUSED)
struct repository *repo)
{
char *inpath = NULL;
const char *message = NULL;
char *into_name = NULL;
int shortlog_len = -1;
int merge_log_config = -1;
struct option options[] = {
{
.type = OPTION_INTEGER,
Expand Down Expand Up @@ -53,7 +53,7 @@ int cmd_fmt_merge_msg(int argc,
int ret;
struct fmt_merge_msg_opts opts;

repo_config(the_repository, fmt_merge_msg_config, NULL);
repo_config(repo, fmt_merge_msg_config, &merge_log_config);
argc = parse_options(argc, argv, prefix, options, fmt_merge_msg_usage,
0);
if (argc > 0)
Expand Down
36 changes: 19 additions & 17 deletions builtin/for-each-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,15 @@
#include "commit.h"
#include "config.h"
#include "environment.h"
#include "for-each-ref.h"
#include "gettext.h"
#include "object.h"
#include "parse-options.h"
#include "ref-filter.h"
#include "strbuf.h"
#include "strvec.h"

static char const * const for_each_ref_usage[] = {
N_("git for-each-ref [<options>] [<pattern>]"),
N_("git for-each-ref [--points-at <object>]"),
N_("git for-each-ref [--merged [<commit>]] [--no-merged [<commit>]]"),
N_("git for-each-ref [--contains [<commit>]] [--no-contains [<commit>]]"),
N_("git for-each-ref [--start-after <marker>]"),
NULL
};

int cmd_for_each_ref(int argc,
const char **argv,
const char *prefix,
struct repository *repo)
int for_each_ref_core(int argc, const char **argv, const char *prefix, struct repository *repo, const char *const *usage)
{
struct ref_sorting *sorting;
struct string_list sorting_options = STRING_LIST_INIT_DUP;
Expand Down Expand Up @@ -70,17 +59,17 @@ int cmd_for_each_ref(int argc,
/* Set default (refname) sorting */
string_list_append(&sorting_options, "refname");

parse_options(argc, argv, prefix, opts, for_each_ref_usage, 0);
parse_options(argc, argv, prefix, opts, usage, 0);
if (format.array_opts.max_count < 0) {
error("invalid --count argument: `%d'", format.array_opts.max_count);
usage_with_options(for_each_ref_usage, opts);
usage_with_options(usage, opts);
}
if (HAS_MULTI_BITS(format.quote_style)) {
error("more than one quoting style?");
usage_with_options(for_each_ref_usage, opts);
usage_with_options(usage, opts);
}
if (verify_ref_format(&format))
usage_with_options(for_each_ref_usage, opts);
usage_with_options(usage, opts);

if (filter.start_after && sorting_options.nr > 1)
die(_("cannot use --start-after with custom sort options"));
Expand Down Expand Up @@ -120,3 +109,16 @@ int cmd_for_each_ref(int argc,
strvec_clear(&vec);
return 0;
}

int cmd_for_each_ref(int argc,
const char **argv,
const char *prefix,
struct repository *repo)
{
static char const * const for_each_ref_usage[] = {
N_("git for-each-ref " COMMON_USAGE_FOR_EACH_REF),
NULL
};

return for_each_ref_core(argc, argv, prefix, repo, for_each_ref_usage);
}
Loading