mirror of
https://github.com/git/git.git
synced 2024-11-23 09:56:28 +08:00
Merge branch 'en/header-split-cache-h-part-3'
Header files cleanup. * en/header-split-cache-h-part-3: (28 commits) fsmonitor-ll.h: split this header out of fsmonitor.h hash-ll, hashmap: move oidhash() to hash-ll object-store-ll.h: split this header out of object-store.h khash: name the structs that khash declares merge-ll: rename from ll-merge git-compat-util.h: remove unneccessary include of wildmatch.h builtin.h: remove unneccessary includes list-objects-filter-options.h: remove unneccessary include diff.h: remove unnecessary include of oidset.h repository: remove unnecessary include of path.h log-tree: replace include of revision.h with simple forward declaration cache.h: remove this no-longer-used header read-cache*.h: move declarations for read-cache.c functions from cache.h repository.h: move declaration of the_index from cache.h merge.h: move declarations for merge.c from cache.h diff.h: move declaration for global in diff.c from cache.h preload-index.h: move declarations for preload-index.c from elsewhere sparse-index.h: move declarations for sparse-index.c from cache.h name-hash.h: move declarations for name-hash.c from cache.h run-command.h: move declarations for run-command.c from cache.h ...
This commit is contained in:
commit
a1264a08a1
@ -448,7 +448,7 @@ For C programs:
|
||||
- The first #include in C files, except in platform specific compat/
|
||||
implementations and sha1dc/, must be either "git-compat-util.h" or
|
||||
one of the approved headers that includes it first for you. (The
|
||||
approved headers currently include "cache.h", "builtin.h",
|
||||
approved headers currently include "builtin.h",
|
||||
"t/helper/test-tool.h", "xdiff/xinclude.h", or
|
||||
"reftable/system.h"). You do not have to include more than one of
|
||||
these.
|
||||
|
@ -124,7 +124,7 @@ parameters provided by the user over the CLI.
|
||||
|
||||
`nr` represents the number of `rev_cmdline_entry` present in the array.
|
||||
|
||||
`alloc` is used by the `ALLOC_GROW` macro. Check `cache.h` - this variable is
|
||||
`alloc` is used by the `ALLOC_GROW` macro. Check `alloc.h` - this variable is
|
||||
used to track the allocated size of the list.
|
||||
|
||||
Per entry, we find:
|
||||
|
@ -28,9 +28,9 @@ and `diff.c` for examples.
|
||||
|
||||
* `struct ll_merge_options`
|
||||
|
||||
Check ll-merge.h for details.
|
||||
Check merge-ll.h for details.
|
||||
|
||||
Low-level (single file) merge
|
||||
-----------------------------
|
||||
|
||||
Check ll-merge.h for details.
|
||||
Check merge-ll.h for details.
|
||||
|
@ -4129,13 +4129,11 @@ Note that terminology has changed since that revision. For example, the
|
||||
README in that revision uses the word "changeset" to describe what we
|
||||
now call a <<def_commit_object,commit>>.
|
||||
|
||||
Also, we do not call it "cache" any more, but rather "index"; however, the
|
||||
file is still called `cache.h`. Remark: Not much reason to change it now,
|
||||
especially since there is no good single name for it anyway, because it is
|
||||
basically _the_ header file which is included by _all_ of Git's C sources.
|
||||
Also, we do not call it "cache" any more, but rather "index"; however,
|
||||
the file is still called `read-cache.h`.
|
||||
|
||||
If you grasp the ideas in that initial commit, you should check out a
|
||||
more recent version and skim `cache.h`, `object.h` and `commit.h`.
|
||||
more recent version and skim `read-cache-ll.h`, `object.h` and `commit.h`.
|
||||
|
||||
In the early days, Git (in the tradition of UNIX) was a bunch of programs
|
||||
which were extremely simple, and which you used in scripts, piping the
|
||||
@ -4146,11 +4144,11 @@ many of these parts have become builtins, and some of the core has been
|
||||
and to avoid code duplication.
|
||||
|
||||
By now, you know what the index is (and find the corresponding data
|
||||
structures in `cache.h`), and that there are just a couple of object types
|
||||
(blobs, trees, commits and tags) which inherit their common structure from
|
||||
`struct object`, which is their first member (and thus, you can cast e.g.
|
||||
`(struct object *)commit` to achieve the _same_ as `&commit->object`, i.e.
|
||||
get at the object name and flags).
|
||||
structures in `read-cache-ll.h`), and that there are just a couple of
|
||||
object types (blobs, trees, commits and tags) which inherit their
|
||||
common structure from `struct object`, which is their first member
|
||||
(and thus, you can cast e.g. `(struct object *)commit` to achieve the
|
||||
_same_ as `&commit->object`, i.e. get at the object name and flags).
|
||||
|
||||
Now is a good point to take a break to let this information sink in.
|
||||
|
||||
|
9
Makefile
9
Makefile
@ -1051,7 +1051,6 @@ LIB_OBJS += linear-assignment.o
|
||||
LIB_OBJS += list-objects-filter-options.o
|
||||
LIB_OBJS += list-objects-filter.o
|
||||
LIB_OBJS += list-objects.o
|
||||
LIB_OBJS += ll-merge.o
|
||||
LIB_OBJS += lockfile.o
|
||||
LIB_OBJS += log-tree.o
|
||||
LIB_OBJS += ls-refs.o
|
||||
@ -1060,6 +1059,7 @@ LIB_OBJS += mailmap.o
|
||||
LIB_OBJS += match-trees.o
|
||||
LIB_OBJS += mem-pool.o
|
||||
LIB_OBJS += merge-blobs.o
|
||||
LIB_OBJS += merge-ll.o
|
||||
LIB_OBJS += merge-ort.o
|
||||
LIB_OBJS += merge-ort-wrappers.o
|
||||
LIB_OBJS += merge-recursive.o
|
||||
@ -1142,6 +1142,7 @@ LIB_OBJS += sigchain.o
|
||||
LIB_OBJS += sparse-index.o
|
||||
LIB_OBJS += split-index.o
|
||||
LIB_OBJS += stable-qsort.o
|
||||
LIB_OBJS += statinfo.o
|
||||
LIB_OBJS += strbuf.o
|
||||
LIB_OBJS += streaming.o
|
||||
LIB_OBJS += string-list.o
|
||||
@ -1951,7 +1952,7 @@ endif
|
||||
BASIC_CFLAGS += \
|
||||
-DSHA1DC_NO_STANDARD_INCLUDES \
|
||||
-DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 \
|
||||
-DSHA1DC_CUSTOM_INCLUDE_SHA1_C="\"cache.h\"" \
|
||||
-DSHA1DC_CUSTOM_INCLUDE_SHA1_C="\"git-compat-util.h\"" \
|
||||
-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="\"git-compat-util.h\""
|
||||
endif
|
||||
endif
|
||||
@ -2742,8 +2743,8 @@ exec-cmd.sp exec-cmd.s exec-cmd.o: EXTRA_CPPFLAGS = \
|
||||
'-DBINDIR="$(bindir_relative_SQ)"' \
|
||||
'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
|
||||
|
||||
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
|
||||
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
|
||||
setup.sp setup.s setup.o: GIT-PREFIX
|
||||
setup.sp setup.s setup.o: EXTRA_CPPFLAGS = \
|
||||
-DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
|
||||
|
||||
config.sp config.s config.o: GIT-PREFIX
|
||||
|
@ -1,10 +1,14 @@
|
||||
#include "cache.h"
|
||||
#include "git-compat-util.h"
|
||||
#include "add-interactive.h"
|
||||
#include "color.h"
|
||||
#include "config.h"
|
||||
#include "diffcore.h"
|
||||
#include "gettext.h"
|
||||
#include "hash.h"
|
||||
#include "hex.h"
|
||||
#include "preload-index.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "repository.h"
|
||||
#include "revision.h"
|
||||
#include "refs.h"
|
||||
#include "string-list.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "cache.h"
|
||||
#include "git-compat-util.h"
|
||||
#include "add-interactive.h"
|
||||
#include "advice.h"
|
||||
#include "alloc.h"
|
||||
@ -6,6 +6,8 @@
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
#include "object-name.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "repository.h"
|
||||
#include "strbuf.h"
|
||||
#include "run-command.h"
|
||||
#include "strvec.h"
|
||||
|
10
apply.c
10
apply.c
@ -7,12 +7,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "git-compat-util.h"
|
||||
#include "abspath.h"
|
||||
#include "alloc.h"
|
||||
#include "base85.h"
|
||||
#include "config.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "blob.h"
|
||||
#include "delta.h"
|
||||
#include "diff.h"
|
||||
@ -21,17 +21,21 @@
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "xdiff-interface.h"
|
||||
#include "ll-merge.h"
|
||||
#include "merge-ll.h"
|
||||
#include "lockfile.h"
|
||||
#include "name-hash.h"
|
||||
#include "object-name.h"
|
||||
#include "object-file.h"
|
||||
#include "parse-options.h"
|
||||
#include "path.h"
|
||||
#include "quote.h"
|
||||
#include "read-cache.h"
|
||||
#include "rerere.h"
|
||||
#include "apply.h"
|
||||
#include "entry.h"
|
||||
#include "setup.h"
|
||||
#include "symlinks.h"
|
||||
#include "wildmatch.h"
|
||||
#include "ws.h"
|
||||
#include "wrapper.h"
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "hex.h"
|
||||
#include "tar.h"
|
||||
#include "archive.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "streaming.h"
|
||||
#include "run-command.h"
|
||||
#include "write-or-die.h"
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "hex.h"
|
||||
#include "streaming.h"
|
||||
#include "utf8.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "userdiff.h"
|
||||
#include "write-or-die.h"
|
||||
#include "xdiff-interface.h"
|
||||
|
@ -6,10 +6,11 @@
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "path.h"
|
||||
#include "pretty.h"
|
||||
#include "setup.h"
|
||||
#include "refs.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "commit.h"
|
||||
#include "tree.h"
|
||||
#include "tree-walk.h"
|
||||
|
6
attr.c
6
attr.c
@ -6,7 +6,7 @@
|
||||
* an insanely large number of attributes.
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "git-compat-util.h"
|
||||
#include "alloc.h"
|
||||
#include "config.h"
|
||||
#include "environment.h"
|
||||
@ -14,10 +14,12 @@
|
||||
#include "attr.h"
|
||||
#include "dir.h"
|
||||
#include "gettext.h"
|
||||
#include "path.h"
|
||||
#include "utf8.h"
|
||||
#include "quote.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "revision.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "setup.h"
|
||||
#include "thread-utils.h"
|
||||
#include "tree-walk.h"
|
||||
|
3
bisect.c
3
bisect.c
@ -18,7 +18,8 @@
|
||||
#include "commit-slab.h"
|
||||
#include "commit-reach.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "path.h"
|
||||
#include "dir.h"
|
||||
|
||||
static struct oid_array good_revs;
|
||||
|
6
blame.c
6
blame.c
@ -1,6 +1,6 @@
|
||||
#include "cache.h"
|
||||
#include "git-compat-util.h"
|
||||
#include "refs.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "cache-tree.h"
|
||||
#include "mergesort.h"
|
||||
#include "convert.h"
|
||||
@ -8,6 +8,8 @@
|
||||
#include "diffcore.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "path.h"
|
||||
#include "read-cache.h"
|
||||
#include "setup.h"
|
||||
#include "tag.h"
|
||||
#include "trace2.h"
|
||||
|
1
blame.h
1
blame.h
@ -2,6 +2,7 @@
|
||||
#define BLAME_H
|
||||
|
||||
#include "commit.h"
|
||||
#include "oidset.h"
|
||||
#include "xdiff-interface.h"
|
||||
#include "revision.h"
|
||||
#include "prio-queue.h"
|
||||
|
1
branch.c
1
branch.c
@ -6,6 +6,7 @@
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "object-name.h"
|
||||
#include "path.h"
|
||||
#include "refs.h"
|
||||
#include "refspec.h"
|
||||
#include "remote.h"
|
||||
|
@ -2,9 +2,6 @@
|
||||
#define BUILTIN_H
|
||||
|
||||
#include "git-compat-util.h"
|
||||
#include "strbuf.h"
|
||||
#include "cache.h"
|
||||
#include "commit.h"
|
||||
|
||||
/*
|
||||
* builtin API
|
||||
|
105
builtin/add.c
105
builtin/add.c
@ -4,10 +4,9 @@
|
||||
* Copyright (C) 2006 Linus Torvalds
|
||||
*/
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "advice.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "lockfile.h"
|
||||
#include "editor.h"
|
||||
#include "dir.h"
|
||||
@ -17,8 +16,12 @@
|
||||
#include "cache-tree.h"
|
||||
#include "run-command.h"
|
||||
#include "parse-options.h"
|
||||
#include "path.h"
|
||||
#include "preload-index.h"
|
||||
#include "diff.h"
|
||||
#include "diffcore.h"
|
||||
#include "read-cache.h"
|
||||
#include "repository.h"
|
||||
#include "revision.h"
|
||||
#include "bulk-checkin.h"
|
||||
#include "strvec.h"
|
||||
@ -36,11 +39,6 @@ static int pathspec_file_nul;
|
||||
static int include_sparse;
|
||||
static const char *pathspec_from_file;
|
||||
|
||||
struct update_callback_data {
|
||||
int flags;
|
||||
int add_errors;
|
||||
};
|
||||
|
||||
static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)
|
||||
{
|
||||
int i, ret = 0;
|
||||
@ -69,95 +67,6 @@ static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int fix_unmerged_status(struct diff_filepair *p,
|
||||
struct update_callback_data *data)
|
||||
{
|
||||
if (p->status != DIFF_STATUS_UNMERGED)
|
||||
return p->status;
|
||||
if (!(data->flags & ADD_CACHE_IGNORE_REMOVAL) && !p->two->mode)
|
||||
/*
|
||||
* This is not an explicit add request, and the
|
||||
* path is missing from the working tree (deleted)
|
||||
*/
|
||||
return DIFF_STATUS_DELETED;
|
||||
else
|
||||
/*
|
||||
* Either an explicit add request, or path exists
|
||||
* in the working tree. An attempt to explicitly
|
||||
* add a path that does not exist in the working tree
|
||||
* will be caught as an error by the caller immediately.
|
||||
*/
|
||||
return DIFF_STATUS_MODIFIED;
|
||||
}
|
||||
|
||||
static void update_callback(struct diff_queue_struct *q,
|
||||
struct diff_options *opt UNUSED, void *cbdata)
|
||||
{
|
||||
int i;
|
||||
struct update_callback_data *data = cbdata;
|
||||
|
||||
for (i = 0; i < q->nr; i++) {
|
||||
struct diff_filepair *p = q->queue[i];
|
||||
const char *path = p->one->path;
|
||||
|
||||
if (!include_sparse && !path_in_sparse_checkout(path, &the_index))
|
||||
continue;
|
||||
|
||||
switch (fix_unmerged_status(p, data)) {
|
||||
default:
|
||||
die(_("unexpected diff status %c"), p->status);
|
||||
case DIFF_STATUS_MODIFIED:
|
||||
case DIFF_STATUS_TYPE_CHANGED:
|
||||
if (add_file_to_index(&the_index, path, data->flags)) {
|
||||
if (!(data->flags & ADD_CACHE_IGNORE_ERRORS))
|
||||
die(_("updating files failed"));
|
||||
data->add_errors++;
|
||||
}
|
||||
break;
|
||||
case DIFF_STATUS_DELETED:
|
||||
if (data->flags & ADD_CACHE_IGNORE_REMOVAL)
|
||||
break;
|
||||
if (!(data->flags & ADD_CACHE_PRETEND))
|
||||
remove_file_from_index(&the_index, path);
|
||||
if (data->flags & (ADD_CACHE_PRETEND|ADD_CACHE_VERBOSE))
|
||||
printf(_("remove '%s'\n"), path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int add_files_to_cache(const char *prefix,
|
||||
const struct pathspec *pathspec, int flags)
|
||||
{
|
||||
struct update_callback_data data;
|
||||
struct rev_info rev;
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.flags = flags;
|
||||
|
||||
repo_init_revisions(the_repository, &rev, prefix);
|
||||
setup_revisions(0, NULL, &rev, NULL);
|
||||
if (pathspec)
|
||||
copy_pathspec(&rev.prune_data, pathspec);
|
||||
rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
|
||||
rev.diffopt.format_callback = update_callback;
|
||||
rev.diffopt.format_callback_data = &data;
|
||||
rev.diffopt.flags.override_submodule_config = 1;
|
||||
rev.max_count = 0; /* do not compare unmerged paths with stage #2 */
|
||||
|
||||
/*
|
||||
* Use an ODB transaction to optimize adding multiple objects.
|
||||
* This function is invoked from commands other than 'add', which
|
||||
* may not have their own transaction active.
|
||||
*/
|
||||
begin_odb_transaction();
|
||||
run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
|
||||
end_odb_transaction();
|
||||
|
||||
release_revisions(&rev);
|
||||
return !!data.add_errors;
|
||||
}
|
||||
|
||||
static int renormalize_tracked_files(const struct pathspec *pathspec, int flags)
|
||||
{
|
||||
int i, retval = 0;
|
||||
@ -640,7 +549,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
|
||||
if (add_renormalize)
|
||||
exit_status |= renormalize_tracked_files(&pathspec, flags);
|
||||
else
|
||||
exit_status |= add_files_to_cache(prefix, &pathspec, flags);
|
||||
exit_status |= add_files_to_cache(the_repository, prefix,
|
||||
&pathspec, include_sparse,
|
||||
flags);
|
||||
|
||||
if (add_new_files)
|
||||
exit_status |= add_files(&dir, flags);
|
||||
|
@ -4,11 +4,10 @@
|
||||
* Based on git-am.sh by Junio C Hamano.
|
||||
*/
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "abspath.h"
|
||||
#include "advice.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "editor.h"
|
||||
#include "environment.h"
|
||||
#include "exec-cmd.h"
|
||||
@ -29,6 +28,7 @@
|
||||
#include "unpack-trees.h"
|
||||
#include "branch.h"
|
||||
#include "object-name.h"
|
||||
#include "preload-index.h"
|
||||
#include "sequencer.h"
|
||||
#include "revision.h"
|
||||
#include "merge-recursive.h"
|
||||
@ -41,6 +41,7 @@
|
||||
#include "string-list.h"
|
||||
#include "packfile.h"
|
||||
#include "pager.h"
|
||||
#include "path.h"
|
||||
#include "repository.h"
|
||||
#include "pretty.h"
|
||||
#include "wrapper.h"
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "gettext.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -2,7 +2,6 @@
|
||||
* Copyright (c) 2006 Franck Bui-Huu
|
||||
* Copyright (c) 2006 Rene Scharfe
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "archive.h"
|
||||
#include "gettext.h"
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "copy.h"
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
@ -12,6 +11,7 @@
|
||||
#include "strvec.h"
|
||||
#include "run-command.h"
|
||||
#include "oid-array.h"
|
||||
#include "path.h"
|
||||
#include "prompt.h"
|
||||
#include "quote.h"
|
||||
#include "revision.h"
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "dir.h"
|
||||
#include "progress.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "pager.h"
|
||||
#include "blame.h"
|
||||
#include "refs.h"
|
||||
|
@ -5,20 +5,20 @@
|
||||
* Based on git-branch.sh by Junio C Hamano.
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "color.h"
|
||||
#include "editor.h"
|
||||
#include "environment.h"
|
||||
#include "refs.h"
|
||||
#include "commit.h"
|
||||
#include "builtin.h"
|
||||
#include "gettext.h"
|
||||
#include "object-name.h"
|
||||
#include "remote.h"
|
||||
#include "parse-options.h"
|
||||
#include "branch.h"
|
||||
#include "diff.h"
|
||||
#include "path.h"
|
||||
#include "revision.h"
|
||||
#include "string-list.h"
|
||||
#include "column.h"
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "parse-options.h"
|
||||
#include "pkt-line.h"
|
||||
#include "repository.h"
|
||||
#include "cache.h"
|
||||
#include "bundle.h"
|
||||
|
||||
/*
|
||||
|
@ -4,11 +4,10 @@
|
||||
* Copyright (C) Linus Torvalds, 2005
|
||||
*/
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "alloc.h"
|
||||
#include "config.h"
|
||||
#include "convert.h"
|
||||
#include "builtin.h"
|
||||
#include "diff.h"
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
@ -22,7 +21,7 @@
|
||||
#include "packfile.h"
|
||||
#include "object-file.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "replace-object.h"
|
||||
#include "promisor-remote.h"
|
||||
#include "mailmap.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "attr.h"
|
||||
#include "environment.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "dir.h"
|
||||
#include "gettext.h"
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "ident.h"
|
||||
#include "mailmap.h"
|
||||
#include "parse-options.h"
|
||||
#include "strbuf.h"
|
||||
#include "string-list.h"
|
||||
#include "write-or-die.h"
|
||||
|
||||
|
@ -2,9 +2,8 @@
|
||||
* GIT - The information manager from hell
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "refs.h"
|
||||
#include "builtin.h"
|
||||
#include "refs.h"
|
||||
#include "setup.h"
|
||||
#include "strbuf.h"
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "parallel-checkout.h"
|
||||
#include "parse-options.h"
|
||||
#include "pkt-line.h"
|
||||
#include "read-cache-ll.h"
|
||||
|
||||
static void packet_to_pc_item(const char *buffer, int len,
|
||||
struct parallel_checkout_item *pc_item)
|
||||
|
@ -16,7 +16,9 @@
|
||||
#include "parse-options.h"
|
||||
#include "entry.h"
|
||||
#include "parallel-checkout.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "setup.h"
|
||||
#include "sparse-index.h"
|
||||
|
||||
#define CHECKOUT_ALL 4
|
||||
static int nul_term_line;
|
||||
|
@ -13,13 +13,16 @@
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "hook.h"
|
||||
#include "ll-merge.h"
|
||||
#include "merge-ll.h"
|
||||
#include "lockfile.h"
|
||||
#include "mem-pool.h"
|
||||
#include "merge-recursive.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "parse-options.h"
|
||||
#include "path.h"
|
||||
#include "preload-index.h"
|
||||
#include "read-cache.h"
|
||||
#include "refs.h"
|
||||
#include "remote.h"
|
||||
#include "resolve-undo.h"
|
||||
@ -861,7 +864,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
|
||||
* entries in the index.
|
||||
*/
|
||||
|
||||
add_files_to_cache(NULL, NULL, 0);
|
||||
add_files_to_cache(the_repository, NULL, NULL, 0, 0);
|
||||
init_merge_options(&o, the_repository);
|
||||
o.verbosity = 0;
|
||||
work = write_in_core_index_as_tree(the_repository);
|
||||
|
@ -9,11 +9,12 @@
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "builtin.h"
|
||||
#include "abspath.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "dir.h"
|
||||
#include "gettext.h"
|
||||
#include "parse-options.h"
|
||||
#include "path.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "repository.h"
|
||||
#include "setup.h"
|
||||
#include "string-list.h"
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "refs.h"
|
||||
#include "refspec.h"
|
||||
#include "object-file.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "tree.h"
|
||||
#include "tree-walk.h"
|
||||
#include "unpack-trees.h"
|
||||
@ -39,6 +39,7 @@
|
||||
#include "setup.h"
|
||||
#include "connected.h"
|
||||
#include "packfile.h"
|
||||
#include "path.h"
|
||||
#include "pkt-line.h"
|
||||
#include "list-objects-filter-options.h"
|
||||
#include "hook.h"
|
||||
@ -930,6 +931,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
||||
int submodule_progress;
|
||||
int filter_submodules = 0;
|
||||
int hash_algo;
|
||||
const int do_not_override_repo_unix_permissions = -1;
|
||||
|
||||
struct transport_ls_refs_options transport_ls_refs_options =
|
||||
TRANSPORT_LS_REFS_OPTIONS_INIT;
|
||||
@ -1097,7 +1099,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
||||
}
|
||||
|
||||
init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN, NULL,
|
||||
INIT_DB_QUIET);
|
||||
do_not_override_repo_unix_permissions, INIT_DB_QUIET);
|
||||
|
||||
if (real_git_dir) {
|
||||
free((char *)git_dir);
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
#include "strbuf.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "builtin.h"
|
||||
#include "commit.h"
|
||||
#include "config.h"
|
||||
#include "dir.h"
|
||||
#include "environment.h"
|
||||
@ -8,7 +9,7 @@
|
||||
#include "parse-options.h"
|
||||
#include "repository.h"
|
||||
#include "commit-graph.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "progress.h"
|
||||
#include "replace-object.h"
|
||||
#include "tag.h"
|
||||
|
@ -3,16 +3,15 @@
|
||||
*
|
||||
* Copyright (C) Linus Torvalds, 2005
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "repository.h"
|
||||
#include "commit.h"
|
||||
#include "tree.h"
|
||||
#include "builtin.h"
|
||||
#include "utf8.h"
|
||||
#include "gpg-interface.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "advice.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
@ -15,7 +15,6 @@
|
||||
#include "dir.h"
|
||||
#include "editor.h"
|
||||
#include "environment.h"
|
||||
#include "builtin.h"
|
||||
#include "diff.h"
|
||||
#include "diffcore.h"
|
||||
#include "commit.h"
|
||||
@ -30,6 +29,9 @@
|
||||
#include "utf8.h"
|
||||
#include "object-name.h"
|
||||
#include "parse-options.h"
|
||||
#include "path.h"
|
||||
#include "preload-index.h"
|
||||
#include "read-cache.h"
|
||||
#include "string-list.h"
|
||||
#include "rerere.h"
|
||||
#include "unpack-trees.h"
|
||||
@ -38,6 +40,7 @@
|
||||
#include "gpg-interface.h"
|
||||
#include "column.h"
|
||||
#include "sequencer.h"
|
||||
#include "sparse-index.h"
|
||||
#include "mailmap.h"
|
||||
#include "help.h"
|
||||
#include "commit-reach.h"
|
||||
@ -447,7 +450,8 @@ static const char *prepare_index(const char **argv, const char *prefix,
|
||||
if (all || (also && pathspec.nr)) {
|
||||
repo_hold_locked_index(the_repository, &index_lock,
|
||||
LOCK_DIE_ON_ERROR);
|
||||
add_files_to_cache(also ? prefix : NULL, &pathspec, 0);
|
||||
add_files_to_cache(the_repository, also ? prefix : NULL,
|
||||
&pathspec, 0, 0);
|
||||
refresh_cache_or_die(refresh_flags);
|
||||
cache_tree_update(&the_index, WRITE_TREE_SILENT);
|
||||
if (write_locked_index(&the_index, &index_lock, 0))
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "path.h"
|
||||
#include "quote.h"
|
||||
#include "setup.h"
|
||||
#include "strbuf.h"
|
||||
#include "worktree.h"
|
||||
#include "wrapper.h"
|
||||
|
||||
|
@ -4,17 +4,17 @@
|
||||
* Copyright (c) 2006 Junio C Hamano
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "dir.h"
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
#include "path.h"
|
||||
#include "repository.h"
|
||||
#include "builtin.h"
|
||||
#include "parse-options.h"
|
||||
#include "quote.h"
|
||||
#include "packfile.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
|
||||
static unsigned long garbage;
|
||||
static off_t size_garbage;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "gettext.h"
|
||||
#include "parse-options.h"
|
||||
#include "path.h"
|
||||
#include "strbuf.h"
|
||||
#include "wrapper.h"
|
||||
#include "write-or-die.h"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
@ -9,19 +9,20 @@
|
||||
#include "tag.h"
|
||||
#include "blob.h"
|
||||
#include "refs.h"
|
||||
#include "builtin.h"
|
||||
#include "exec-cmd.h"
|
||||
#include "object-name.h"
|
||||
#include "parse-options.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "revision.h"
|
||||
#include "diff.h"
|
||||
#include "hashmap.h"
|
||||
#include "setup.h"
|
||||
#include "strvec.h"
|
||||
#include "run-command.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "list-objects.h"
|
||||
#include "commit-slab.h"
|
||||
#include "wildmatch.h"
|
||||
|
||||
#define MAX_TAGS (FLAG_BITS - 1)
|
||||
|
||||
|
@ -3,13 +3,14 @@
|
||||
*
|
||||
* Copyright (C) Linus Torvalds, 2005
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "diff.h"
|
||||
#include "diff-merges.h"
|
||||
#include "commit.h"
|
||||
#include "preload-index.h"
|
||||
#include "repository.h"
|
||||
#include "revision.h"
|
||||
#include "builtin.h"
|
||||
#include "submodule.h"
|
||||
|
||||
static const char diff_files_usage[] =
|
||||
|
@ -1,11 +1,13 @@
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "diff.h"
|
||||
#include "diff-merges.h"
|
||||
#include "commit.h"
|
||||
#include "preload-index.h"
|
||||
#include "repository.h"
|
||||
#include "revision.h"
|
||||
#include "builtin.h"
|
||||
#include "setup.h"
|
||||
#include "sparse-index.h"
|
||||
#include "submodule.h"
|
||||
|
||||
static const char diff_cache_usage[] =
|
||||
|
@ -1,14 +1,15 @@
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "diff.h"
|
||||
#include "commit.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "log-tree.h"
|
||||
#include "builtin.h"
|
||||
#include "submodule.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "repository.h"
|
||||
#include "revision.h"
|
||||
#include "tree.h"
|
||||
|
||||
static struct rev_info log_tree_opt;
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Copyright (c) 2006 Junio C Hamano
|
||||
*/
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "ewah/ewok.h"
|
||||
#include "lockfile.h"
|
||||
@ -16,9 +16,10 @@
|
||||
#include "diff.h"
|
||||
#include "diff-merges.h"
|
||||
#include "diffcore.h"
|
||||
#include "preload-index.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "revision.h"
|
||||
#include "log-tree.h"
|
||||
#include "builtin.h"
|
||||
#include "setup.h"
|
||||
#include "submodule.h"
|
||||
#include "oid-array.h"
|
||||
|
@ -12,22 +12,23 @@
|
||||
* Copyright (C) 2016 Johannes Schindelin
|
||||
*/
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "abspath.h"
|
||||
#include "config.h"
|
||||
#include "copy.h"
|
||||
#include "builtin.h"
|
||||
#include "run-command.h"
|
||||
#include "environment.h"
|
||||
#include "exec-cmd.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "parse-options.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "sparse-index.h"
|
||||
#include "strvec.h"
|
||||
#include "strbuf.h"
|
||||
#include "lockfile.h"
|
||||
#include "object-file.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "dir.h"
|
||||
#include "entry.h"
|
||||
#include "setup.h"
|
||||
|
@ -4,14 +4,13 @@
|
||||
* Copyright (C) 2007 Johannes E. Schindelin
|
||||
*/
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "refs.h"
|
||||
#include "refspec.h"
|
||||
#include "object-file.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "commit.h"
|
||||
#include "object.h"
|
||||
#include "tag.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "builtin.h"
|
||||
#include "abspath.h"
|
||||
#include "cache.h"
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
@ -13,6 +12,7 @@
|
||||
#include "commit.h"
|
||||
#include "delta.h"
|
||||
#include "pack.h"
|
||||
#include "path.h"
|
||||
#include "refs.h"
|
||||
#include "csum-file.h"
|
||||
#include "quote.h"
|
||||
@ -21,7 +21,7 @@
|
||||
#include "packfile.h"
|
||||
#include "object-file.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "mem-pool.h"
|
||||
#include "commit-reach.h"
|
||||
#include "khash.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* "git fetch"
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "advice.h"
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
@ -11,11 +11,10 @@
|
||||
#include "refs.h"
|
||||
#include "refspec.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "oidset.h"
|
||||
#include "oid-array.h"
|
||||
#include "commit.h"
|
||||
#include "builtin.h"
|
||||
#include "string-list.h"
|
||||
#include "remote.h"
|
||||
#include "transport.h"
|
||||
@ -29,6 +28,7 @@
|
||||
#include "utf8.h"
|
||||
#include "packfile.h"
|
||||
#include "pager.h"
|
||||
#include "path.h"
|
||||
#include "pkt-line.h"
|
||||
#include "list-objects-filter-options.h"
|
||||
#include "commit-reach.h"
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
#include "refs.h"
|
||||
#include "object.h"
|
||||
#include "parse-options.h"
|
||||
#include "ref-filter.h"
|
||||
#include "strbuf.h"
|
||||
#include "strvec.h"
|
||||
#include "commit-reach.h"
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
#include "parse-options.h"
|
||||
#include "path.h"
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "repository.h"
|
||||
@ -21,10 +20,13 @@
|
||||
#include "packfile.h"
|
||||
#include "object-file.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "path.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "replace-object.h"
|
||||
#include "resolve-undo.h"
|
||||
#include "run-command.h"
|
||||
#include "sparse-index.h"
|
||||
#include "worktree.h"
|
||||
#include "pack-revindex.h"
|
||||
#include "pack-bitmap.h"
|
||||
|
@ -5,15 +5,17 @@
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
#include "parse-options.h"
|
||||
#include "fsmonitor.h"
|
||||
#include "fsmonitor-ll.h"
|
||||
#include "fsmonitor-ipc.h"
|
||||
#include "fsmonitor-path-utils.h"
|
||||
#include "fsmonitor-settings.h"
|
||||
#include "compat/fsmonitor/fsm-health.h"
|
||||
#include "compat/fsmonitor/fsm-listen.h"
|
||||
#include "fsmonitor--daemon.h"
|
||||
#include "simple-ipc.h"
|
||||
#include "khash.h"
|
||||
#include "pkt-line.h"
|
||||
#include "trace.h"
|
||||
#include "trace2.h"
|
||||
|
||||
static const char * const builtin_fsmonitor__daemon_usage[] = {
|
||||
|
@ -27,9 +27,10 @@
|
||||
#include "commit-graph.h"
|
||||
#include "packfile.h"
|
||||
#include "object-file.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "pack.h"
|
||||
#include "pack-objects.h"
|
||||
#include "path.h"
|
||||
#include "blob.h"
|
||||
#include "tree.h"
|
||||
#include "promisor-remote.h"
|
||||
|
@ -1,10 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006 Rene Scharfe
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "commit.h"
|
||||
#include "tar.h"
|
||||
#include "builtin.h"
|
||||
#include "quote.h"
|
||||
#include "wrapper.h"
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (c) 2006 Junio C Hamano
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "alloc.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
@ -14,7 +14,6 @@
|
||||
#include "commit.h"
|
||||
#include "tag.h"
|
||||
#include "tree-walk.h"
|
||||
#include "builtin.h"
|
||||
#include "parse-options.h"
|
||||
#include "string-list.h"
|
||||
#include "run-command.h"
|
||||
@ -28,9 +27,11 @@
|
||||
#include "submodule-config.h"
|
||||
#include "object-file.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "packfile.h"
|
||||
#include "pager.h"
|
||||
#include "path.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "write-or-die.h"
|
||||
|
||||
static const char *grep_prefix;
|
||||
|
@ -10,12 +10,13 @@
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "object-file.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "blob.h"
|
||||
#include "quote.h"
|
||||
#include "parse-options.h"
|
||||
#include "exec-cmd.h"
|
||||
#include "setup.h"
|
||||
#include "strbuf.h"
|
||||
#include "write-or-die.h"
|
||||
|
||||
/*
|
||||
|
@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Builtin help command
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "exec-cmd.h"
|
||||
#include "gettext.h"
|
||||
#include "pager.h"
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
|
@ -14,12 +14,13 @@
|
||||
#include "progress.h"
|
||||
#include "fsck.h"
|
||||
#include "exec-cmd.h"
|
||||
#include "strbuf.h"
|
||||
#include "streaming.h"
|
||||
#include "thread-utils.h"
|
||||
#include "packfile.h"
|
||||
#include "pack-revindex.h"
|
||||
#include "object-file.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "oid-array.h"
|
||||
#include "replace-object.h"
|
||||
#include "promisor-remote.h"
|
||||
|
@ -3,485 +3,18 @@
|
||||
*
|
||||
* Copyright (C) Linus Torvalds, 2005
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "abspath.h"
|
||||
#include "config.h"
|
||||
#include "copy.h"
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
#include "refs.h"
|
||||
#include "builtin.h"
|
||||
#include "exec-cmd.h"
|
||||
#include "object-file.h"
|
||||
#include "parse-options.h"
|
||||
#include "path.h"
|
||||
#include "setup.h"
|
||||
#include "worktree.h"
|
||||
#include "strbuf.h"
|
||||
#include "wrapper.h"
|
||||
|
||||
#ifndef DEFAULT_GIT_TEMPLATE_DIR
|
||||
#define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates"
|
||||
#endif
|
||||
|
||||
#ifdef NO_TRUSTABLE_FILEMODE
|
||||
#define TEST_FILEMODE 0
|
||||
#else
|
||||
#define TEST_FILEMODE 1
|
||||
#endif
|
||||
|
||||
#define GIT_DEFAULT_HASH_ENVIRONMENT "GIT_DEFAULT_HASH"
|
||||
|
||||
static int init_is_bare_repository = 0;
|
||||
static int init_shared_repository = -1;
|
||||
|
||||
static void copy_templates_1(struct strbuf *path, struct strbuf *template_path,
|
||||
DIR *dir)
|
||||
{
|
||||
size_t path_baselen = path->len;
|
||||
size_t template_baselen = template_path->len;
|
||||
struct dirent *de;
|
||||
|
||||
/* Note: if ".git/hooks" file exists in the repository being
|
||||
* re-initialized, /etc/core-git/templates/hooks/update would
|
||||
* cause "git init" to fail here. I think this is sane but
|
||||
* it means that the set of templates we ship by default, along
|
||||
* with the way the namespace under .git/ is organized, should
|
||||
* be really carefully chosen.
|
||||
*/
|
||||
safe_create_dir(path->buf, 1);
|
||||
while ((de = readdir(dir)) != NULL) {
|
||||
struct stat st_git, st_template;
|
||||
int exists = 0;
|
||||
|
||||
strbuf_setlen(path, path_baselen);
|
||||
strbuf_setlen(template_path, template_baselen);
|
||||
|
||||
if (de->d_name[0] == '.')
|
||||
continue;
|
||||
strbuf_addstr(path, de->d_name);
|
||||
strbuf_addstr(template_path, de->d_name);
|
||||
if (lstat(path->buf, &st_git)) {
|
||||
if (errno != ENOENT)
|
||||
die_errno(_("cannot stat '%s'"), path->buf);
|
||||
}
|
||||
else
|
||||
exists = 1;
|
||||
|
||||
if (lstat(template_path->buf, &st_template))
|
||||
die_errno(_("cannot stat template '%s'"), template_path->buf);
|
||||
|
||||
if (S_ISDIR(st_template.st_mode)) {
|
||||
DIR *subdir = opendir(template_path->buf);
|
||||
if (!subdir)
|
||||
die_errno(_("cannot opendir '%s'"), template_path->buf);
|
||||
strbuf_addch(path, '/');
|
||||
strbuf_addch(template_path, '/');
|
||||
copy_templates_1(path, template_path, subdir);
|
||||
closedir(subdir);
|
||||
}
|
||||
else if (exists)
|
||||
continue;
|
||||
else if (S_ISLNK(st_template.st_mode)) {
|
||||
struct strbuf lnk = STRBUF_INIT;
|
||||
if (strbuf_readlink(&lnk, template_path->buf,
|
||||
st_template.st_size) < 0)
|
||||
die_errno(_("cannot readlink '%s'"), template_path->buf);
|
||||
if (symlink(lnk.buf, path->buf))
|
||||
die_errno(_("cannot symlink '%s' '%s'"),
|
||||
lnk.buf, path->buf);
|
||||
strbuf_release(&lnk);
|
||||
}
|
||||
else if (S_ISREG(st_template.st_mode)) {
|
||||
if (copy_file(path->buf, template_path->buf, st_template.st_mode))
|
||||
die_errno(_("cannot copy '%s' to '%s'"),
|
||||
template_path->buf, path->buf);
|
||||
}
|
||||
else
|
||||
error(_("ignoring template %s"), template_path->buf);
|
||||
}
|
||||
}
|
||||
|
||||
static void copy_templates(const char *template_dir, const char *init_template_dir)
|
||||
{
|
||||
struct strbuf path = STRBUF_INIT;
|
||||
struct strbuf template_path = STRBUF_INIT;
|
||||
size_t template_len;
|
||||
struct repository_format template_format = REPOSITORY_FORMAT_INIT;
|
||||
struct strbuf err = STRBUF_INIT;
|
||||
DIR *dir;
|
||||
char *to_free = NULL;
|
||||
|
||||
if (!template_dir)
|
||||
template_dir = getenv(TEMPLATE_DIR_ENVIRONMENT);
|
||||
if (!template_dir)
|
||||
template_dir = init_template_dir;
|
||||
if (!template_dir)
|
||||
template_dir = to_free = system_path(DEFAULT_GIT_TEMPLATE_DIR);
|
||||
if (!template_dir[0]) {
|
||||
free(to_free);
|
||||
return;
|
||||
}
|
||||
|
||||
strbuf_addstr(&template_path, template_dir);
|
||||
strbuf_complete(&template_path, '/');
|
||||
template_len = template_path.len;
|
||||
|
||||
dir = opendir(template_path.buf);
|
||||
if (!dir) {
|
||||
warning(_("templates not found in %s"), template_dir);
|
||||
goto free_return;
|
||||
}
|
||||
|
||||
/* Make sure that template is from the correct vintage */
|
||||
strbuf_addstr(&template_path, "config");
|
||||
read_repository_format(&template_format, template_path.buf);
|
||||
strbuf_setlen(&template_path, template_len);
|
||||
|
||||
/*
|
||||
* No mention of version at all is OK, but anything else should be
|
||||
* verified.
|
||||
*/
|
||||
if (template_format.version >= 0 &&
|
||||
verify_repository_format(&template_format, &err) < 0) {
|
||||
warning(_("not copying templates from '%s': %s"),
|
||||
template_dir, err.buf);
|
||||
strbuf_release(&err);
|
||||
goto close_free_return;
|
||||
}
|
||||
|
||||
strbuf_addstr(&path, get_git_common_dir());
|
||||
strbuf_complete(&path, '/');
|
||||
copy_templates_1(&path, &template_path, dir);
|
||||
close_free_return:
|
||||
closedir(dir);
|
||||
free_return:
|
||||
free(to_free);
|
||||
strbuf_release(&path);
|
||||
strbuf_release(&template_path);
|
||||
clear_repository_format(&template_format);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the git_dir is not directly inside the working tree, then git will not
|
||||
* find it by default, and we need to set the worktree explicitly.
|
||||
*/
|
||||
static int needs_work_tree_config(const char *git_dir, const char *work_tree)
|
||||
{
|
||||
if (!strcmp(work_tree, "/") && !strcmp(git_dir, "/.git"))
|
||||
return 0;
|
||||
if (skip_prefix(git_dir, work_tree, &git_dir) &&
|
||||
!strcmp(git_dir, "/.git"))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void initialize_repository_version(int hash_algo, int reinit)
|
||||
{
|
||||
char repo_version_string[10];
|
||||
int repo_version = GIT_REPO_VERSION;
|
||||
|
||||
if (hash_algo != GIT_HASH_SHA1)
|
||||
repo_version = GIT_REPO_VERSION_READ;
|
||||
|
||||
/* This forces creation of new config file */
|
||||
xsnprintf(repo_version_string, sizeof(repo_version_string),
|
||||
"%d", repo_version);
|
||||
git_config_set("core.repositoryformatversion", repo_version_string);
|
||||
|
||||
if (hash_algo != GIT_HASH_SHA1)
|
||||
git_config_set("extensions.objectformat",
|
||||
hash_algos[hash_algo].name);
|
||||
else if (reinit)
|
||||
git_config_set_gently("extensions.objectformat", NULL);
|
||||
}
|
||||
|
||||
static int create_default_files(const char *template_path,
|
||||
const char *original_git_dir,
|
||||
const char *initial_branch,
|
||||
const struct repository_format *fmt,
|
||||
int quiet)
|
||||
{
|
||||
struct stat st1;
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
char *path;
|
||||
char junk[2];
|
||||
int reinit;
|
||||
int filemode;
|
||||
struct strbuf err = STRBUF_INIT;
|
||||
const char *init_template_dir = NULL;
|
||||
const char *work_tree = get_git_work_tree();
|
||||
|
||||
/*
|
||||
* First copy the templates -- we might have the default
|
||||
* config file there, in which case we would want to read
|
||||
* from it after installing.
|
||||
*
|
||||
* Before reading that config, we also need to clear out any cached
|
||||
* values (since we've just potentially changed what's available on
|
||||
* disk).
|
||||
*/
|
||||
git_config_get_pathname("init.templatedir", &init_template_dir);
|
||||
copy_templates(template_path, init_template_dir);
|
||||
free((char *)init_template_dir);
|
||||
git_config_clear();
|
||||
reset_shared_repository();
|
||||
git_config(git_default_config, NULL);
|
||||
|
||||
/*
|
||||
* We must make sure command-line options continue to override any
|
||||
* values we might have just re-read from the config.
|
||||
*/
|
||||
is_bare_repository_cfg = init_is_bare_repository || !work_tree;
|
||||
if (init_shared_repository != -1)
|
||||
set_shared_repository(init_shared_repository);
|
||||
|
||||
/*
|
||||
* We would have created the above under user's umask -- under
|
||||
* shared-repository settings, we would need to fix them up.
|
||||
*/
|
||||
if (get_shared_repository()) {
|
||||
adjust_shared_perm(get_git_dir());
|
||||
}
|
||||
|
||||
/*
|
||||
* We need to create a "refs" dir in any case so that older
|
||||
* versions of git can tell that this is a repository.
|
||||
*/
|
||||
safe_create_dir(git_path("refs"), 1);
|
||||
adjust_shared_perm(git_path("refs"));
|
||||
|
||||
if (refs_init_db(&err))
|
||||
die("failed to set up refs db: %s", err.buf);
|
||||
|
||||
/*
|
||||
* Point the HEAD symref to the initial branch with if HEAD does
|
||||
* not yet exist.
|
||||
*/
|
||||
path = git_path_buf(&buf, "HEAD");
|
||||
reinit = (!access(path, R_OK)
|
||||
|| readlink(path, junk, sizeof(junk)-1) != -1);
|
||||
if (!reinit) {
|
||||
char *ref;
|
||||
|
||||
if (!initial_branch)
|
||||
initial_branch = git_default_branch_name(quiet);
|
||||
|
||||
ref = xstrfmt("refs/heads/%s", initial_branch);
|
||||
if (check_refname_format(ref, 0) < 0)
|
||||
die(_("invalid initial branch name: '%s'"),
|
||||
initial_branch);
|
||||
|
||||
if (create_symref("HEAD", ref, NULL) < 0)
|
||||
exit(1);
|
||||
free(ref);
|
||||
}
|
||||
|
||||
initialize_repository_version(fmt->hash_algo, 0);
|
||||
|
||||
/* Check filemode trustability */
|
||||
path = git_path_buf(&buf, "config");
|
||||
filemode = TEST_FILEMODE;
|
||||
if (TEST_FILEMODE && !lstat(path, &st1)) {
|
||||
struct stat st2;
|
||||
filemode = (!chmod(path, st1.st_mode ^ S_IXUSR) &&
|
||||
!lstat(path, &st2) &&
|
||||
st1.st_mode != st2.st_mode &&
|
||||
!chmod(path, st1.st_mode));
|
||||
if (filemode && !reinit && (st1.st_mode & S_IXUSR))
|
||||
filemode = 0;
|
||||
}
|
||||
git_config_set("core.filemode", filemode ? "true" : "false");
|
||||
|
||||
if (is_bare_repository())
|
||||
git_config_set("core.bare", "true");
|
||||
else {
|
||||
git_config_set("core.bare", "false");
|
||||
/* allow template config file to override the default */
|
||||
if (log_all_ref_updates == LOG_REFS_UNSET)
|
||||
git_config_set("core.logallrefupdates", "true");
|
||||
if (needs_work_tree_config(original_git_dir, work_tree))
|
||||
git_config_set("core.worktree", work_tree);
|
||||
}
|
||||
|
||||
if (!reinit) {
|
||||
/* Check if symlink is supported in the work tree */
|
||||
path = git_path_buf(&buf, "tXXXXXX");
|
||||
if (!close(xmkstemp(path)) &&
|
||||
!unlink(path) &&
|
||||
!symlink("testing", path) &&
|
||||
!lstat(path, &st1) &&
|
||||
S_ISLNK(st1.st_mode))
|
||||
unlink(path); /* good */
|
||||
else
|
||||
git_config_set("core.symlinks", "false");
|
||||
|
||||
/* Check if the filesystem is case-insensitive */
|
||||
path = git_path_buf(&buf, "CoNfIg");
|
||||
if (!access(path, F_OK))
|
||||
git_config_set("core.ignorecase", "true");
|
||||
probe_utf8_pathname_composition();
|
||||
}
|
||||
|
||||
strbuf_release(&buf);
|
||||
return reinit;
|
||||
}
|
||||
|
||||
static void create_object_directory(void)
|
||||
{
|
||||
struct strbuf path = STRBUF_INIT;
|
||||
size_t baselen;
|
||||
|
||||
strbuf_addstr(&path, get_object_directory());
|
||||
baselen = path.len;
|
||||
|
||||
safe_create_dir(path.buf, 1);
|
||||
|
||||
strbuf_setlen(&path, baselen);
|
||||
strbuf_addstr(&path, "/pack");
|
||||
safe_create_dir(path.buf, 1);
|
||||
|
||||
strbuf_setlen(&path, baselen);
|
||||
strbuf_addstr(&path, "/info");
|
||||
safe_create_dir(path.buf, 1);
|
||||
|
||||
strbuf_release(&path);
|
||||
}
|
||||
|
||||
static void separate_git_dir(const char *git_dir, const char *git_link)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (!stat(git_link, &st)) {
|
||||
const char *src;
|
||||
|
||||
if (S_ISREG(st.st_mode))
|
||||
src = read_gitfile(git_link);
|
||||
else if (S_ISDIR(st.st_mode))
|
||||
src = git_link;
|
||||
else
|
||||
die(_("unable to handle file type %d"), (int)st.st_mode);
|
||||
|
||||
if (rename(src, git_dir))
|
||||
die_errno(_("unable to move %s to %s"), src, git_dir);
|
||||
repair_worktrees(NULL, NULL);
|
||||
}
|
||||
|
||||
write_file(git_link, "gitdir: %s", git_dir);
|
||||
}
|
||||
|
||||
static void validate_hash_algorithm(struct repository_format *repo_fmt, int hash)
|
||||
{
|
||||
const char *env = getenv(GIT_DEFAULT_HASH_ENVIRONMENT);
|
||||
/*
|
||||
* If we already have an initialized repo, don't allow the user to
|
||||
* specify a different algorithm, as that could cause corruption.
|
||||
* Otherwise, if the user has specified one on the command line, use it.
|
||||
*/
|
||||
if (repo_fmt->version >= 0 && hash != GIT_HASH_UNKNOWN && hash != repo_fmt->hash_algo)
|
||||
die(_("attempt to reinitialize repository with different hash"));
|
||||
else if (hash != GIT_HASH_UNKNOWN)
|
||||
repo_fmt->hash_algo = hash;
|
||||
else if (env) {
|
||||
int env_algo = hash_algo_by_name(env);
|
||||
if (env_algo == GIT_HASH_UNKNOWN)
|
||||
die(_("unknown hash algorithm '%s'"), env);
|
||||
repo_fmt->hash_algo = env_algo;
|
||||
}
|
||||
}
|
||||
|
||||
int init_db(const char *git_dir, const char *real_git_dir,
|
||||
const char *template_dir, int hash, const char *initial_branch,
|
||||
unsigned int flags)
|
||||
{
|
||||
int reinit;
|
||||
int exist_ok = flags & INIT_DB_EXIST_OK;
|
||||
char *original_git_dir = real_pathdup(git_dir, 1);
|
||||
struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;
|
||||
|
||||
if (real_git_dir) {
|
||||
struct stat st;
|
||||
|
||||
if (!exist_ok && !stat(git_dir, &st))
|
||||
die(_("%s already exists"), git_dir);
|
||||
|
||||
if (!exist_ok && !stat(real_git_dir, &st))
|
||||
die(_("%s already exists"), real_git_dir);
|
||||
|
||||
set_git_dir(real_git_dir, 1);
|
||||
git_dir = get_git_dir();
|
||||
separate_git_dir(git_dir, original_git_dir);
|
||||
}
|
||||
else {
|
||||
set_git_dir(git_dir, 1);
|
||||
git_dir = get_git_dir();
|
||||
}
|
||||
startup_info->have_repository = 1;
|
||||
|
||||
/* Ensure `core.hidedotfiles` is processed */
|
||||
git_config(platform_core_config, NULL);
|
||||
|
||||
safe_create_dir(git_dir, 0);
|
||||
|
||||
init_is_bare_repository = is_bare_repository();
|
||||
|
||||
/* Check to see if the repository version is right.
|
||||
* Note that a newly created repository does not have
|
||||
* config file, so this will not fail. What we are catching
|
||||
* is an attempt to reinitialize new repository with an old tool.
|
||||
*/
|
||||
check_repository_format(&repo_fmt);
|
||||
|
||||
validate_hash_algorithm(&repo_fmt, hash);
|
||||
|
||||
reinit = create_default_files(template_dir, original_git_dir,
|
||||
initial_branch, &repo_fmt,
|
||||
flags & INIT_DB_QUIET);
|
||||
if (reinit && initial_branch)
|
||||
warning(_("re-init: ignored --initial-branch=%s"),
|
||||
initial_branch);
|
||||
|
||||
create_object_directory();
|
||||
|
||||
if (get_shared_repository()) {
|
||||
char buf[10];
|
||||
/* We do not spell "group" and such, so that
|
||||
* the configuration can be read by older version
|
||||
* of git. Note, we use octal numbers for new share modes,
|
||||
* and compatibility values for PERM_GROUP and
|
||||
* PERM_EVERYBODY.
|
||||
*/
|
||||
if (get_shared_repository() < 0)
|
||||
/* force to the mode value */
|
||||
xsnprintf(buf, sizeof(buf), "0%o", -get_shared_repository());
|
||||
else if (get_shared_repository() == PERM_GROUP)
|
||||
xsnprintf(buf, sizeof(buf), "%d", OLD_PERM_GROUP);
|
||||
else if (get_shared_repository() == PERM_EVERYBODY)
|
||||
xsnprintf(buf, sizeof(buf), "%d", OLD_PERM_EVERYBODY);
|
||||
else
|
||||
BUG("invalid value for shared_repository");
|
||||
git_config_set("core.sharedrepository", buf);
|
||||
git_config_set("receive.denyNonFastforwards", "true");
|
||||
}
|
||||
|
||||
if (!(flags & INIT_DB_QUIET)) {
|
||||
int len = strlen(git_dir);
|
||||
|
||||
if (reinit)
|
||||
printf(get_shared_repository()
|
||||
? _("Reinitialized existing shared Git repository in %s%s\n")
|
||||
: _("Reinitialized existing Git repository in %s%s\n"),
|
||||
git_dir, len && git_dir[len-1] != '/' ? "/" : "");
|
||||
else
|
||||
printf(get_shared_repository()
|
||||
? _("Initialized empty shared Git repository in %s%s\n")
|
||||
: _("Initialized empty Git repository in %s%s\n"),
|
||||
git_dir, len && git_dir[len-1] != '/' ? "/" : "");
|
||||
}
|
||||
|
||||
free(original_git_dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int guess_repository_type(const char *git_dir)
|
||||
{
|
||||
const char *slash;
|
||||
@ -546,6 +79,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
|
||||
const char *object_format = NULL;
|
||||
const char *initial_branch = NULL;
|
||||
int hash_algo = GIT_HASH_UNKNOWN;
|
||||
int init_shared_repository = -1;
|
||||
const struct option init_db_options[] = {
|
||||
OPT_STRING(0, "template", &template_dir, N_("template-directory"),
|
||||
N_("directory from which templates will be used")),
|
||||
@ -703,5 +237,5 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
|
||||
|
||||
flags |= INIT_DB_EXIST_OK;
|
||||
return init_db(git_dir, real_git_dir, template_dir, hash_algo,
|
||||
initial_branch, flags);
|
||||
initial_branch, init_shared_repository, flags);
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "gettext.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "refs.h"
|
||||
#include "object-file.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "pager.h"
|
||||
#include "color.h"
|
||||
#include "commit.h"
|
||||
|
@ -5,13 +5,12 @@
|
||||
*
|
||||
* Copyright (C) Linus Torvalds, 2005
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "repository.h"
|
||||
#include "config.h"
|
||||
#include "convert.h"
|
||||
#include "quote.h"
|
||||
#include "dir.h"
|
||||
#include "builtin.h"
|
||||
#include "gettext.h"
|
||||
#include "object-name.h"
|
||||
#include "strbuf.h"
|
||||
@ -20,9 +19,12 @@
|
||||
#include "parse-options.h"
|
||||
#include "resolve-undo.h"
|
||||
#include "string-list.h"
|
||||
#include "path.h"
|
||||
#include "pathspec.h"
|
||||
#include "read-cache.h"
|
||||
#include "run-command.h"
|
||||
#include "setup.h"
|
||||
#include "sparse-index.h"
|
||||
#include "submodule.h"
|
||||
#include "submodule-config.h"
|
||||
#include "object-store.h"
|
||||
@ -543,143 +545,6 @@ static int get_common_prefix_len(const char *common_prefix)
|
||||
return common_prefix_len;
|
||||
}
|
||||
|
||||
static int read_one_entry_opt(struct index_state *istate,
|
||||
const struct object_id *oid,
|
||||
struct strbuf *base,
|
||||
const char *pathname,
|
||||
unsigned mode, int opt)
|
||||
{
|
||||
int len;
|
||||
struct cache_entry *ce;
|
||||
|
||||
if (S_ISDIR(mode))
|
||||
return READ_TREE_RECURSIVE;
|
||||
|
||||
len = strlen(pathname);
|
||||
ce = make_empty_cache_entry(istate, base->len + len);
|
||||
|
||||
ce->ce_mode = create_ce_mode(mode);
|
||||
ce->ce_flags = create_ce_flags(1);
|
||||
ce->ce_namelen = base->len + len;
|
||||
memcpy(ce->name, base->buf, base->len);
|
||||
memcpy(ce->name + base->len, pathname, len+1);
|
||||
oidcpy(&ce->oid, oid);
|
||||
return add_index_entry(istate, ce, opt);
|
||||
}
|
||||
|
||||
static int read_one_entry(const struct object_id *oid, struct strbuf *base,
|
||||
const char *pathname, unsigned mode,
|
||||
void *context)
|
||||
{
|
||||
struct index_state *istate = context;
|
||||
return read_one_entry_opt(istate, oid, base, pathname,
|
||||
mode,
|
||||
ADD_CACHE_OK_TO_ADD|ADD_CACHE_SKIP_DFCHECK);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is used when the caller knows there is no existing entries at
|
||||
* the stage that will conflict with the entry being added.
|
||||
*/
|
||||
static int read_one_entry_quick(const struct object_id *oid, struct strbuf *base,
|
||||
const char *pathname, unsigned mode,
|
||||
void *context)
|
||||
{
|
||||
struct index_state *istate = context;
|
||||
return read_one_entry_opt(istate, oid, base, pathname,
|
||||
mode, ADD_CACHE_JUST_APPEND);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the tree specified with --with-tree option
|
||||
* (typically, HEAD) into stage #1 and then
|
||||
* squash them down to stage #0. This is used for
|
||||
* --error-unmatch to list and check the path patterns
|
||||
* that were given from the command line. We are not
|
||||
* going to write this index out.
|
||||
*/
|
||||
void overlay_tree_on_index(struct index_state *istate,
|
||||
const char *tree_name, const char *prefix)
|
||||
{
|
||||
struct tree *tree;
|
||||
struct object_id oid;
|
||||
struct pathspec pathspec;
|
||||
struct cache_entry *last_stage0 = NULL;
|
||||
int i;
|
||||
read_tree_fn_t fn = NULL;
|
||||
int err;
|
||||
|
||||
if (repo_get_oid(the_repository, tree_name, &oid))
|
||||
die("tree-ish %s not found.", tree_name);
|
||||
tree = parse_tree_indirect(&oid);
|
||||
if (!tree)
|
||||
die("bad tree-ish %s", tree_name);
|
||||
|
||||
/* Hoist the unmerged entries up to stage #3 to make room */
|
||||
/* TODO: audit for interaction with sparse-index. */
|
||||
ensure_full_index(istate);
|
||||
for (i = 0; i < istate->cache_nr; i++) {
|
||||
struct cache_entry *ce = istate->cache[i];
|
||||
if (!ce_stage(ce))
|
||||
continue;
|
||||
ce->ce_flags |= CE_STAGEMASK;
|
||||
}
|
||||
|
||||
if (prefix) {
|
||||
static const char *(matchbuf[1]);
|
||||
matchbuf[0] = NULL;
|
||||
parse_pathspec(&pathspec, PATHSPEC_ALL_MAGIC,
|
||||
PATHSPEC_PREFER_CWD, prefix, matchbuf);
|
||||
} else
|
||||
memset(&pathspec, 0, sizeof(pathspec));
|
||||
|
||||
/*
|
||||
* See if we have cache entry at the stage. If so,
|
||||
* do it the original slow way, otherwise, append and then
|
||||
* sort at the end.
|
||||
*/
|
||||
for (i = 0; !fn && i < istate->cache_nr; i++) {
|
||||
const struct cache_entry *ce = istate->cache[i];
|
||||
if (ce_stage(ce) == 1)
|
||||
fn = read_one_entry;
|
||||
}
|
||||
|
||||
if (!fn)
|
||||
fn = read_one_entry_quick;
|
||||
err = read_tree(the_repository, tree, &pathspec, fn, istate);
|
||||
clear_pathspec(&pathspec);
|
||||
if (err)
|
||||
die("unable to read tree entries %s", tree_name);
|
||||
|
||||
/*
|
||||
* Sort the cache entry -- we need to nuke the cache tree, though.
|
||||
*/
|
||||
if (fn == read_one_entry_quick) {
|
||||
cache_tree_free(&istate->cache_tree);
|
||||
QSORT(istate->cache, istate->cache_nr, cmp_cache_name_compare);
|
||||
}
|
||||
|
||||
for (i = 0; i < istate->cache_nr; i++) {
|
||||
struct cache_entry *ce = istate->cache[i];
|
||||
switch (ce_stage(ce)) {
|
||||
case 0:
|
||||
last_stage0 = ce;
|
||||
/* fallthru */
|
||||
default:
|
||||
continue;
|
||||
case 1:
|
||||
/*
|
||||
* If there is stage #0 entry for this, we do not
|
||||
* need to show it. We use CE_UPDATE bit to mark
|
||||
* such an entry.
|
||||
*/
|
||||
if (last_stage0 &&
|
||||
!strcmp(last_stage0->name, ce->name))
|
||||
ce->ce_flags |= CE_UPDATE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const char * const ls_files_usage[] = {
|
||||
N_("git ls-files [<options>] [<file>...]"),
|
||||
NULL
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "transport.h"
|
||||
@ -8,6 +7,7 @@
|
||||
#include "remote.h"
|
||||
#include "refs.h"
|
||||
#include "parse-options.h"
|
||||
#include "wildmatch.h"
|
||||
|
||||
static const char * const ls_remote_usage[] = {
|
||||
N_("git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n"
|
||||
|
@ -3,17 +3,17 @@
|
||||
*
|
||||
* Copyright (C) Linus Torvalds, 2005
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "blob.h"
|
||||
#include "tree.h"
|
||||
#include "commit.h"
|
||||
#include "path.h"
|
||||
#include "quote.h"
|
||||
#include "builtin.h"
|
||||
#include "parse-options.h"
|
||||
#include "pathspec.h"
|
||||
|
||||
|
@ -2,9 +2,8 @@
|
||||
* Another stupid program, this one parsing the headers of an
|
||||
* email to figure out authorship and subject
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "abspath.h"
|
||||
#include "builtin.h"
|
||||
#include "abspath.h"
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
#include "utf8.h"
|
||||
|
@ -4,7 +4,6 @@
|
||||
* It just splits a mbox into a list of files: "0001" "0002" ..
|
||||
* so you can process them further from there.
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "gettext.h"
|
||||
#include "string-list.h"
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "commit.h"
|
||||
#include "gettext.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "builtin.h"
|
||||
#include "abspath.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
#include "setup.h"
|
||||
|
@ -1,8 +1,10 @@
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "builtin.h"
|
||||
#include "hex.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "repository.h"
|
||||
#include "run-command.h"
|
||||
#include "sparse-index.h"
|
||||
|
||||
static const char *pgm;
|
||||
static int one_shot, quiet;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "git-compat-util.h"
|
||||
#include "builtin.h"
|
||||
#include "diff.h"
|
||||
#include "repository.h"
|
||||
|
||||
static const char builtin_merge_ours_usage[] =
|
||||
"git merge-ours <base>... -- HEAD <remote>...";
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "advice.h"
|
||||
#include "commit.h"
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "commit-reach.h"
|
||||
#include "merge-ort.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "parse-options.h"
|
||||
#include "repository.h"
|
||||
#include "blob.h"
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "abspath.h"
|
||||
#include "advice.h"
|
||||
#include "alloc.h"
|
||||
@ -18,7 +18,6 @@
|
||||
#include "hex.h"
|
||||
#include "object-name.h"
|
||||
#include "parse-options.h"
|
||||
#include "builtin.h"
|
||||
#include "lockfile.h"
|
||||
#include "run-command.h"
|
||||
#include "hook.h"
|
||||
@ -28,6 +27,7 @@
|
||||
#include "refspec.h"
|
||||
#include "commit.h"
|
||||
#include "diffcore.h"
|
||||
#include "path.h"
|
||||
#include "revision.h"
|
||||
#include "unpack-trees.h"
|
||||
#include "cache-tree.h"
|
||||
@ -37,6 +37,7 @@
|
||||
#include "color.h"
|
||||
#include "rerere.h"
|
||||
#include "help.h"
|
||||
#include "merge.h"
|
||||
#include "merge-recursive.h"
|
||||
#include "merge-ort-wrappers.h"
|
||||
#include "resolve-undo.h"
|
||||
|
@ -2,10 +2,11 @@
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "parse-options.h"
|
||||
#include "strbuf.h"
|
||||
#include "tag.h"
|
||||
#include "replace-object.h"
|
||||
#include "object-file.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "fsck.h"
|
||||
#include "config.h"
|
||||
|
||||
|
@ -8,9 +8,10 @@
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "quote.h"
|
||||
#include "strbuf.h"
|
||||
#include "tree.h"
|
||||
#include "parse-options.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
|
||||
static struct treeent {
|
||||
unsigned mode;
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "builtin.h"
|
||||
#include "abspath.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
#include "parse-options.h"
|
||||
#include "midx.h"
|
||||
#include "strbuf.h"
|
||||
#include "trace2.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
|
||||
#define BUILTIN_MIDX_WRITE_USAGE \
|
||||
N_("git multi-pack-index [<options>] write [--preferred-pack=<pack>]" \
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "config.h"
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
#include "name-hash.h"
|
||||
#include "object-file.h"
|
||||
#include "pathspec.h"
|
||||
#include "lockfile.h"
|
||||
@ -18,6 +19,7 @@
|
||||
#include "cache-tree.h"
|
||||
#include "string-list.h"
|
||||
#include "parse-options.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "repository.h"
|
||||
#include "setup.h"
|
||||
#include "submodule.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "hash-lookup.h"
|
||||
#include "commit-slab.h"
|
||||
#include "commit-graph.h"
|
||||
#include "wildmatch.h"
|
||||
|
||||
/*
|
||||
* One day. See the 'name a rev shortly after epoch' test in t6120 when
|
||||
|
@ -7,15 +7,15 @@
|
||||
* and builtin/tag.c by Kristian Høgsberg and Carlos Rica.
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "editor.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "notes.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "path.h"
|
||||
#include "repository.h"
|
||||
#include "blob.h"
|
||||
#include "pretty.h"
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "list.h"
|
||||
#include "packfile.h"
|
||||
#include "object-file.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "replace-object.h"
|
||||
#include "dir.h"
|
||||
#include "midx.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "hex.h"
|
||||
#include "repository.h"
|
||||
#include "packfile.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
|
||||
#define BLKSIZE 512
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "diff.h"
|
||||
#include "gettext.h"
|
||||
#include "hash.h"
|
||||
#include "hex.h"
|
||||
#include "parse-options.h"
|
||||
|
||||
|
@ -1,19 +1,20 @@
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "commit.h"
|
||||
#include "diff.h"
|
||||
#include "dir.h"
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "revision.h"
|
||||
#include "builtin.h"
|
||||
#include "reachable.h"
|
||||
#include "parse-options.h"
|
||||
#include "path.h"
|
||||
#include "progress.h"
|
||||
#include "prune-packed.h"
|
||||
#include "replace-object.h"
|
||||
#include "object-file.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "shallow.h"
|
||||
|
||||
static const char * const prune_usage[] = {
|
||||
|
@ -6,12 +6,12 @@
|
||||
* Fetch one or more remote refs and merge it/them into the current HEAD.
|
||||
*/
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "advice.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "merge.h"
|
||||
#include "object-name.h"
|
||||
#include "parse-options.h"
|
||||
#include "exec-cmd.h"
|
||||
@ -19,6 +19,8 @@
|
||||
#include "oid-array.h"
|
||||
#include "remote.h"
|
||||
#include "dir.h"
|
||||
#include "path.h"
|
||||
#include "read-cache-ll.h"
|
||||
#include "rebase.h"
|
||||
#include "refs.h"
|
||||
#include "refspec.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* "git push"
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "advice.h"
|
||||
#include "branch.h"
|
||||
#include "config.h"
|
||||
@ -10,7 +10,6 @@
|
||||
#include "refs.h"
|
||||
#include "refspec.h"
|
||||
#include "run-command.h"
|
||||
#include "builtin.h"
|
||||
#include "remote.h"
|
||||
#include "transport.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "gettext.h"
|
||||
#include "object-name.h"
|
||||
#include "parse-options.h"
|
||||
#include "range-diff.h"
|
||||
#include "config.h"
|
||||
#include "repository.h"
|
||||
#include "revision.h"
|
||||
|
||||
static const char * const builtin_range_diff_usage[] = {
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
@ -17,11 +17,11 @@
|
||||
#include "cache-tree.h"
|
||||
#include "unpack-trees.h"
|
||||
#include "dir.h"
|
||||
#include "builtin.h"
|
||||
#include "parse-options.h"
|
||||
#include "repository.h"
|
||||
#include "resolve-undo.h"
|
||||
#include "setup.h"
|
||||
#include "sparse-index.h"
|
||||
#include "submodule.h"
|
||||
#include "submodule-config.h"
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "object-file.h"
|
||||
#include "object-name.h"
|
||||
#include "parse-options.h"
|
||||
#include "path.h"
|
||||
#include "commit.h"
|
||||
#include "diff.h"
|
||||
#include "wt-status.h"
|
||||
|
@ -30,7 +30,8 @@
|
||||
#include "oidset.h"
|
||||
#include "packfile.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "path.h"
|
||||
#include "protocol.h"
|
||||
#include "commit-reach.h"
|
||||
#include "server-info.h"
|
||||
|
@ -1,8 +1,10 @@
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
#include "repository.h"
|
||||
#include "revision.h"
|
||||
#include "reachable.h"
|
||||
#include "wildmatch.h"
|
||||
#include "worktree.h"
|
||||
#include "reflog.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
#include "parse-options.h"
|
||||
#include "path.h"
|
||||
#include "transport.h"
|
||||
#include "remote.h"
|
||||
#include "string-list.h"
|
||||
@ -10,7 +11,7 @@
|
||||
#include "rebase.h"
|
||||
#include "refs.h"
|
||||
#include "refspec.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "strvec.h"
|
||||
#include "commit-reach.h"
|
||||
#include "progress.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "parse-options.h"
|
||||
#include "path.h"
|
||||
#include "run-command.h"
|
||||
#include "server-info.h"
|
||||
#include "sigchain.h"
|
||||
@ -15,7 +16,7 @@
|
||||
#include "midx.h"
|
||||
#include "packfile.h"
|
||||
#include "prune-packed.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "promisor-remote.h"
|
||||
#include "shallow.h"
|
||||
#include "pack.h"
|
||||
|
@ -8,22 +8,23 @@
|
||||
* git-tag.sh and mktag.c by Linus Torvalds.
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "editor.h"
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
#include "hex.h"
|
||||
#include "refs.h"
|
||||
#include "parse-options.h"
|
||||
#include "path.h"
|
||||
#include "run-command.h"
|
||||
#include "object-file.h"
|
||||
#include "object-name.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "replace-object.h"
|
||||
#include "repository.h"
|
||||
#include "tag.h"
|
||||
#include "wildmatch.h"
|
||||
|
||||
static const char * const git_replace_usage[] = {
|
||||
N_("git replace [-f] <object> <replacement>"),
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "dir.h"
|
||||
#include "gettext.h"
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "config.h"
|
||||
#include "environment.h"
|
||||
#include "gettext.h"
|
||||
#include "hash.h"
|
||||
#include "hex.h"
|
||||
#include "lockfile.h"
|
||||
#include "tag.h"
|
||||
@ -26,9 +27,11 @@
|
||||
#include "branch.h"
|
||||
#include "object-name.h"
|
||||
#include "parse-options.h"
|
||||
#include "path.h"
|
||||
#include "unpack-trees.h"
|
||||
#include "cache-tree.h"
|
||||
#include "setup.h"
|
||||
#include "sparse-index.h"
|
||||
#include "submodule.h"
|
||||
#include "submodule-config.h"
|
||||
#include "trace.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "cache.h"
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "commit.h"
|
||||
#include "diff.h"
|
||||
@ -12,10 +12,9 @@
|
||||
#include "object.h"
|
||||
#include "object-name.h"
|
||||
#include "object-file.h"
|
||||
#include "object-store.h"
|
||||
#include "object-store-ll.h"
|
||||
#include "pack.h"
|
||||
#include "pack-bitmap.h"
|
||||
#include "builtin.h"
|
||||
#include "log-tree.h"
|
||||
#include "graph.h"
|
||||
#include "bisect.h"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user