aboutsummaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorClemens Buchacher <drizzd@aon.at>2011-07-30 19:13:47 +0200
committerJunio C Hamano <gitster@pobox.com>2011-08-02 14:20:35 -0700
commit8894d5358095a08c2f700a87ce9fdefb0b6eb61b (patch)
tree9bb41b5eba638c33b61acb7041817c6b129c0796 /cache.h
parent3503b8d0da61d920ebd9294fd6a9a0f758328fd3 (diff)
downloadgit-8894d5358095a08c2f700a87ce9fdefb0b6eb61b.tar.gz
git-8894d5358095a08c2f700a87ce9fdefb0b6eb61b.tar.xz
commit: allow partial commits with relative paths
In order to do partial commits, git-commit overlays a tree on the cache and checks pathspecs against the result. Currently, the overlaying is done using "prefix" which prevents relative pathspecs with ".." and absolute pathspec from matching when they refer to files not under "prefix" and absent from the index, but still in the tree (i.e. files staged for removal). The point of providing a prefix at all is performance optimization. If we say there is no common prefix for the files of interest, then we have to read the entire tree into the index. But even if we cannot use the working directory as a prefix, we can still figure out if there is a common prefix for all given paths, and use that instead. The pathspec_prefix() routine from ls-files.c does exactly that. Any use of global variables is removed from pathspec_prefix() so that it can be called from commit.c. Reported-by: Reuben Thomas <rrt@sc3d.org> Analyzed-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/cache.h b/cache.h
index e11cf6ab1..553a6ebd4 100644
--- a/cache.h
+++ b/cache.h
@@ -426,6 +426,7 @@ extern void set_git_work_tree(const char *tree);
#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
extern const char **get_pathspec(const char *prefix, const char **pathspec);
+extern const char *pathspec_prefix(const char *prefix, const char **pathspec);
extern void setup_work_tree(void);
extern const char *setup_git_directory_gently(int *);
extern const char *setup_git_directory(void);