* [Patch 0/5] make more commands built-in
@ 2010-01-22 16:22 Linus Torvalds
2010-01-22 16:25 ` [PATCH 1/5] make "merge-index" a built-in Linus Torvalds
0 siblings, 1 reply; 9+ messages in thread
From: Linus Torvalds @ 2010-01-22 16:22 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
Ok, so since I was working on this yesterday, I decided to just continue
until I was done with all the trivial files.
This series makes five more commands built-in: 'merge-index', 'mktag',
'unpack-file', 'pack-redundant' and 'index-pack'. It further shrinks my
git install footprint by about 20%:
[torvalds@nehalem git]$ du -s /home/torvalds/libexec/git-core
21424 /home/torvalds/libexec/git-core (before)
16920 /home/torvalds/libexec/git-core (after)
and if we didn't default to having debug info enabled, it would look
almost acceptable:
[torvalds@nehalem git]$ du -s /home/torvalds/libexec/git-core
5728 /home/torvalds/libexec/git-core (with "-g" removed)
5108 /home/torvalds/libexec/git-core (with -Os and no debugging)
There still remains a few big git commands after this, but this takes care
of most of the core ones.
All of these patches are trivial, the only one that has _any_ changes
apart from the obvious builtin conversion is 'pack-redundant' which
required some of the pack creation interfaces to now take 'const' index
pathnames etc.
But as you can see, it removes more lines than it adds, and considering
that yesterday the 'du' reported ~40MB of disk space for the git install,
the shrinking certainly matters (of course, I suspect most distros
wouldn't ship with debug info, so for most people it's about a few MB
rather than a few tens of MB, but still).
Linus
---
Linus Torvalds (5):
make "merge-index" a built-in
make "mktag" a built-in
make "git unpack-file" a built-in
make "git pack-redundant" a built-in
make "index-pack" a built-in
Makefile | 10 +++++-----
index-pack.c => builtin-index-pack.c | 16 +++++++---------
merge-index.c => builtin-merge-index.c | 7 ++-----
mktag.c => builtin-mktag.c | 6 +-----
builtin-pack-objects.c | 5 +++--
pack-redundant.c => builtin-pack-redundant.c | 8 ++------
unpack-file.c => builtin-unpack-file.c | 5 +----
builtin.h | 5 +++++
git.c | 5 +++++
pack-write.c | 4 ++--
pack.h | 2 +-
11 files changed, 34 insertions(+), 39 deletions(-)
rename index-pack.c => builtin-index-pack.c (98%)
rename merge-index.c => builtin-merge-index.c (94%)
rename mktag.c => builtin-mktag.c (98%)
rename pack-redundant.c => builtin-pack-redundant.c (99%)
rename unpack-file.c => builtin-unpack-file.c (89%)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/5] make "merge-index" a built-in
2010-01-22 16:22 [Patch 0/5] make more commands built-in Linus Torvalds
@ 2010-01-22 16:25 ` Linus Torvalds
2010-01-22 16:26 ` PATCH 2/5] make "mktag" " Linus Torvalds
0 siblings, 1 reply; 9+ messages in thread
From: Linus Torvalds @ 2010-01-22 16:25 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
Totally trivial. Famous last words.
Makefile | 2 +-
merge-index.c => builtin-merge-index.c | 7 ++-----
builtin.h | 1 +
git.c | 1 +
4 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index e1c7ae5..70ac4b3 100644
--- a/Makefile
+++ b/Makefile
@@ -389,7 +389,6 @@ PROGRAMS += $(EXTRA_PROGRAMS)
PROGRAMS += git-fast-import$X
PROGRAMS += git-imap-send$X
PROGRAMS += git-index-pack$X
-PROGRAMS += git-merge-index$X
PROGRAMS += git-mktag$X
PROGRAMS += git-pack-redundant$X
PROGRAMS += git-shell$X
@@ -667,6 +666,7 @@ BUILTIN_OBJS += builtin-mailsplit.o
BUILTIN_OBJS += builtin-merge.o
BUILTIN_OBJS += builtin-merge-base.o
BUILTIN_OBJS += builtin-merge-file.o
+BUILTIN_OBJS += builtin-merge-index.o
BUILTIN_OBJS += builtin-merge-ours.o
BUILTIN_OBJS += builtin-merge-recursive.o
BUILTIN_OBJS += builtin-merge-tree.o
diff --git a/merge-index.c b/builtin-merge-index.c
similarity index 94%
rename from merge-index.c
rename to builtin-merge-index.c
index 19ddd03..2c4cf5e 100644
--- a/merge-index.c
+++ b/builtin-merge-index.c
@@ -66,7 +66,7 @@ static void merge_all(void)
}
}
-int main(int argc, char **argv)
+int cmd_merge_index(int argc, const char **argv, const char *prefix)
{
int i, force_file = 0;
@@ -78,9 +78,6 @@ int main(int argc, char **argv)
if (argc < 3)
usage("git merge-index [-o] [-q] <merge-program> (-a | [--] <filename>*)");
- git_extract_argv0_path(argv[0]);
-
- setup_git_directory();
read_cache();
i = 1;
@@ -94,7 +91,7 @@ int main(int argc, char **argv)
}
pgm = argv[i++];
for (; i < argc; i++) {
- char *arg = argv[i];
+ const char *arg = argv[i];
if (!force_file && *arg == '-') {
if (!strcmp(arg, "--")) {
force_file = 1;
diff --git a/builtin.h b/builtin.h
index cb8489f..e961b33 100644
--- a/builtin.h
+++ b/builtin.h
@@ -68,6 +68,7 @@ extern int cmd_mailinfo(int argc, const char **argv, const char *prefix);
extern int cmd_mailsplit(int argc, const char **argv, const char *prefix);
extern int cmd_merge(int argc, const char **argv, const char *prefix);
extern int cmd_merge_base(int argc, const char **argv, const char *prefix);
+extern int cmd_merge_index(int argc, const char **argv, const char *prefix);
extern int cmd_merge_ours(int argc, const char **argv, const char *prefix);
extern int cmd_merge_file(int argc, const char **argv, const char *prefix);
extern int cmd_merge_recursive(int argc, const char **argv, const char *prefix);
diff --git a/git.c b/git.c
index b60999c..eae12e3 100644
--- a/git.c
+++ b/git.c
@@ -331,6 +331,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "merge", cmd_merge, RUN_SETUP | NEED_WORK_TREE },
{ "merge-base", cmd_merge_base, RUN_SETUP },
{ "merge-file", cmd_merge_file },
+ { "merge-index", cmd_merge_index, RUN_SETUP },
{ "merge-ours", cmd_merge_ours, RUN_SETUP },
{ "merge-recursive", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
{ "merge-recursive-ours", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
--
1.6.6.1.399.g73128.dirty
^ permalink raw reply related [flat|nested] 9+ messages in thread
* PATCH 2/5] make "mktag" a built-in
2010-01-22 16:25 ` [PATCH 1/5] make "merge-index" a built-in Linus Torvalds
@ 2010-01-22 16:26 ` Linus Torvalds
2010-01-22 16:27 ` [PATCH 3/5] make "git unpack-file" " Linus Torvalds
2010-01-22 16:33 ` PATCH 2/5] make "mktag" " Linus Torvalds
0 siblings, 2 replies; 9+ messages in thread
From: Linus Torvalds @ 2010-01-22 16:26 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Fri, 22 Jan 2010 07:34:44 -0800
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
Another trivial one.
Makefile | 2 +-
mktag.c => builtin-mktag.c | 6 +-----
builtin.h | 1 +
git.c | 1 +
4 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index 70ac4b3..c5a1190 100644
--- a/Makefile
+++ b/Makefile
@@ -389,7 +389,6 @@ PROGRAMS += $(EXTRA_PROGRAMS)
PROGRAMS += git-fast-import$X
PROGRAMS += git-imap-send$X
PROGRAMS += git-index-pack$X
-PROGRAMS += git-mktag$X
PROGRAMS += git-pack-redundant$X
PROGRAMS += git-shell$X
PROGRAMS += git-show-index$X
@@ -670,6 +669,7 @@ BUILTIN_OBJS += builtin-merge-index.o
BUILTIN_OBJS += builtin-merge-ours.o
BUILTIN_OBJS += builtin-merge-recursive.o
BUILTIN_OBJS += builtin-merge-tree.o
+BUILTIN_OBJS += builtin-mktag.o
BUILTIN_OBJS += builtin-mktree.o
BUILTIN_OBJS += builtin-mv.o
BUILTIN_OBJS += builtin-name-rev.o
diff --git a/mktag.c b/builtin-mktag.c
similarity index 98%
rename from mktag.c
rename to builtin-mktag.c
index a3b4270..1cb0f3f 100644
--- a/mktag.c
+++ b/builtin-mktag.c
@@ -153,7 +153,7 @@ static int verify_tag(char *buffer, unsigned long size)
#undef PD_FMT
-int main(int argc, char **argv)
+int cmd_mktag(int argc, const char **argv, const char *prefix)
{
struct strbuf buf = STRBUF_INIT;
unsigned char result_sha1[20];
@@ -161,10 +161,6 @@ int main(int argc, char **argv)
if (argc != 1)
usage("git mktag < signaturefile");
- git_extract_argv0_path(argv[0]);
-
- setup_git_directory();
-
if (strbuf_read(&buf, 0, 4096) < 0) {
die_errno("could not read from stdin");
}
diff --git a/builtin.h b/builtin.h
index e961b33..2aaef74 100644
--- a/builtin.h
+++ b/builtin.h
@@ -73,6 +73,7 @@ extern int cmd_merge_ours(int argc, const char **argv, const char *prefix);
extern int cmd_merge_file(int argc, const char **argv, const char *prefix);
extern int cmd_merge_recursive(int argc, const char **argv, const char *prefix);
extern int cmd_merge_tree(int argc, const char **argv, const char *prefix);
+extern int cmd_mktag(int argc, const char **argv, const char *prefix);
extern int cmd_mktree(int argc, const char **argv, const char *prefix);
extern int cmd_mv(int argc, const char **argv, const char *prefix);
extern int cmd_name_rev(int argc, const char **argv, const char *prefix);
diff --git a/git.c b/git.c
index eae12e3..0b8f8a7 100644
--- a/git.c
+++ b/git.c
@@ -338,6 +338,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "merge-recursive-theirs", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
{ "merge-subtree", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
{ "merge-tree", cmd_merge_tree, RUN_SETUP },
+ { "mktag", cmd_mktag, RUN_SETUP },
{ "mktree", cmd_mktree, RUN_SETUP },
{ "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE },
{ "name-rev", cmd_name_rev, RUN_SETUP },
--
1.6.6.1.399.g73128
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/5] make "git unpack-file" a built-in
2010-01-22 16:26 ` PATCH 2/5] make "mktag" " Linus Torvalds
@ 2010-01-22 16:27 ` Linus Torvalds
2010-01-22 16:28 ` [PATCH 4/5] make "git pack-redundant" " Linus Torvalds
2010-01-22 18:04 ` [PATCH 3/5] make "git unpack-file" " Junio C Hamano
2010-01-22 16:33 ` PATCH 2/5] make "mktag" " Linus Torvalds
1 sibling, 2 replies; 9+ messages in thread
From: Linus Torvalds @ 2010-01-22 16:27 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Fri, 22 Jan 2010 07:38:03 -0800
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
Again.. No surprises.
Makefile | 2 +-
unpack-file.c => builtin-unpack-file.c | 5 +----
builtin.h | 1 +
git.c | 1 +
4 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index c5a1190..88e2f8f 100644
--- a/Makefile
+++ b/Makefile
@@ -392,7 +392,6 @@ PROGRAMS += git-index-pack$X
PROGRAMS += git-pack-redundant$X
PROGRAMS += git-shell$X
PROGRAMS += git-show-index$X
-PROGRAMS += git-unpack-file$X
PROGRAMS += git-upload-pack$X
PROGRAMS += git-http-backend$X
@@ -698,6 +697,7 @@ BUILTIN_OBJS += builtin-stripspace.o
BUILTIN_OBJS += builtin-symbolic-ref.o
BUILTIN_OBJS += builtin-tag.o
BUILTIN_OBJS += builtin-tar-tree.o
+BUILTIN_OBJS += builtin-unpack-file.o
BUILTIN_OBJS += builtin-unpack-objects.o
BUILTIN_OBJS += builtin-update-index.o
BUILTIN_OBJS += builtin-update-ref.o
diff --git a/unpack-file.c b/builtin-unpack-file.c
similarity index 89%
rename from unpack-file.c
rename to builtin-unpack-file.c
index e9d8934..608590a 100644
--- a/unpack-file.c
+++ b/builtin-unpack-file.c
@@ -22,18 +22,15 @@ static char *create_temp_file(unsigned char *sha1)
return path;
}
-int main(int argc, char **argv)
+int cmd_unpack_file(int argc, const char **argv, const char *prefix)
{
unsigned char sha1[20];
- git_extract_argv0_path(argv[0]);
-
if (argc != 2 || !strcmp(argv[1], "-h"))
usage("git unpack-file <sha1>");
if (get_sha1(argv[1], sha1))
die("Not a valid object name %s", argv[1]);
- setup_git_directory();
git_config(git_default_config, NULL);
puts(create_temp_file(sha1));
diff --git a/builtin.h b/builtin.h
index 2aaef74..d4fec89 100644
--- a/builtin.h
+++ b/builtin.h
@@ -103,6 +103,7 @@ extern int cmd_stripspace(int argc, const char **argv, const char *prefix);
extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);
extern int cmd_tag(int argc, const char **argv, const char *prefix);
extern int cmd_tar_tree(int argc, const char **argv, const char *prefix);
+extern int cmd_unpack_file(int argc, const char **argv, const char *prefix);
extern int cmd_unpack_objects(int argc, const char **argv, const char *prefix);
extern int cmd_update_index(int argc, const char **argv, const char *prefix);
extern int cmd_update_ref(int argc, const char **argv, const char *prefix);
diff --git a/git.c b/git.c
index 0b8f8a7..832bd2d 100644
--- a/git.c
+++ b/git.c
@@ -370,6 +370,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
{ "tag", cmd_tag, RUN_SETUP },
{ "tar-tree", cmd_tar_tree },
+ { "unpack-file", cmd_unpack_file, RUN_SETUP },
{ "unpack-objects", cmd_unpack_objects, RUN_SETUP },
{ "update-index", cmd_update_index, RUN_SETUP },
{ "update-ref", cmd_update_ref, RUN_SETUP },
--
1.6.6.1.399.g73128
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/5] make "git pack-redundant" a built-in
2010-01-22 16:27 ` [PATCH 3/5] make "git unpack-file" " Linus Torvalds
@ 2010-01-22 16:28 ` Linus Torvalds
2010-01-22 16:31 ` [PATCH 5/5] make "index-pack" " Linus Torvalds
2010-01-22 18:04 ` [PATCH 3/5] make "git unpack-file" " Junio C Hamano
1 sibling, 1 reply; 9+ messages in thread
From: Linus Torvalds @ 2010-01-22 16:28 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Fri, 22 Jan 2010 07:42:14 -0800
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
This has one function that now needed a 'const char *' argument
conversion, but it's the next one that actually affects other files..
Makefile | 2 +-
pack-redundant.c => builtin-pack-redundant.c | 8 ++------
builtin.h | 1 +
git.c | 1 +
4 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index 88e2f8f..33f9870 100644
--- a/Makefile
+++ b/Makefile
@@ -389,7 +389,6 @@ PROGRAMS += $(EXTRA_PROGRAMS)
PROGRAMS += git-fast-import$X
PROGRAMS += git-imap-send$X
PROGRAMS += git-index-pack$X
-PROGRAMS += git-pack-redundant$X
PROGRAMS += git-shell$X
PROGRAMS += git-show-index$X
PROGRAMS += git-upload-pack$X
@@ -673,6 +672,7 @@ BUILTIN_OBJS += builtin-mktree.o
BUILTIN_OBJS += builtin-mv.o
BUILTIN_OBJS += builtin-name-rev.o
BUILTIN_OBJS += builtin-pack-objects.o
+BUILTIN_OBJS += builtin-pack-redundant.o
BUILTIN_OBJS += builtin-pack-refs.o
BUILTIN_OBJS += builtin-patch-id.o
BUILTIN_OBJS += builtin-prune-packed.o
diff --git a/pack-redundant.c b/builtin-pack-redundant.c
similarity index 99%
rename from pack-redundant.c
rename to builtin-pack-redundant.c
index 21c61db..41e1615 100644
--- a/pack-redundant.c
+++ b/builtin-pack-redundant.c
@@ -568,7 +568,7 @@ static struct pack_list * add_pack(struct packed_git *p)
return pack_list_insert(&altodb_packs, &l);
}
-static struct pack_list * add_pack_file(char *filename)
+static struct pack_list * add_pack_file(const char *filename)
{
struct packed_git *p = packed_git;
@@ -593,7 +593,7 @@ static void load_all(void)
}
}
-int main(int argc, char **argv)
+int cmd_pack_redundant(int argc, const char **argv, const char *prefix)
{
int i;
struct pack_list *min, *red, *pl;
@@ -601,13 +601,9 @@ int main(int argc, char **argv)
unsigned char *sha1;
char buf[42]; /* 40 byte sha1 + \n + \0 */
- git_extract_argv0_path(argv[0]);
-
if (argc == 2 && !strcmp(argv[1], "-h"))
usage(pack_redundant_usage);
- setup_git_directory();
-
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (!strcmp(arg, "--")) {
diff --git a/builtin.h b/builtin.h
index d4fec89..bd7f737 100644
--- a/builtin.h
+++ b/builtin.h
@@ -78,6 +78,7 @@ extern int cmd_mktree(int argc, const char **argv, const char *prefix);
extern int cmd_mv(int argc, const char **argv, const char *prefix);
extern int cmd_name_rev(int argc, const char **argv, const char *prefix);
extern int cmd_pack_objects(int argc, const char **argv, const char *prefix);
+extern int cmd_pack_redundant(int argc, const char **argv, const char *prefix);
extern int cmd_patch_id(int argc, const char **argv, const char *prefix);
extern int cmd_pickaxe(int argc, const char **argv, const char *prefix);
extern int cmd_prune(int argc, const char **argv, const char *prefix);
diff --git a/git.c b/git.c
index 832bd2d..6cc1eba 100644
--- a/git.c
+++ b/git.c
@@ -343,6 +343,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE },
{ "name-rev", cmd_name_rev, RUN_SETUP },
{ "pack-objects", cmd_pack_objects, RUN_SETUP },
+ { "pack-redundant", cmd_pack_redundant, RUN_SETUP },
{ "patch-id", cmd_patch_id },
{ "peek-remote", cmd_ls_remote },
{ "pickaxe", cmd_blame, RUN_SETUP },
--
1.6.6.1.399.g73128
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/5] make "index-pack" a built-in
2010-01-22 16:28 ` [PATCH 4/5] make "git pack-redundant" " Linus Torvalds
@ 2010-01-22 16:31 ` Linus Torvalds
0 siblings, 0 replies; 9+ messages in thread
From: Linus Torvalds @ 2010-01-22 16:31 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Fri, 22 Jan 2010 07:55:19 -0800
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>
---
I say "fairly trivial", but I have to admit to hating the moron people who
decided that 'free()' takes a "void *", not a "const void *". So now we
have three new casts like this
free((void *)ptr)
just to avoid a compiler warning due to incompetent standards people.
Oh well. I didn't feel it was worth an 'xfree()'.
Makefile | 2 +-
index-pack.c => builtin-index-pack.c | 16 +++++++---------
builtin-pack-objects.c | 5 +++--
builtin.h | 1 +
git.c | 1 +
pack-write.c | 4 ++--
pack.h | 2 +-
7 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/Makefile b/Makefile
index 33f9870..c0dbee2 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
similarity index 98%
rename from index-pack.c
rename to builtin-index-pack.c
index 190f372..b4cf8c5 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 59b07fe..b0887d7 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 bd7f737..e8202f3 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 6cc1eba..b3e23f1 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 741efcd..9f47cf9 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 a883334..b759a23 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);
--
1.6.6.1.399.g73128
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: PATCH 2/5] make "mktag" a built-in
2010-01-22 16:26 ` PATCH 2/5] make "mktag" " Linus Torvalds
2010-01-22 16:27 ` [PATCH 3/5] make "git unpack-file" " Linus Torvalds
@ 2010-01-22 16:33 ` Linus Torvalds
1 sibling, 0 replies; 9+ messages in thread
From: Linus Torvalds @ 2010-01-22 16:33 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
Oops, I screwed up the subject line on this one (obvious missing opening
brace, since I'm a tool and can't cut-and-paste correctly). So please fix
that before applying.
Linus
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/5] make "git unpack-file" a built-in
2010-01-22 16:27 ` [PATCH 3/5] make "git unpack-file" " Linus Torvalds
2010-01-22 16:28 ` [PATCH 4/5] make "git pack-redundant" " Linus Torvalds
@ 2010-01-22 18:04 ` Junio C Hamano
2010-01-22 18:26 ` Linus Torvalds
1 sibling, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2010-01-22 18:04 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Junio C Hamano, Git Mailing List
Linus Torvalds <torvalds@linux-foundation.org> writes:
> From: Linus Torvalds <torvalds@linux-foundation.org>
> Date: Fri, 22 Jan 2010 07:38:03 -0800
>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> ---
> Again.. No surprises.
> ...
> diff --git a/unpack-file.c b/builtin-unpack-file.c
> similarity index 89%
> rename from unpack-file.c
> rename to builtin-unpack-file.c
> index e9d8934..608590a 100644
> --- a/unpack-file.c
> +++ b/builtin-unpack-file.c
> @@ -22,18 +22,15 @@ static char *create_temp_file(unsigned char *sha1)
> return path;
> }
>
> -int main(int argc, char **argv)
> +int cmd_unpack_file(int argc, const char **argv, const char *prefix)
> {
> unsigned char sha1[20];
>
> - git_extract_argv0_path(argv[0]);
> -
> if (argc != 2 || !strcmp(argv[1], "-h"))
> usage("git unpack-file <sha1>");
> if (get_sha1(argv[1], sha1))
> die("Not a valid object name %s", argv[1]);
>
> - setup_git_directory();
This will now require "git unpack-file -h" to be run in a git controlled
directory, so strictly speaking it changes behaviour.
Not that anybody would care that much, though.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/5] make "git unpack-file" a built-in
2010-01-22 18:04 ` [PATCH 3/5] make "git unpack-file" " Junio C Hamano
@ 2010-01-22 18:26 ` Linus Torvalds
0 siblings, 0 replies; 9+ messages in thread
From: Linus Torvalds @ 2010-01-22 18:26 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List
On Fri, 22 Jan 2010, Junio C Hamano wrote:
> > {
> > unsigned char sha1[20];
> >
> > - git_extract_argv0_path(argv[0]);
> > -
> > if (argc != 2 || !strcmp(argv[1], "-h"))
> > usage("git unpack-file <sha1>");
> > if (get_sha1(argv[1], sha1))
> > die("Not a valid object name %s", argv[1]);
> >
> > - setup_git_directory();
>
> This will now require "git unpack-file -h" to be run in a git controlled
> directory, so strictly speaking it changes behaviour.
>
> Not that anybody would care that much, though.
Heh. You didn't notice the same change in the merge-tree conversion that
you already accepted ;)
Yeah, any usage messages will now run after setup for the commands that do
the whole RUN_SETUP thing. That's pack-redundant, unpack-file, mktag,
merge-index and merge-tree. So they'll now report "Not a git repository"
before they report invalid arguments.
Linus
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-01-22 18:32 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-22 16:22 [Patch 0/5] make more commands built-in Linus Torvalds
2010-01-22 16:25 ` [PATCH 1/5] make "merge-index" a built-in Linus Torvalds
2010-01-22 16:26 ` PATCH 2/5] make "mktag" " Linus Torvalds
2010-01-22 16:27 ` [PATCH 3/5] make "git unpack-file" " Linus Torvalds
2010-01-22 16:28 ` [PATCH 4/5] make "git pack-redundant" " Linus Torvalds
2010-01-22 16:31 ` [PATCH 5/5] make "index-pack" " Linus Torvalds
2010-01-22 18:04 ` [PATCH 3/5] make "git unpack-file" " Junio C Hamano
2010-01-22 18:26 ` Linus Torvalds
2010-01-22 16:33 ` PATCH 2/5] make "mktag" " Linus Torvalds
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 NNTP newsgroup(s).