aboutsummaryrefslogtreecommitdiff
path: root/builtin/apply.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-06-07 14:06:47 -0700
committerJunio C Hamano <gitster@pobox.com>2012-07-09 14:36:51 -0700
commit813ebf82215ce3e07631ea7ab12b30c609adcccd (patch)
treebbaecf028ebe447e45b157d3f67685b67ffe77d8 /builtin/apply.c
parent5a812661694efed28b4446724278bcc21fe6d6d6 (diff)
downloadgit-813ebf82215ce3e07631ea7ab12b30c609adcccd.tar.gz
git-813ebf82215ce3e07631ea7ab12b30c609adcccd.tar.xz
apply: move check_to_create_blob() closer to its sole caller
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/apply.c')
-rw-r--r--builtin/apply.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index ee1a96089..cd25e6309 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -3159,29 +3159,6 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *
return 0;
}
-static int check_to_create_blob(const char *new_name, int ok_if_exists)
-{
- struct stat nst;
- if (!lstat(new_name, &nst)) {
- if (S_ISDIR(nst.st_mode) || ok_if_exists)
- return 0;
- /*
- * A leading component of new_name might be a symlink
- * that is going to be removed with this patch, but
- * still pointing at somewhere that has the path.
- * In such a case, path "new_name" does not exist as
- * far as git is concerned.
- */
- if (has_symlink_leading_path(new_name, strlen(new_name)))
- return 0;
-
- return error(_("%s: already exists in working directory"), new_name);
- }
- else if ((errno != ENOENT) && (errno != ENOTDIR))
- return error("%s: %s", new_name, strerror(errno));
- return 0;
-}
-
static int verify_index_match(struct cache_entry *ce, struct stat *st)
{
if (S_ISGITLINK(ce->ce_mode)) {
@@ -3272,6 +3249,29 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
return 0;
}
+static int check_to_create_blob(const char *new_name, int ok_if_exists)
+{
+ struct stat nst;
+ if (!lstat(new_name, &nst)) {
+ if (S_ISDIR(nst.st_mode) || ok_if_exists)
+ return 0;
+ /*
+ * A leading component of new_name might be a symlink
+ * that is going to be removed with this patch, but
+ * still pointing at somewhere that has the path.
+ * In such a case, path "new_name" does not exist as
+ * far as git is concerned.
+ */
+ if (has_symlink_leading_path(new_name, strlen(new_name)))
+ return 0;
+
+ return error(_("%s: already exists in working directory"), new_name);
+ }
+ else if ((errno != ENOENT) && (errno != ENOTDIR))
+ return error("%s: %s", new_name, strerror(errno));
+ return 0;
+}
+
/*
* Check and apply the patch in-core; leave the result in patch->result
* for the caller to write it out to the final destination.