Skip to contentSkip to conversation

bundle-uri: replace printf with fprintf in print_bundle_uri function

PATCH In review Jan Mazur via GitGitGadget 2 participants 3 messages Jun 4, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bundle-uri: replace printf with fprintf in print_bundle_uri function

From: Jan Mazur <[email protected]>

---
bundle-uri: replace printf with fprintf in print_bundle_uri function

Small fix to bundle-uri convenience debug function.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1985%2Fmzr%2Fbundle_uri__print_bundle_list_fix-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1985/mzr/bundle_uri__print_bundle_list_fix-v1
Pull-Request: https://github.com/git/git/pull/1985

 bundle-uri.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bundle-uri.c +1 -1
index 9accf157b44..c9d65aa0ce8 100644
@@ -122,7 +122,7 @@ void print_bundle_list(FILE *fp, struct bundle_list *list)
 		int i;
 		for (i = 0; i < BUNDLE_HEURISTIC__COUNT; i++) {
 			if (heuristics[i].heuristic == list->heuristic) {
-				printf("\theuristic = %s\n",
+				fprintf(fp, "\theuristic = %s\n",
 				       heuristics[list->heuristic].name);
 				break;
 			}

base-commit: b07857f7dcffee4d3b428df8dce6c9b49a57c9c1

Signature · 1 line
gitgitgadget
#1 lore raw
Quoted 1 line · Jan Mazur via GitGitGadget

Subject: [PATCH] bundle-uri: replace printf with fprintf in print_bundle_uri function

That says _what_ the patch does. We care more deeply about _why_ it is a good idea for a patch to do so. And ...

Quoted 1 line

From: Jan Mazur <[email protected]>

... there is nothing described here.

Quoted 1 line

Something like this, perhaps?

Subject: [PATCH] bundle-uri: send debug output to given FILE * stream

d796cedb (bundle-uri: unit test "key=value" parsing, 2022-10-12) introduced the print_bundle_list() function, which takes a "FILE *fp" to write the output to. Later with c93c3d2f (bundle-uri:
parse bundle.heuristic=creationToken, 2023-01-31) the function started showing additional information, which is always written to the standard output stream.

It does not look like a deliberate decision to do so, and it does not hurt, as all callers of the function passes stdout to it.

We could change the function not to take fp and always write to the standard output to simplify, but let's use the FILE *fp provided by the caller consistently to write out output.

The change the patch makes looks obviously correct.

Thanks.

Quoted 27 lines

---
bundle-uri: replace printf with fprintf in print_bundle_uri function

Small fix to bundle-uri convenience debug function.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1985%2Fmzr%2Fbundle_uri__print_bundle_list_fix-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1985/mzr/bundle_uri__print_bundle_list_fix-v1
Pull-Request: https://github.com/git/git/pull/1985

 bundle-uri.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bundle-uri.c +1 -1
index 9accf157b44..c9d65aa0ce8 100644
@@ -122,7 +122,7 @@ void print_bundle_list(FILE *fp, struct bundle_list *list)
 		int i;
 		for (i = 0; i < BUNDLE_HEURISTIC__COUNT; i++) {
 			if (heuristics[i].heuristic == list->heuristic) {
-				printf("\theuristic = %s\n",
+				fprintf(fp, "\theuristic = %s\n",
 				       heuristics[list->heuristic].name);
 				break;
 			}

base-commit: b07857f7dcffee4d3b428df8dce6c9b49a57c9c1

#2 lore raw

PATCH v2 1/1 bundle-uri: send debug output to given FILE * stream

In reply to Jan Mazur via GitGitGadget

From: Jan Mazur <[email protected]>

d796cedb (bundle-uri: unit test "key=value" parsing, 2022-10-12) introduced the print_bundle_list() function, which takes a "FILE *fp" to write the output to. Later with c93c3d2f (bundle-uri:
parse bundle.heuristic=creationToken, 2023-01-31) the function started showing additional information, which is always written to the standard output stream.

It does not look like a deliberate decision to do so, and it does not hurt, as all callers of the function passes stdout to it.

We could change the function not to take fp and always write to the standard output to simplify, but let's use the FILE *fp provided by the caller consistently to write out output.

---
bundle-uri: send debug output to given FILE * stream

Small fix to bundle-uri convenience debug function.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1985%2Fmzr%2Fbundle_uri__print_bundle_list_fix-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1985/mzr/bundle_uri__print_bundle_list_fix-v2
Pull-Request: https://github.com/git/git/pull/1985

Range-diff vs v1:

1: 83cbf182253 ! 1: 38f05164811 bundle-uri: replace printf with fprintf in print_bundle_uri function
@@ Metadata
Author: Jan Mazur <[email protected]>

## Commit message ##
- bundle-uri: replace printf with fprintf in print_bundle_uri function
+ bundle-uri: send debug output to given FILE * stream
+
+ d796cedb (bundle-uri: unit test "key=value" parsing, 2022-10-12)
+ introduced the print_bundle_list() function, which takes a "FILE
+ *fp" to write the output to. Later with c93c3d2f (bundle-uri:
+ parse bundle.heuristic=creationToken, 2023-01-31) the function
+ started showing additional information, which is always written
+ to the standard output stream.
+
+ It does not look like a deliberate decision to do so, and it
+ does not hurt, as all callers of the function passes stdout to
+ it.
+
+ We could change the function not to take fp and always write to
+ the standard output to simplify, but let's use the FILE *fp
+ provided by the caller consistently to write out output.

 bundle-uri.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bundle-uri.c +1 -1
index 9accf157b44..c9d65aa0ce8 100644
@@ -122,7 +122,7 @@ void print_bundle_list(FILE *fp, struct bundle_list *list)
 		int i;
 		for (i = 0; i < BUNDLE_HEURISTIC__COUNT; i++) {
 			if (heuristics[i].heuristic == list->heuristic) {
-				printf("\theuristic = %s\n",
+				fprintf(fp, "\theuristic = %s\n",
 				       heuristics[list->heuristic].name);
 				break;
 			}

base-commit: b07857f7dcffee4d3b428df8dce6c9b49a57c9c1

Signature · 1 line
gitgitgadget