summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8894d53)
raw | patch | inline | side by side (parent: 8894d53)
author | Clemens Buchacher <drizzd@aon.at> | |
Sun, 4 Sep 2011 10:41:59 +0000 (12:41 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 6 Sep 2011 19:50:10 +0000 (12:50 -0700) |
Passing a prefix to a function that is supposed to find the prefix is
strange. And it's really only used if the pathspec is NULL. Make the
callers handle this case instead.
As we are always returning a fresh copy of a string (or NULL), change the
type of the returned value to non-const "char *".
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
strange. And it's really only used if the pathspec is NULL. Make the
callers handle this case instead.
As we are always returning a fresh copy of a string (or NULL), change the
type of the returned value to non-const "char *".
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit.c | patch | blob | history | |
builtin/ls-files.c | patch | blob | history | |
cache.h | patch | blob | history | |
setup.c | patch | blob | history |
diff --git a/builtin/commit.c b/builtin/commit.c
index cb738574f729e91ff239f12db3f3f1ef1ef9570c..50bacd68e2103de9f976fecd9ac2bc0ef737884a 100644 (file)
--- a/builtin/commit.c
+++ b/builtin/commit.c
m = xcalloc(1, i);
if (with_tree) {
- const char *max_prefix = pathspec_prefix(prefix, pattern);
- overlay_tree_on_cache(with_tree, max_prefix);
+ char *max_prefix = pathspec_prefix(pattern);
+ overlay_tree_on_cache(with_tree, max_prefix ? max_prefix : prefix);
+ free(max_prefix);
}
for (i = 0; i < active_nr; i++) {
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 0e98bff0c46035162fc424418cc434b52299c1cc..19e53cc881b41881ff5f92581ce2f8541b399ffa 100644 (file)
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
strip_trailing_slash_from_submodules();
/* Find common prefix for all pathspec's */
- max_prefix = pathspec_prefix(prefix, pathspec);
+ max_prefix = pathspec_prefix(pathspec);
max_prefix_len = max_prefix ? strlen(max_prefix) : 0;
/* Treat unmatching pathspec elements as errors */
index 553a6ebd4b5cf1fb7269b0dd6a9589d2c638a7c3..a3462bafce407bbad79d8f0121b5bbff3f304316 100644 (file)
--- a/cache.h
+++ b/cache.h
#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 char *pathspec_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);
index 699fcf096d98f9875586cf07297eb87b431f5961..f767d8adb110dde7dcafa8cf030ee7a496753800 100644 (file)
--- a/setup.c
+++ b/setup.c
return pathspec;
}
-const char *pathspec_prefix(const char *prefix, const char **pathspec)
+char *pathspec_prefix(const char **pathspec)
{
const char **p, *n, *prev;
unsigned long max;
if (!pathspec)
- return prefix ? xmemdupz(prefix, strlen(prefix)) : NULL;
+ return NULL;
prev = NULL;
max = PATH_MAX;