git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Witten <mfwitten@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH 4/4] Clean: Remove useless parameters from both get_commit_info() functions
Date: Fri, 11 Feb 2011 17:48:17 +0000	[thread overview]
Message-ID: <d92be3a1-6f30-4b04-ac38-39058e5a6959-mfwitten@gmail.com> (raw)
In-Reply-To: <1fbceaa8-398c-44ec-8833-a03e4cca6805-mfwitten@gmail.com>

Both `builtin/blame.c' and `reflog-walk.c' have static get_commit_info()
functions:

    $ echo; git grep get_commit_info 7811d9600f02e70c9f835719c71156c967a684f7 | cut -c42-

    builtin/blame.c:static void get_commit_info(struct commit *commit,
    builtin/blame.c:	get_commit_info(suspect->commit, &ci, 1);
    builtin/blame.c:	get_commit_info(suspect->commit, &ci, 1);
    builtin/blame.c:			get_commit_info(suspect->commit, &ci, 1);
    reflog-walk.c:static struct commit_info *get_commit_info(struct commit *commit,
    reflog-walk.c:		get_commit_info(commit, &info->reflogs, 0);

Every time one of the get_commit_info() functions is called, the
last parameter is invariably set to the same constant, rendering that
parameter effectively useless.

This commit removes those last parameters and updates the function bodies
and calls accordingly.

Signed-off-by: Michael Witten <mfwitten@gmail.com>
---
 builtin/blame.c |   14 ++++----------
 reflog-walk.c   |   18 ++++--------------
 2 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index f6b03f7..5b5fc6a 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1413,8 +1413,7 @@ static void get_ac_line(const char *inbuf, const char *what,
 }
 
 static void get_commit_info(struct commit *commit,
-			    struct commit_info *ret,
-			    int detailed)
+			    struct commit_info *ret)
 {
 	int len;
 	const char *subject;
@@ -1447,11 +1446,6 @@ static void get_commit_info(struct commit *commit,
 		    sizeof(author_mail), author_mail,
 		    &ret->author_time, &ret->author_tz);
 
-	if (!detailed) {
-		free(reencoded);
-		return;
-	}
-
 	ret->committer = committer_name;
 	ret->committer_mail = committer_mail;
 	get_ac_line(message, "\ncommitter ",
@@ -1493,7 +1487,7 @@ static int emit_one_suspect_detail(struct origin *suspect)
 		return 0;
 
 	suspect->commit->object.flags |= METAINFO_SHOWN;
-	get_commit_info(suspect->commit, &ci, 1);
+	get_commit_info(suspect->commit, &ci);
 	printf("author %s\n", ci.author);
 	printf("author-mail %s\n", ci.author_mail);
 	printf("author-time %lu\n", ci.author_time);
@@ -1664,7 +1658,7 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
 	char hex[41];
 	int show_raw_time = !!(opt & OUTPUT_RAW_TIMESTAMP);
 
-	get_commit_info(suspect->commit, &ci, 1);
+	get_commit_info(suspect->commit, &ci);
 	strcpy(hex, sha1_to_hex(suspect->commit->object.sha1));
 
 	cp = nth_line(sb, ent->lno);
@@ -1850,7 +1844,7 @@ static void find_alignment(struct scoreboard *sb, int *option)
 			longest_file = num;
 		if (!(suspect->commit->object.flags & METAINFO_SHOWN)) {
 			suspect->commit->object.flags |= METAINFO_SHOWN;
-			get_commit_info(suspect->commit, &ci, 1);
+			get_commit_info(suspect->commit, &ci);
 			if (*option & OUTPUT_SHOW_EMAIL)
 				num = utf8_strwidth(ci.author_mail);
 			else
diff --git a/reflog-walk.c b/reflog-walk.c
index 5d81d39..3357331 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -87,22 +87,12 @@ struct commit_info_lifo {
 };
 
 static struct commit_info *get_commit_info(struct commit *commit,
-		struct commit_info_lifo *lifo, int pop)
+		struct commit_info_lifo *lifo)
 {
 	int i;
 	for (i = 0; i < lifo->nr; i++)
-		if (lifo->items[i].commit == commit) {
-			struct commit_info *result = &lifo->items[i];
-			if (pop) {
-				if (i + 1 < lifo->nr)
-					memmove(lifo->items + i,
-						lifo->items + i + 1,
-						(lifo->nr - i) *
-						sizeof(struct commit_info));
-				lifo->nr--;
-			}
-			return result;
-		}
+		if (lifo->items[i].commit == commit)
+			return &lifo->items[i];
 	return NULL;
 }
 
@@ -214,7 +204,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
 void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
 {
 	struct commit_info *commit_info =
-		get_commit_info(commit, &info->reflogs, 0);
+		get_commit_info(commit, &info->reflogs);
 	struct commit_reflog *commit_reflog;
 	struct reflog_info *reflog;
 
-- 
1.7.4.18.g68fe8

  reply	other threads:[~2011-03-30 17:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-30 16:13 [PATCH 0/4] Miscellaneous Improvements Michael Witten
2011-02-22 17:15 ` [PATCH 1/4] Typos: t/README Michael Witten
2011-02-15 23:12   ` [PATCH 2/4] Clean: Remove superfluous strbuf 'docs' Michael Witten
2011-03-02 15:25     ` [PATCH 3/4] Clean: Remove unnecessary `\' (line continuation) Michael Witten
2011-02-11 17:48       ` Michael Witten [this message]
2011-03-30 19:21       ` Junio C Hamano
2011-03-30 18:58   ` [PATCH 1/4] Typos: t/README Junio C Hamano
2011-03-30 19:02     ` Michael Witten

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

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

  git send-email \
    --in-reply-to=d92be3a1-6f30-4b04-ac38-39058e5a6959-mfwitten@gmail.com \
    --to=mfwitten@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
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 NNTP newsgroup(s).