git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] submodule.c: use GIT_DIR_ENVIRONMENT consistently
@ 2016-12-30  0:47 Stefan Beller
  2016-12-30  1:36 ` René Scharfe
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Beller @ 2016-12-30  0:47 UTC (permalink / raw)
  To: gitster, jrnieder; +Cc: git, 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.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
  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(-)

diff --git a/submodule.c b/submodule.c
index ece17315d6..973b9f3f96 100644
--- a/submodule.c
+++ b/submodule.c
@@ -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);
 }
-- 
2.11.0.259.ga95e92af08.dirty


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] submodule.c: use GIT_DIR_ENVIRONMENT consistently
  2016-12-30  0:47 [PATCH] submodule.c: use GIT_DIR_ENVIRONMENT consistently Stefan Beller
@ 2016-12-30  1:36 ` René Scharfe
  2017-01-03 18:30   ` [PATCHv2] " Stefan Beller
  0 siblings, 1 reply; 4+ messages in thread
From: René Scharfe @ 2016-12-30  1:36 UTC (permalink / raw)
  To: Stefan Beller; +Cc: gitster, jrnieder, git

Am 30.12.2016 um 01:47 schrieb Stefan Beller:
> diff --git a/submodule.c b/submodule.c
> index ece17315d6..973b9f3f96 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -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);

>  }
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCHv2] submodule.c: use GIT_DIR_ENVIRONMENT consistently
  2016-12-30  1:36 ` René Scharfe
@ 2017-01-03 18:30   ` Stefan Beller
  2017-01-04  1:18     ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Beller @ 2017-01-03 18:30 UTC (permalink / raw)
  To: gitster, l.s.r; +Cc: git, 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.

Signed-off-by: Stefan Beller <sbeller@google.com>
---

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(-)

diff --git a/submodule.c b/submodule.c
index ece17315d6..973b9f3f96 100644
--- a/submodule.c
+++ b/submodule.c
@@ -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);
 }
-- 
2.11.0.259.ga95e92af08.dirty


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCHv2] submodule.c: use GIT_DIR_ENVIRONMENT consistently
  2017-01-03 18:30   ` [PATCHv2] " Stefan Beller
@ 2017-01-04  1:18     ` Jeff King
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2017-01-04  1:18 UTC (permalink / raw)
  To: Stefan Beller; +Cc: gitster, l.s.r, git

On Tue, Jan 03, 2017 at 10:30:47AM -0800, Stefan Beller wrote:

> 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: Stefan Beller <sbeller@google.com>

This looks like a good change to me.

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

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-01-04  1:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-30  0:47 [PATCH] submodule.c: use GIT_DIR_ENVIRONMENT consistently Stefan Beller
2016-12-30  1:36 ` René Scharfe
2017-01-03 18:30   ` [PATCHv2] " Stefan Beller
2017-01-04  1:18     ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).