[PATCH 1/2] reflog: drop usage of global variables

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

 



The 'builtin/reflog.c' file uses the 'the_repository' global variable
directly and also via 'git_config()'. Since this is a builtin command
which has access to the 'struct repository', drop usage of the global
variable and use the available repository struct.

With this, remove the 'USE_THE_REPOSITORY_VARIABLE' macro from the file.

Signed-off-by: Karthik Nayak <karthik.188@xxxxxxxxx>
---
 builtin/reflog.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/builtin/reflog.c b/builtin/reflog.c
index 95f264989b..f92258f6b6 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -1,5 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
-
 #include "builtin.h"
 #include "config.h"
 #include "gettext.h"
@@ -236,7 +234,7 @@ static int expire_total_callback(const struct option *opt,
 }
 
 static int cmd_reflog_show(int argc, const char **argv, const char *prefix,
-			   struct repository *repo UNUSED)
+			   struct repository *repo)
 {
 	struct option options[] = {
 		OPT_END()
@@ -246,7 +244,7 @@ static int cmd_reflog_show(int argc, const char **argv, const char *prefix,
 		      PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_ARGV0 |
 		      PARSE_OPT_KEEP_UNKNOWN_OPT);
 
-	return cmd_log_reflog(argc, argv, prefix, the_repository);
+	return cmd_log_reflog(argc, argv, prefix, repo);
 }
 
 static int show_reflog(const char *refname, void *cb_data UNUSED)
@@ -256,7 +254,7 @@ static int show_reflog(const char *refname, void *cb_data UNUSED)
 }
 
 static int cmd_reflog_list(int argc, const char **argv, const char *prefix,
-			   struct repository *repo UNUSED)
+			   struct repository *repo)
 {
 	struct option options[] = {
 		OPT_END()
@@ -268,13 +266,13 @@ static int cmd_reflog_list(int argc, const char **argv, const char *prefix,
 		return error(_("%s does not accept arguments: '%s'"),
 			     "list", argv[0]);
 
-	ref_store = get_main_ref_store(the_repository);
+	ref_store = get_main_ref_store(repo);
 
 	return refs_for_each_reflog(ref_store, show_reflog, NULL);
 }
 
 static int cmd_reflog_expire(int argc, const char **argv, const char *prefix,
-			     struct repository *repo UNUSED)
+			     struct repository *repo)
 {
 	struct cmd_reflog_expire_cb cmd = { 0 };
 	timestamp_t now = time(NULL);
@@ -310,7 +308,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix,
 
 	default_reflog_expire_unreachable = now - 30 * 24 * 3600;
 	default_reflog_expire = now - 90 * 24 * 3600;
-	git_config(reflog_expire_config, NULL);
+	repo_config(repo, reflog_expire_config, NULL);
 
 	save_commit_buffer = 0;
 	do_all = status = 0;
@@ -332,7 +330,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix,
 	if (cmd.stalefix) {
 		struct rev_info revs;
 
-		repo_init_revisions(the_repository, &revs, prefix);
+		repo_init_revisions(repo, &revs, prefix);
 		revs.do_not_die_on_missing_objects = 1;
 		revs.ignore_missing = 1;
 		revs.ignore_missing_links = 1;
@@ -368,7 +366,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix,
 			};
 
 			set_reflog_expiry_param(&cb.cmd,  item->string);
-			status |= refs_reflog_expire(get_main_ref_store(the_repository),
+			status |= refs_reflog_expire(get_main_ref_store(repo),
 						     item->string, flags,
 						     reflog_expiry_prepare,
 						     should_prune_fn,
@@ -382,12 +380,12 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix,
 		char *ref;
 		struct expire_reflog_policy_cb cb = { .cmd = cmd };
 
-		if (!repo_dwim_log(the_repository, argv[i], strlen(argv[i]), NULL, &ref)) {
+		if (!repo_dwim_log(repo, argv[i], strlen(argv[i]), NULL, &ref)) {
 			status |= error(_("%s points nowhere!"), argv[i]);
 			continue;
 		}
 		set_reflog_expiry_param(&cb.cmd, ref);
-		status |= refs_reflog_expire(get_main_ref_store(the_repository),
+		status |= refs_reflog_expire(get_main_ref_store(repo),
 					     ref, flags,
 					     reflog_expiry_prepare,
 					     should_prune_fn,
@@ -430,7 +428,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix,
 }
 
 static int cmd_reflog_exists(int argc, const char **argv, const char *prefix,
-			     struct repository *repo UNUSED)
+			     struct repository *repo)
 {
 	struct option options[] = {
 		OPT_END()
@@ -445,7 +443,7 @@ static int cmd_reflog_exists(int argc, const char **argv, const char *prefix,
 	refname = argv[0];
 	if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))
 		die(_("invalid ref format: %s"), refname);
-	return !refs_reflog_exists(get_main_ref_store(the_repository),
+	return !refs_reflog_exists(get_main_ref_store(repo),
 				   refname);
 }
 

-- 
2.48.1





[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]

  Powered by Linux