Skip to contentSkip to conversation

submodule.c: use GIT_DIR_ENVIRONMENT consistently

PATCH Superseded Stefan Beller 3 participants 4 messages Dec 30, 2016 – Jan 4, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 submodule.c: use GIT_DIR_ENVIRONMENT consistently

In C code we have the luxury of having constants for all the important things that are hard coded. This is the only place in C, that hard codes the git directory environment variable, so fix it.

---
Signed-off-by-the-format-patch-config ;)

This is the only occurrence for "GIT_DIR=" in C, but what about ".git" git grep "\.git\"" *.c finds some places, which we may want to convert to DEFAULT_GIT_DIR_ENVIRONMENT?
(mainly things that are newer if I can judge the places correctly lots of submodules, worktrees and the no data in ".git" bug AFAICT)

Thanks,
Stefan

 submodule.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
submodule.c +2 -1
index ece17315d6..973b9f3f96 100644
@@ -1333,5 +1333,6 @@ void prepare_submodule_repo_env(struct argv_array *out)
 		if (strcmp(*var, CONFIG_DATA_ENVIRONMENT))
 			argv_array_push(out, *var);
 	}
-	argv_array_push(out, "GIT_DIR=.git");
+	argv_array_push(out, "%s=%s", GIT_DIR_ENVIRONMENT,
+		DEFAULT_GIT_DIR_ENVIRONMENT);
 }
Signature · 1 line
2.11.0.259.ga95e92af08.dirty
#1 lore raw

Am 30.12.2016 um 01:47 schrieb Stefan Beller:

submodule.c void prepare_submodule_repo_env(struct argv_array *out) · line 1337

Quoted 11 lines
submodule.c +2 -1
index ece17315d6..973b9f3f96 100644
@@ -1333,5 +1333,6 @@ void prepare_submodule_repo_env(struct argv_array *out)
 		if (strcmp(*var, CONFIG_DATA_ENVIRONMENT))
 			argv_array_push(out, *var);
 	}
-	argv_array_push(out, "GIT_DIR=.git");
+	argv_array_push(out, "%s=%s", GIT_DIR_ENVIRONMENT,
+		DEFAULT_GIT_DIR_ENVIRONMENT);

argv_array_pushf (with added "f") instead?

And indent continued lines to align them with the left parenthesis, like this:

	fn(arg1,
	   arg2);
Quoted 2 lines
submodule.c +0 -0
 }
#2 lore raw

PATCH v2 1/1 submodule.c: use GIT_DIR_ENVIRONMENT consistently

In C code we have the luxury of having constants for all the important things that are hard coded. This is the only place in C, that hard codes the git directory environment variable, so fix it.

---

v2:
argv_array_pushf and realigned.

v1:
Signed-off-by-the-format-patch-config ;)

This is the only occurrence for "GIT_DIR=" in C, but what about ".git" git grep "\.git\"" *.c finds some places, which we may want to convert to DEFAULT_GIT_DIR_ENVIRONMENT?
(mainly things that are newer if I can judge the places correctly lots of submodules, worktrees and the no data in ".git" bug AFAICT)

Thanks,
Stefan

 submodule.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
submodule.c +2 -1
index ece17315d6..973b9f3f96 100644
@@ -1333,5 +1333,6 @@ void prepare_submodule_repo_env(struct argv_array *out)
 		if (strcmp(*var, CONFIG_DATA_ENVIRONMENT))
 			argv_array_push(out, *var);
 	}
-	argv_array_push(out, "GIT_DIR=.git");
+	argv_array_pushf(out, "%s=%s", GIT_DIR_ENVIRONMENT,
+			 DEFAULT_GIT_DIR_ENVIRONMENT);
 }
Signature · 1 line
2.11.0.259.ga95e92af08.dirty
#3 lore raw
Quoted 5 lines · Stefan Beller

In C code we have the luxury of having constants for all the important things that are hard coded. This is the only place in C, that hard codes the git directory environment variable, so fix it.

This looks like a good change to me.

Minor nit: the comma after "C" in your commit message is extraneous. ;)

-Peff