Skip to contentSkip to conversation

Move deny_non_fast_forwards handling completely into receive-pack.

PATCH In review Shawn Pearce 2 participants 2 messages Aug 11, 2016

lore
Share & tools
lore
#1 lore raw
In reply to Shawn Pearce
Quoted 5 lines · Shawn Pearce

The 'receive.denynonfastforwards' option has nothing to do with the repository format version. Since receive-pack already uses git_config to initialize itself before executing any updates we can use the normal configuration strategy and isolate the receive specific variables away from the core variables.

Sounds sane. Thanks.

#0 lore raw

PATCH 1/1 Move deny_non_fast_forwards handling completely into receive-pack.

The 'receive.denynonfastforwards' option has nothing to do with the repository format version. Since receive-pack already uses git_config to initialize itself before executing any updates we can use the normal configuration strategy and isolate the receive specific variables away from the core variables.

---
 cache.h        |    1 -
 environment.c  |    1 -
 receive-pack.c |   16 +++++++++++++++-
 setup.c        |    2 --
 4 files changed, 15 insertions(+), 5 deletions(-)
cache.h +0 -1
index a360528..e997a85 100644
@@ -189,7 +189,6 @@ extern int prefer_symlink_refs;
 extern int log_all_ref_updates;
 extern int warn_ambiguous_refs;
 extern int shared_repository;
-extern int deny_non_fast_forwards;
 extern const char *apply_default_whitespace;
 extern int zlib_compression_level;
 
environment.c +0 -1
index 63b1d15..84d870c 100644
@@ -20,7 +20,6 @@ int warn_ambiguous_refs = 1;
 int repository_format_version;
 char git_commit_encoding[MAX_ENCODING_LENGTH] = "utf-8";
 int shared_repository = PERM_UMASK;
-int deny_non_fast_forwards = 0;
 const char *apply_default_whitespace;
 int zlib_compression_level = Z_DEFAULT_COMPRESSION;
 int pager_in_use;
receive-pack.c +15 -1
index f6f1729..e966148 100644
@@ -12,12 +12,26 @@ static const char *keep_packer[] = {
 	"index-pack", "--stdin", "--fix-thin", NULL
 };
 
+static int deny_non_fast_forwards = 0;
 static int report_status;
 static int keep_pack;
 
 static char capabilities[] = "report-status keep-pack";
 static int capabilities_sent;
 
+static int receive_pack_config(const char *var, const char *value)
+{
+	git_default_config(var, value);
+
+	if (strcmp(var, "receive.denynonfastforwards") == 0)
+	{
+		deny_non_fast_forwards = git_config_bool(var, value);
+		return 0;
+	}
+
+	return 0;
+}
+
 static int show_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
 {
 	if (capabilities_sent)
@@ -290,7 +304,7 @@ int main(int argc, char **argv)
 		die("'%s': unable to chdir or not a git archive", dir);
 
 	setup_ident();
-	git_config(git_default_config);
+	git_config(receive_pack_config);
 
 	write_head_info();
 
setup.c +0 -2
index 9a46a58..2afdba4 100644
@@ -244,8 +244,6 @@ int check_repository_format_version(cons
                repository_format_version = git_config_int(var, value);
 	else if (strcmp(var, "core.sharedrepository") == 0)
 		shared_repository = git_config_perm(var, value);
-	else if (strcmp(var, "receive.denynonfastforwards") == 0)
-		deny_non_fast_forwards = git_config_bool(var, value);
        return 0;
 }
 
Signature · 1 line
1.4.3.3.g7d63