git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"René Scharfe" <l.s.r@web.de>, "Git List" <git@vger.kernel.org>
Subject: Re: [PATCH 2/2] avoid using sha1_to_hex output as printf format
Date: Fri, 08 Jul 2016 10:09:28 -0700	[thread overview]
Message-ID: <xmqqeg74m4zb.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <xmqqinwgm5aa.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Fri, 08 Jul 2016 10:02:53 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> As to the hunk to commit.c that was dropped in this round, the only
> caller of print_commit_list() is bisect.c, and it passes "%s\n" to
> format_cur and format_last, it seems, so that suggests a more
> obvious direction for cleaning things up, I would say.

And the result is a pleasing diffstat.

-- >8 --
Subject: commit.c: remove print_commit_list()

The helper function tries to offer a way to conveniently show the
last one differently from others, presumably to allow you to say
something like

	A, B, and C.

while iterating over a list that has these three elements.

However, there is only one caller, and it passes the same format
string "%s\n" for both the last one and the other ones.  Retire the
helper function and update the caller with a simplified version.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 bisect.c |  5 ++++-
 commit.c | 10 ----------
 commit.h |  4 ----
 3 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/bisect.c b/bisect.c
index dc13319..02f76f0 100644
--- a/bisect.c
+++ b/bisect.c
@@ -646,7 +646,10 @@ static void exit_if_skipped_commits(struct commit_list *tried,
 
 	printf("There are only 'skip'ped commits left to test.\n"
 	       "The first %s commit could be any of:\n", term_bad);
-	print_commit_list(tried, "%s\n", "%s\n");
+
+	for ( ; tried; tried = tried->next)
+		printf("%s\n", oid_to_hex(&tried->item->object.oid));
+
 	if (bad)
 		printf("%s\n", oid_to_hex(bad));
 	printf("We cannot bisect more!\n");
diff --git a/commit.c b/commit.c
index 3f4f371..bf27972 100644
--- a/commit.c
+++ b/commit.c
@@ -1617,16 +1617,6 @@ struct commit_list **commit_list_append(struct commit *commit,
 	return &new->next;
 }
 
-void print_commit_list(struct commit_list *list,
-		       const char *format_cur,
-		       const char *format_last)
-{
-	for ( ; list; list = list->next) {
-		const char *format = list->next ? format_cur : format_last;
-		printf(format, oid_to_hex(&list->item->object.oid));
-	}
-}
-
 const char *find_commit_header(const char *msg, const char *key, size_t *out_len)
 {
 	int key_len = strlen(key);
diff --git a/commit.h b/commit.h
index 78ed513..71693ce 100644
--- a/commit.h
+++ b/commit.h
@@ -376,10 +376,6 @@ extern int parse_signed_commit(const struct commit *commit,
 			       struct strbuf *message, struct strbuf *signature);
 extern int remove_signature(struct strbuf *buf);
 
-extern void print_commit_list(struct commit_list *list,
-			      const char *format_cur,
-			      const char *format_last);
-
 /*
  * Check the signature of the given commit. The result of the check is stored
  * in sig->check_result, 'G' for a good signature, 'U' for a good signature

  reply	other threads:[~2016-07-08 17:09 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-07 20:02 [PATCH] am: ignore return value of write_file() René Scharfe
2016-07-07 20:31 ` Jeff King
2016-07-08  6:37   ` Johannes Schindelin
2016-07-08  6:56     ` Jeff King
2016-07-08  9:04       ` [PATCH 0/8] write_file cleanups Jeff King
2016-07-08  9:06         ` [PATCH 1/8] config: fix bogus fd check when setting up default config Jeff King
2016-07-08  9:08         ` [PATCH 2/8] am: ignore return value of write_file() Jeff King
2016-07-08  9:08         ` [PATCH 3/8] branch: use non-gentle write_file for branch description Jeff King
2016-07-08  9:09         ` [PATCH 4/8] write_file: drop "gently" form Jeff King
2016-07-08  9:10         ` [PATCH 5/8] write_file: use xopen Jeff King
2016-07-08  9:12         ` [PATCH 6/8] write_file: add pointer+len variant Jeff King
2016-07-08  9:12         ` [PATCH 7/8] write_file: add format attribute Jeff King
2016-07-08  9:25           ` Jeff King
2016-07-08  9:25             ` [PATCH 1/2] walker: let walker_say take arbitrary formats Jeff King
2016-07-08  9:25             ` [PATCH 2/2] avoid using sha1_to_hex output as printf format Jeff King
2016-07-08 10:35               ` Jeff King
2016-07-08 17:02                 ` Junio C Hamano
2016-07-08 17:09                   ` Junio C Hamano [this message]
2016-07-08 21:41                     ` Jeff King
2016-07-08  9:12         ` [PATCH 8/8] use write_file_buf where applicable Jeff King
2016-07-08  9:16         ` [PATCH 9/8] branch: use write_file_buf instead of write_file Jeff King
2016-07-08 18:44         ` [PATCH 0/8] write_file cleanups René Scharfe
2016-07-09 14:24       ` [PATCH] am: ignore return value of write_file() Johannes Schindelin
2016-07-10 10:53         ` Johannes Schindelin
2016-07-08  6:33 ` Johannes Schindelin
2016-07-08 18:44   ` René Scharfe
2016-07-08 21:51     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqeg74m4zb.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=l.s.r@web.de \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).