From 3f8099fce7779631fe8827a8979d7b57629a36de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 24 Jul 2010 06:30:49 -0500 Subject: Revert "rehabilitate 'git index-pack' inside the object store" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now setup_git_directory_gently behaves sanely even from subdirs of .git, so simplify index-pack by no longer protecting against that. This reverts commit a672ea6ac5a1b876bc7adfe6534b16fa2a32c94b (excluding tests). Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin/index-pack.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'builtin/index-pack.c') diff --git a/builtin/index-pack.c b/builtin/index-pack.c index a89ae831dd..89a1f12d61 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -880,29 +880,15 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix) char *index_name_buf = NULL, *keep_name_buf = NULL; struct pack_idx_entry **idx_objects; unsigned char pack_sha1[20]; + int nongit; if (argc == 2 && !strcmp(argv[1], "-h")) usage(index_pack_usage); - /* - * We wish to read the repository's config file if any, and - * for that it is necessary to call setup_git_directory_gently(). - * However if the cwd was inside .git/objects/pack/ then we need - * to go back there or all the pack name arguments will be wrong. - * And in that case we cannot rely on any prefix returned by - * setup_git_directory_gently() either. - */ - { - char cwd[PATH_MAX+1]; - int nongit; - - if (!getcwd(cwd, sizeof(cwd)-1)) - die("Unable to get current working directory"); - setup_git_directory_gently(&nongit); - git_config(git_index_pack_config, NULL); - if (chdir(cwd)) - die("Cannot come back to cwd"); - } + prefix = setup_git_directory_gently(&nongit); + git_config(git_index_pack_config, NULL); + if (prefix && chdir(prefix)) + die("Cannot come back to cwd"); for (i = 1; i < argc; i++) { const char *arg = argv[i]; -- cgit v1.2.3 From e0fce074fc4fdf2d2175ff97f1cc3db918ea87e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 5 Aug 2010 22:18:53 -0500 Subject: index-pack: run setup_git_directory_gently() sooner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit index-pack already runs a repository search unconditionally; running such a search earlier is not risky and ensures GIT_DIR will be set correctly if the configuration needs to be accessed from run_builtin(). Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin/index-pack.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'builtin/index-pack.c') diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 89a1f12d61..e852890862 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -880,12 +880,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix) char *index_name_buf = NULL, *keep_name_buf = NULL; struct pack_idx_entry **idx_objects; unsigned char pack_sha1[20]; - int nongit; if (argc == 2 && !strcmp(argv[1], "-h")) usage(index_pack_usage); - prefix = setup_git_directory_gently(&nongit); git_config(git_index_pack_config, NULL); if (prefix && chdir(prefix)) die("Cannot come back to cwd"); -- cgit v1.2.3 From c03c83152d6ce6fa5ae49a8698da5fc25a53127f Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Tue, 5 Oct 2010 09:24:10 +0200 Subject: do not depend on signed integer overflow Signed integer overflow is not defined in C, so do not depend on it. This fixes a problem with GCC 4.4.0 and -O3 where the optimizer would consider "consumed_bytes > consumed_bytes + bytes" as a constant expression, and never execute the die()-call. Signed-off-by: Erik Faye-Lund Acked-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- builtin/index-pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/index-pack.c') diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 2e680d7a7a..e243d9d22e 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -161,7 +161,7 @@ static void use(int bytes) input_offset += bytes; /* make sure off_t is sufficiently large not to wrap */ - if (consumed_bytes > consumed_bytes + bytes) + if (signed_add_overflows(consumed_bytes, bytes)) die("pack too large for current definition of off_t"); consumed_bytes += bytes; } -- cgit v1.2.3 From 0adda9362ab080b0994355c5a3183a896a606cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20N=C4=9Bmec?= Date: Fri, 8 Oct 2010 19:31:17 +0200 Subject: Use parentheses and `...' where appropriate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove some stray usage of other bracket types and asterisks for the same purpose. Signed-off-by: Štěpán Němec Acked-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin/index-pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/index-pack.c') diff --git a/builtin/index-pack.c b/builtin/index-pack.c index e243d9d22e..8dc5c0b541 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -11,7 +11,7 @@ #include "exec_cmd.h" static const char index_pack_usage[] = -"git index-pack [-v] [-o ] [{ --keep | --keep= }] [--strict] { | --stdin [--fix-thin] [] }"; +"git index-pack [-v] [-o ] [ --keep | --keep= ] [--strict] ( | --stdin [--fix-thin] [])"; struct object_entry { -- cgit v1.2.3