зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
377d0276ca
Коммит
3bb7256281
2
Makefile
2
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
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
1
git.c
1
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 },
|
||||
|
|
|
@ -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;
|
||||
|
|
2
pack.h
2
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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче