Skip to content

Improvements to ref-filter

Hariom Verma via GitGitGadget git 4 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest8 patches 0 repliesNew
  2. v39 patches 8 repliesSuperseded
  3. v29 patches 2 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v15 patches6 repliesSuperseded

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8ref-filter: support different email formatsDocumentation/git-for-each-ref.txt ref-filter.c t/t6300-for-each-ref.sh+65 -100 replies
2/8ref-filter: refactor `grab_objectname()`ref-filter.c+21 -150 replies
3/8ref-filter: modify error messages in `grab_objectname()`ref-filter.c+2 -20 replies
4/8ref-filter: rename `objectname` related functions and fieldsref-filter.c+20 -200 replies
5/8ref-filter: add `short` modifier to 'tree' atomDocumentation/git-for-each-ref.txt ref-filter.c t/t6300-for-each-ref.sh+12 -50 replies
6/8ref-filter: add `short` modifier to 'parent' atomDocumentation/git-for-each-ref.txt ref-filter.c t/t6300-for-each-ref.sh+11 -50 replies
7/8pretty: refactor `format_sanitized_subject()`pretty.c pretty.h+14 -90 replies
8/8ref-filter: add `sanitize` option for 'subject' atomDocumentation/git-for-each-ref.txt ref-filter.c t/t6300-for-each-ref.sh+25 -80 replies

Reviews trailers per patch

None of the 8 patches has a Reviewed-by or Acked-by.

PatchChristian CouderHeba Waly
1/8Mentored-by Mentored-by
2/8Mentored-by Mentored-by
3/8Mentored-by Mentored-by
4/8Mentored-by Mentored-by
5/8Mentored-by Mentored-by
6/8Mentored-by Mentored-by
7/8Mentored-by Mentored-by
8/8Mentored-by Mentored-by

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/8] [GSoC] Improvements to ref-filter

This is the first patch series that introduces some improvements and features to file ref-filter.{c,h}. These changes are useful to ref-filter, but in near future also will allow us to use ref-filter's logic in pretty.c

I plan to add more to format-support.{c,h} in the upcoming patch series. That will lead to more improved and feature-rich ref-filter.c

Hariom Verma (8):
ref-filter: support different email formats
ref-filter: refactor grab_objectname()
ref-filter: modify error messages in grab_objectname()
ref-filter: rename objectname related functions and fields
ref-filter: add short modifier to 'tree' atom
ref-filter: add short modifier to 'parent' atom
pretty: refactor format_sanitized_subject()
ref-filter: add sanitize option for 'subject' atom

 Documentation/git-for-each-ref.txt |  10 +-
 pretty.c                           |  20 ++--
 pretty.h                           |   3 +
 ref-filter.c                       | 158 +++++++++++++++++++----------
 t/t6300-for-each-ref.sh            |  35 +++++++
 5 files changed, 161 insertions(+), 65 deletions(-)

base-commit: 675a4aaf3b226c0089108221b96559e0baae5de9
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-684%2Fharry-hov%2Fonly-rf6-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-684/harry-hov/only-rf6-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/684

Range-diff vs v3:

  1:  3e6fc66a46 =  1:  55618fe4c1 ref-filter: support different email formats
  2:  5268b973da =  2:  c508c96eb8 ref-filter: refactor `grab_objectname()`
  3:  4a12ff8210 =  3:  582f00ace6 ref-filter: modify error messages in `grab_objectname()`
  4:  d53ca56778 =  4:  503a1874ce ref-filter: rename `objectname` related functions and fields
  5:  fd4ed82e80 =  5:  6b97166796 ref-filter: add `short` modifier to 'tree' atom
  6:  7a039823de =  6:  5ed5ac259d ref-filter: add `short` modifier to 'parent' atom
  7:  0ad22c7cdd !  7:  6105046d96 pretty: refactor `format_sanitized_subject()`
     @@ Commit message
          of `\n` in a variable `eol` and passed it in
          `format_sanitized_subject()`. And the loop runs upto `eol`.
      
     -    But this change isn't sufficient to reuse this function in
     -    ref-filter.c because there exist tags with multiline subject.
     -
     -    It's wise to replace `\n` with ' ', if `format_sanitized_subject()`
     -    encounters `\n` before end of subject line, just like `copy_subject()`.
     -    Because we'll be only using `format_sanitized_subject()` for
     -    "%(subject:sanitize)", instead of `copy_subject()` and
     -    `format_sanitized_subject()` both. So, added the code:
     -    ```
     -    if (char == '\n') /* never true if called inside pretty.c */
     -        char = ' ';
     -    ```
     -
     -    Now, it's ready to be reused in ref-filter.c
     -
          Mentored-by: Christian Couder <[email protected]>
          Mentored-by: Heba Waly <[email protected]>
          Signed-off-by: Hariom Verma <[email protected]>
     @@ pretty.c: static int istitlechar(char c)
       }
       
      -static void format_sanitized_subject(struct strbuf *sb, const char *msg)
     -+static void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len)
     ++void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len)
       {
     -+	char *r = xmemdupz(msg, len);
       	size_t trimlen;
       	size_t start_len = sb->len;
       	int space = 2;
     @@ pretty.c: static int istitlechar(char c)
      -	for (; *msg && *msg != '\n'; msg++) {
      -		if (istitlechar(*msg)) {
      +	for (i = 0; i < len; i++) {
     -+		if (r[i] == '\n')
     -+			r[i] = ' ';
     -+		if (istitlechar(r[i])) {
     ++		if (istitlechar(msg[i])) {
       			if (space == 1)
       				strbuf_addch(sb, '-');
       			space = 0;
     @@ pretty.c: static int istitlechar(char c)
      -			if (*msg == '.')
      -				while (*(msg+1) == '.')
      -					msg++;
     -+			strbuf_addch(sb, r[i]);
     -+			if (r[i] == '.')
     -+				while (r[i+1] == '.')
     ++			strbuf_addch(sb, msg[i]);
     ++			if (msg[i] == '.')
     ++				while (msg[i+1] == '.')
      +					i++;
       		} else
       			space |= 1;
       	}
     -+	free(r);
     - 
     - 	/* trim any trailing '.' or '-' characters */
     - 	trimlen = 0;
      @@ pretty.c: static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
       	const struct commit *commit = c->commit;
       	const char *msg = c->message;
     @@ pretty.c: static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
       		return 1;
       	case 'b':	/* body */
       		strbuf_addstr(sb, msg + c->body_off);
     +
     + ## pretty.h ##
     +@@ pretty.h: const char *format_subject(struct strbuf *sb, const char *msg,
     + /* Check if "cmit_fmt" will produce an empty output. */
     + int commit_format_is_empty(enum cmit_fmt);
     + 
     ++/* Make subject of commit message suitable for filename */
     ++void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len);
     ++
     + #endif /* PRETTY_H */
  8:  7a64495f99 <  -:  ---------- format-support: move `format_sanitized_subject()` from pretty
  9:  1ab35e9251 !  8:  7cba8d7a28 ref-filter: add `sanitize` option for 'subject' atom

@@ Documentation/git-for-each-ref.txt: contents:subject::
The remainder of the commit or the tag message that follows

## ref-filter.c ##
-@@
- #include "worktree.h"
- #include "hashmap.h"
- #include "strvec.h"
-+#include "format-support.h"
-
- static struct ref_msg {
- const char *gone;
@@ ref-filter.c: static struct used_atom {
unsigned int nobracket : 1, push : 1, push_remote : 1;
} remote_ref;

Signature · 1 line
gitgitgadget