зеркало из https://github.com/microsoft/git.git
Make git-checkout-index a builtin
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Родитель
640ce1052b
Коммит
e414156ab6
6
Makefile
6
Makefile
|
@ -173,7 +173,6 @@ SIMPLE_PROGRAMS = \
|
|||
|
||||
# ... and all the rest that could be moved out of bindir to gitexecdir
|
||||
PROGRAMS = \
|
||||
git-checkout-index$X \
|
||||
git-convert-objects$X git-fetch-pack$X git-fsck-objects$X \
|
||||
git-hash-object$X git-index-pack$X git-local-fetch$X \
|
||||
git-merge-base$X \
|
||||
|
@ -187,7 +186,9 @@ PROGRAMS = \
|
|||
git-pack-redundant$X git-var$X \
|
||||
git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
|
||||
|
||||
BUILT_INS = git-log$X git-whatchanged$X git-show$X git-update-ref$X \
|
||||
BUILT_INS = \
|
||||
git-checkout-index$X \
|
||||
git-log$X git-whatchanged$X git-show$X git-update-ref$X \
|
||||
git-count-objects$X git-diff$X git-push$X git-mailsplit$X \
|
||||
git-grep$X git-add$X git-rm$X git-rev-list$X git-stripspace$X \
|
||||
git-check-ref-format$X git-rev-parse$X git-mailinfo$X \
|
||||
|
@ -245,6 +246,7 @@ LIB_OBJS = \
|
|||
alloc.o merge-file.o path-list.o $(DIFF_OBJS)
|
||||
|
||||
BUILTIN_OBJS = \
|
||||
builtin-checkout-index.o \
|
||||
builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \
|
||||
builtin-grep.o builtin-add.o builtin-rev-list.o builtin-check-ref-format.o \
|
||||
builtin-rm.o builtin-init-db.o builtin-rev-parse.o \
|
||||
|
|
|
@ -42,8 +42,6 @@
|
|||
#include "cache-tree.h"
|
||||
|
||||
#define CHECKOUT_ALL 4
|
||||
static const char *prefix;
|
||||
static int prefix_length;
|
||||
static int line_termination = '\n';
|
||||
static int checkout_stage; /* default to checkout stage0 */
|
||||
static int to_tempfile;
|
||||
|
@ -51,7 +49,7 @@ static char topath[4][MAXPATHLEN+1];
|
|||
|
||||
static struct checkout state;
|
||||
|
||||
static void write_tempfile_record (const char *name)
|
||||
static void write_tempfile_record(const char *name, int prefix_length)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -77,7 +75,7 @@ static void write_tempfile_record (const char *name)
|
|||
}
|
||||
}
|
||||
|
||||
static int checkout_file(const char *name)
|
||||
static int checkout_file(const char *name, int prefix_length)
|
||||
{
|
||||
int namelen = strlen(name);
|
||||
int pos = cache_name_pos(name, namelen);
|
||||
|
@ -106,7 +104,7 @@ static int checkout_file(const char *name)
|
|||
|
||||
if (did_checkout) {
|
||||
if (to_tempfile)
|
||||
write_tempfile_record(name);
|
||||
write_tempfile_record(name, prefix_length);
|
||||
return errs > 0 ? -1 : 0;
|
||||
}
|
||||
|
||||
|
@ -124,7 +122,7 @@ static int checkout_file(const char *name)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int checkout_all(void)
|
||||
static int checkout_all(const char *prefix, int prefix_length)
|
||||
{
|
||||
int i, errs = 0;
|
||||
struct cache_entry* last_ce = NULL;
|
||||
|
@ -141,7 +139,7 @@ static int checkout_all(void)
|
|||
if (last_ce && to_tempfile) {
|
||||
if (ce_namelen(last_ce) != ce_namelen(ce)
|
||||
|| memcmp(last_ce->name, ce->name, ce_namelen(ce)))
|
||||
write_tempfile_record(last_ce->name);
|
||||
write_tempfile_record(last_ce->name, prefix_length);
|
||||
}
|
||||
if (checkout_entry(ce, &state,
|
||||
to_tempfile ? topath[ce_stage(ce)] : NULL) < 0)
|
||||
|
@ -149,7 +147,7 @@ static int checkout_all(void)
|
|||
last_ce = ce;
|
||||
}
|
||||
if (last_ce && to_tempfile)
|
||||
write_tempfile_record(last_ce->name);
|
||||
write_tempfile_record(last_ce->name, prefix_length);
|
||||
if (errs)
|
||||
/* we have already done our error reporting.
|
||||
* exit with the same code as die().
|
||||
|
@ -163,16 +161,16 @@ static const char checkout_cache_usage[] =
|
|||
|
||||
static struct lock_file lock_file;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int cmd_checkout_index(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
int i;
|
||||
int newfd = -1;
|
||||
int all = 0;
|
||||
int read_from_stdin = 0;
|
||||
int prefix_length;
|
||||
|
||||
state.base_dir = "";
|
||||
prefix = setup_git_directory();
|
||||
git_config(git_default_config);
|
||||
state.base_dir = "";
|
||||
prefix_length = prefix ? strlen(prefix) : 0;
|
||||
|
||||
if (read_cache() < 0) {
|
||||
|
@ -270,7 +268,7 @@ int main(int argc, char **argv)
|
|||
if (read_from_stdin)
|
||||
die("git-checkout-index: don't mix '--stdin' and explicit filenames");
|
||||
p = prefix_path(prefix, prefix_length, arg);
|
||||
checkout_file(p);
|
||||
checkout_file(p, prefix_length);
|
||||
if (p < arg || p > arg + strlen(arg))
|
||||
free((char*)p);
|
||||
}
|
||||
|
@ -292,7 +290,7 @@ int main(int argc, char **argv)
|
|||
else
|
||||
path_name = buf.buf;
|
||||
p = prefix_path(prefix, prefix_length, path_name);
|
||||
checkout_file(p);
|
||||
checkout_file(p, prefix_length);
|
||||
if (p < path_name || p > path_name + strlen(path_name))
|
||||
free((char *)p);
|
||||
if (path_name != buf.buf)
|
||||
|
@ -301,7 +299,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (all)
|
||||
checkout_all();
|
||||
checkout_all(prefix, prefix_length);
|
||||
|
||||
if (0 <= newfd &&
|
||||
(write_cache(newfd, active_cache, active_nr) ||
|
|
@ -53,6 +53,7 @@ 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_unpack_objects(int argc, const char **argv, const char *prefix);
|
||||
extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);
|
||||
extern int cmd_checkout_index(int argc, const char **argv, const char *prefix);
|
||||
|
||||
extern int cmd_write_tree(int argc, const char **argv, const char *prefix);
|
||||
extern int write_tree(unsigned char *sha1, int missing_ok, const char *prefix);
|
||||
|
|
1
git.c
1
git.c
|
@ -269,6 +269,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
|
|||
{ "pack-objects", cmd_pack_objects, NEEDS_PREFIX },
|
||||
{ "unpack-objects", cmd_unpack_objects, NEEDS_PREFIX },
|
||||
{ "symbolic-ref", cmd_symbolic_ref, NEEDS_PREFIX },
|
||||
{ "checkout-index", cmd_checkout_index, NEEDS_PREFIX },
|
||||
};
|
||||
int i;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче