[PATCH 4/4] Clean: Remove useless parameters from both get_commit_info() functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]