aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-01-22 07:55:19 -0800
committerJunio C Hamano <gitster@pobox.com>2010-01-22 10:10:27 -0800
commit3bb7256281bb1d291bb705a57dc3f30b26b7c127 (patch)
tree7d0fb7bf88cabcd5c7b17a0f687f359737c6ce2d
parent377d0276ca7446ce9fb2f6987b1e6b4ba9e7cf29 (diff)
downloadgit-3bb7256281bb1d291bb705a57dc3f30b26b7c127.tar.gz
git-3bb7256281bb1d291bb705a57dc3f30b26b7c127.tar.xz
make "index-pack" a built-in
This required some fairly trivial packfile function 'const' cleanup, since the builtin commands get a const char *argv[] array. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--Makefile2
-rw-r--r--builtin-index-pack.c (renamed from index-pack.c)16
-rw-r--r--builtin-pack-objects.c5
-rw-r--r--builtin.h1
-rw-r--r--git.c1
-rw-r--r--pack-write.c4
-rw-r--r--pack.h2
7 files changed, 16 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index 33f987088..c0dbee2ae 100644
--- a/Makefile
+++ b/Makefile
@@ -388,7 +388,6 @@ EXTRA_PROGRAMS =
PROGRAMS += $(EXTRA_PROGRAMS)
PROGRAMS += git-fast-import$X
PROGRAMS += git-imap-send$X
-PROGRAMS += git-index-pack$X
PROGRAMS += git-shell$X
PROGRAMS += git-show-index$X
PROGRAMS += git-upload-pack$X
@@ -653,6 +652,7 @@ BUILTIN_OBJS += builtin-gc.o
BUILTIN_OBJS += builtin-grep.o
BUILTIN_OBJS += builtin-hash-object.o
BUILTIN_OBJS += builtin-help.o
+BUILTIN_OBJS += builtin-index-pack.o
BUILTIN_OBJS += builtin-init-db.o
BUILTIN_OBJS += builtin-log.o
BUILTIN_OBJS += builtin-ls-files.o
diff --git a/index-pack.c b/builtin-index-pack.c
index 190f372dd..b4cf8c53e 100644
--- a/index-pack.c
+++ b/builtin-index-pack.c
@@ -166,7 +166,7 @@ static void use(int bytes)
consumed_bytes += bytes;
}
-static char *open_pack_file(char *pack_name)
+static const char *open_pack_file(const char *pack_name)
{
if (from_stdin) {
input_fd = 0;
@@ -870,18 +870,16 @@ static int git_index_pack_config(const char *k, const char *v, void *cb)
return git_default_config(k, v, cb);
}
-int main(int argc, char **argv)
+int cmd_index_pack(int argc, const char **argv, const char *prefix)
{
int i, fix_thin_pack = 0;
- char *curr_pack, *pack_name = NULL;
- char *curr_index, *index_name = NULL;
+ const char *curr_pack, *curr_index;
+ const char *index_name = NULL, *pack_name = NULL;
const char *keep_name = NULL, *keep_msg = NULL;
char *index_name_buf = NULL, *keep_name_buf = NULL;
struct pack_idx_entry **idx_objects;
unsigned char pack_sha1[20];
- git_extract_argv0_path(argv[0]);
-
if (argc == 2 && !strcmp(argv[1], "-h"))
usage(index_pack_usage);
@@ -906,7 +904,7 @@ int main(int argc, char **argv)
}
for (i = 1; i < argc; i++) {
- char *arg = argv[i];
+ const char *arg = argv[i];
if (*arg == '-') {
if (!strcmp(arg, "--stdin")) {
@@ -1039,9 +1037,9 @@ int main(int argc, char **argv)
free(index_name_buf);
free(keep_name_buf);
if (pack_name == NULL)
- free(curr_pack);
+ free((void *) curr_pack);
if (index_name == NULL)
- free(curr_index);
+ free((void *) curr_index);
return 0;
}
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 59b07fe49..b0887d759 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -525,7 +525,8 @@ static void write_pack_file(void)
if (!pack_to_stdout) {
mode_t mode = umask(0);
struct stat st;
- char *idx_tmp_name, tmpname[PATH_MAX];
+ const char *idx_tmp_name;
+ char tmpname[PATH_MAX];
umask(mode);
mode = 0444 & ~mode;
@@ -569,7 +570,7 @@ static void write_pack_file(void)
if (rename(idx_tmp_name, tmpname))
die_errno("unable to rename temporary index file");
- free(idx_tmp_name);
+ free((void *) idx_tmp_name);
free(pack_tmp_name);
puts(sha1_to_hex(sha1));
}
diff --git a/builtin.h b/builtin.h
index bd7f73748..e8202f3f5 100644
--- a/builtin.h
+++ b/builtin.h
@@ -58,6 +58,7 @@ extern int cmd_grep(int argc, const char **argv, const char *prefix);
extern int cmd_hash_object(int argc, const char **argv, const char *prefix);
extern int cmd_help(int argc, const char **argv, const char *prefix);
extern int cmd_http_fetch(int argc, const char **argv, const char *prefix);
+extern int cmd_index_pack(int argc, const char **argv, const char *prefix);
extern int cmd_init_db(int argc, const char **argv, const char *prefix);
extern int cmd_log(int argc, const char **argv, const char *prefix);
extern int cmd_log_reflog(int argc, const char **argv, const char *prefix);
diff --git a/git.c b/git.c
index 6cc1eba29..b3e23f104 100644
--- a/git.c
+++ b/git.c
@@ -320,6 +320,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "grep", cmd_grep, USE_PAGER },
{ "hash-object", cmd_hash_object },
{ "help", cmd_help },
+ { "index-pack", cmd_index_pack },
{ "init", cmd_init_db },
{ "init-db", cmd_init_db },
{ "log", cmd_log, RUN_SETUP | USE_PAGER },
diff --git a/pack-write.c b/pack-write.c
index 741efcd93..9f47cf996 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -17,8 +17,8 @@ static int sha1_compare(const void *_a, const void *_b)
* the SHA1 hash of sorted object names. The objects array passed in
* will be sorted by SHA1 on exit.
*/
-char *write_idx_file(char *index_name, struct pack_idx_entry **objects,
- int nr_objects, unsigned char *sha1)
+const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects,
+ int nr_objects, unsigned char *sha1)
{
struct sha1file *f;
struct pack_idx_entry **sorted_by_sha, **list, **last;
diff --git a/pack.h b/pack.h
index a883334b2..b759a23d4 100644
--- a/pack.h
+++ b/pack.h
@@ -55,7 +55,7 @@ struct pack_idx_entry {
off_t offset;
};
-extern char *write_idx_file(char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1);
+extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1);
extern int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, off_t offset, off_t len, unsigned int nr);
extern int verify_pack(struct packed_git *);
extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t, unsigned char *, off_t);