ref-filter: add %(rest) atom

%(rest) is a atom used for cat-file batch mode, which can split
the input lines at the first whitespace boundary, all characters
before that whitespace are considered to be the object name;
characters after that first run of whitespace (i.e., the "rest"
of the line) are output in place of the %(rest) atom.

In order to let "cat-file --batch=%(rest)" use the ref-filter
interface, add %(rest) atom for ref-filter.

Introduce the reject_atom() to reject the atom %(rest) for
"git for-each-ref", "git branch", "git tag" and "git verify-tag".

Reviewed-by: Jacob Keller <jacob.keller@gmail.com>
Suggected-by: Jacob Keller <jacob.keller@gmail.com>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Hariom Verma <hariom18599@gmail.com>
Signed-off-by: ZheNing Hu <adlternative@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
ZheNing Hu
2021-07-26 03:26:50 +00:00
committed by Junio C Hamano
parent e85fcb355a
commit b9dee075eb
6 changed files with 45 additions and 1 deletions

View File

@ -38,6 +38,7 @@ struct ref_sorting {
struct ref_array_item {
struct object_id objectname;
const char *rest;
int flag;
unsigned int kind;
const char *symref;
@ -76,14 +77,16 @@ struct ref_format {
* verify_ref_format() afterwards to finalize.
*/
const char *format;
const char *rest;
int quote_style;
int use_rest;
int use_color;
/* Internal state to ref-filter */
int need_color_reset_at_eol;
};
#define REF_FORMAT_INIT { NULL, 0, -1 }
#define REF_FORMAT_INIT { .use_color = -1 }
/* Macros for checking --merged and --no-merged options */
#define _OPT_MERGED_NO_MERGED(option, filter, h) \