* Re: [PATCH] Prefer fgetc over fgets where possible
2023-07-17 15:38 [PATCH] Prefer fgetc over fgets where possible AtariDreams via GitGitGadget
@ 2023-07-17 16:51 ` Junio C Hamano
2023-07-17 20:14 ` Taylor Blau
2024-12-18 1:16 ` [PATCH v2] " AreaZR via GitGitGadget
2 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2023-07-17 16:51 UTC (permalink / raw)
To: AtariDreams via GitGitGadget; +Cc: git, Seija Kijin
"AtariDreams via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Seija Kijin <doremylover123@gmail.com>
>
> fputc is meant for single characters,
> fputs is for strings. We are better off
> inserting sole \n characters as
> characters, not whole strings.
I do not see if these short lines are deliberate; are they meant to
follow some sort of poetry styles?
In any case, while the above is correct, I do not see the patch
noise is worth it in this particular case. Yes, if we are writing
code snippets shown with the context in these hunks afresh, please
carefully choose between fputs() and fputc(). But once the code is
written and it is in, it is not worth to go back and fix it, unless
we are fixing surrounding area and doing the clean-up as a "while at
it" change.
By the way, because my mail program warned against an address that
apparently refuses to receive any replies, I had to manually remove
"AtariDreams <83477269+AtariDreams@users.noreply.github.com>" while
composing this message. I'd appreciate it if you arrange to ensure
that your next patch will not have such addresses on your CC: line.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] Prefer fgetc over fgets where possible
2023-07-17 15:38 [PATCH] Prefer fgetc over fgets where possible AtariDreams via GitGitGadget
2023-07-17 16:51 ` Junio C Hamano
2023-07-17 20:14 ` Taylor Blau
@ 2024-12-18 1:16 ` AreaZR via GitGitGadget
2 siblings, 0 replies; 4+ messages in thread
From: AreaZR via GitGitGadget @ 2024-12-18 1:16 UTC (permalink / raw)
To: git; +Cc: AreaZR, Seija Kijin
From: Seija Kijin <doremylover123@gmail.com>
fputc is meant for single characters,
fputs is for strings. We are better off
inserting sole \n characters as
characters, not whole strings.
Signed-off-by: Seija Kijin doremylover123@gmail.com
---
Prefer fgetc over fgets where possible
fputc is meant for single characters, fputs is for strings. We are
better off inserting sole \n characters as characters, not whole
strings.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1550%2FAreaZR%2Ffgetc-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1550/AreaZR/fgetc-v2
Pull-Request: https://github.com/git/git/pull/1550
Range-diff vs v1:
1: f833a7cc857 ! 1: 26f329befbd Prefer fgetc over fgets where possible
@@ Commit message
Signed-off-by: Seija Kijin doremylover123@gmail.com
+ ## bisect.c ##
+@@ bisect.c: static void show_list(const char *debug, int counted, int nr,
+ subject_len = find_commit_subject(buf, &subject_start);
+ if (subject_len)
+ fprintf(stderr, " %.*s", subject_len, subject_start);
+- fprintf(stderr, "\n");
++ fputc('\n', stderr);
+ }
+ }
+
+
+ ## commit-graph.c ##
+@@ commit-graph.c: static void graph_report(const char *fmt, ...)
+ verify_commit_graph_error = 1;
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+- fprintf(stderr, "\n");
++ fputc('\n', stderr);
+ va_end(ap);
+ }
+
+
## wt-status.c ##
@@ wt-status.c: static void wt_longstatus_print_tracking(struct wt_status *s)
- color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c",
- comment_line_char);
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%s",
+ comment_line_str);
else
- fputs("\n", s->fp);
+ fputc('\n', s->fp);
bisect.c | 2 +-
commit-graph.c | 2 +-
wt-status.c | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/bisect.c b/bisect.c
index d71c4e4b44b..3b1e034013f 100644
--- a/bisect.c
+++ b/bisect.c
@@ -179,7 +179,7 @@ static void show_list(const char *debug, int counted, int nr,
subject_len = find_commit_subject(buf, &subject_start);
if (subject_len)
fprintf(stderr, " %.*s", subject_len, subject_start);
- fprintf(stderr, "\n");
+ fputc('\n', stderr);
}
}
diff --git a/commit-graph.c b/commit-graph.c
index e2e2083951c..b649598916a 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -2696,7 +2696,7 @@ static void graph_report(const char *fmt, ...)
verify_commit_graph_error = 1;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
+ fputc('\n', stderr);
va_end(ap);
}
diff --git a/wt-status.c b/wt-status.c
index 6a8c05d1cff..75b8e900a4c 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1227,7 +1227,7 @@ static void wt_longstatus_print_tracking(struct wt_status *s)
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%s",
comment_line_str);
else
- fputs("\n", s->fp);
+ fputc('\n', s->fp);
strbuf_release(&sb);
}
@@ -1832,7 +1832,7 @@ static void wt_longstatus_print_state(struct wt_status *s)
if (state->merge_in_progress) {
if (state->rebase_interactive_in_progress) {
show_rebase_information(s, state_color);
- fputs("\n", s->fp);
+ fputc('\n', s->fp);
}
show_merge_in_progress(s, state_color);
} else if (state->am_in_progress)
base-commit: 063bcebf0c917140ca0e705cbe0fdea127e90086
--
gitgitgadget
^ permalink raw reply related [flat|nested] 4+ messages in thread