@matheusbsbs / matheus-bagliano / commits / af05d67939
Fork 0

Always set *nongit_ok in setup_git_directory_gently()

setup_git_directory_gently() only modified the value of its *nongit_ok argument if we were not in a git repository. Now it will always set it to 0 when we are inside a repository. Also remove now unnecessary initializations in the callers of this function. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Mar 25, 2008 at 22:06 UTC af05d67939f306a68c5f81ed30f65a82ae025661
8 files changed +16 -8
builtin-apply.c
+1 -1
@@ -2994,7 +2994,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
2994 int read_stdin = 1;
2995 int inaccurate_eof = 0;
2996 int errs = 0;
2997 - int is_not_gitdir = 0;
2997 + int is_not_gitdir;
2998
2999 const char *whitespace_option = NULL;
3000
builtin-bundle.c
+1 -1
@@ -14,7 +14,7 @@ static const char *bundle_usage="git-bundle (create <bundle> <git-rev-list args>
14 int cmd_bundle(int argc, const char **argv, const char *prefix)
15 {
16 struct bundle_header header;
17 - int nongit = 0;
17 + int nongit;
18 const char *cmd, *bundle_file;
19 int bundle_fd = -1;
20 char buffer[PATH_MAX];
builtin-config.c
+1 -1
@@ -264,7 +264,7 @@ static int get_colorbool(int argc, const char **argv)
264
265 int cmd_config(int argc, const char **argv, const char *prefix)
266 {
267 - int nongit = 0;
267 + int nongit;
268 char* value;
269 const char *file = setup_git_directory_gently(&nongit);
270
builtin-diff-files.c
+1 -1
@@ -16,7 +16,7 @@ COMMON_DIFF_OPTIONS_HELP;
16 int cmd_diff_files(int argc, const char **argv, const char *prefix)
17 {
18 struct rev_info rev;
19 - int nongit = 0;
19 + int nongit;
20 int result;
21
22 prefix = setup_git_directory_gently(&nongit);
builtin-diff.c
+1 -1
@@ -210,7 +210,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
210 int ents = 0, blobs = 0, paths = 0;
211 const char *path = NULL;
212 struct blobinfo blob[2];
213 - int nongit = 0;
213 + int nongit;
214 int result = 0;
215
216 /*
builtin-ls-remote.c
+1 -1
@@ -31,7 +31,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
31 {
32 int i;
33 const char *dest = NULL;
34 - int nongit = 0;
34 + int nongit;
35 unsigned flags = 0;
36 const char *uploadpack = NULL;
37 const char **pattern = NULL;
git.c
+2 -2
@@ -142,14 +142,14 @@ static int split_cmdline(char *cmdline, const char ***argv)
142
143 static int handle_alias(int *argcp, const char ***argv)
144 {
145 - int nongit = 0, envchanged = 0, ret = 0, saved_errno = errno;
145 + int envchanged = 0, ret = 0, saved_errno = errno;
146 const char *subdir;
147 int count, option_count;
148 const char** new_argv;
149 const char *alias_command;
150 char *alias_string;
151
152 - subdir = setup_git_directory_gently(&nongit);
152 + subdir = setup_git_directory_gently(NULL);
153
154 alias_command = (*argv)[0];
155 alias_string = alias_lookup(alias_command);
setup.c
+8
@@ -325,6 +325,14 @@ const char *setup_git_directory_gently(int *nongit_ok)
325 const char *gitdirenv;
326 int len, offset;
327
328 + /*
329 + * Let's assume that we are in a git repository.
330 + * If it turns out later that we are somewhere else, the value will be
331 + * updated accordingly.
332 + */
333 + if (nongit_ok)
334 + *nongit_ok = 0;
335 +
336 /*
337 * If GIT_DIR is set explicitly, we're not going
338 * to do any discovery, but we still do repository