apply: move check_to_create_blob() closer to its sole caller
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jun 7, 2012 at 14:06 UTC
813ebf82215ce3e07631ea7ab12b30c609adcccd
1 file changed
+23
-23
builtin/apply.c
+23
-23
@@ -3159,29 +3159,6 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *
3159
return 0;
3160
}
3161
3162
-static int check_to_create_blob(const char *new_name, int ok_if_exists)
3163
-{
3164
- struct stat nst;
3165
- if (!lstat(new_name, &nst)) {
3166
- if (S_ISDIR(nst.st_mode) || ok_if_exists)
3167
- return 0;
3168
- /*
3169
- * A leading component of new_name might be a symlink
3170
- * that is going to be removed with this patch, but
3171
- * still pointing at somewhere that has the path.
3172
- * In such a case, path "new_name" does not exist as
3173
- * far as git is concerned.
3174
- */
3175
- if (has_symlink_leading_path(new_name, strlen(new_name)))
3176
- return 0;
3177
-
3178
- return error(_("%s: already exists in working directory"), new_name);
3179
- }
3180
- else if ((errno != ENOENT) && (errno != ENOTDIR))
3181
- return error("%s: %s", new_name, strerror(errno));
3182
- return 0;
3183
-}
3184
-
3162
static int verify_index_match(struct cache_entry *ce, struct stat *st)
3163
{
3164
if (S_ISGITLINK(ce->ce_mode)) {
@@ -3272,6 +3249,29 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
3249
return 0;
3250
}
3251
3252
+static int check_to_create_blob(const char *new_name, int ok_if_exists)
3253
+{
3254
+ struct stat nst;
3255
+ if (!lstat(new_name, &nst)) {
3256
+ if (S_ISDIR(nst.st_mode) || ok_if_exists)
3257
+ return 0;
3258
+ /*
3259
+ * A leading component of new_name might be a symlink
3260
+ * that is going to be removed with this patch, but
3261
+ * still pointing at somewhere that has the path.
3262
+ * In such a case, path "new_name" does not exist as
3263
+ * far as git is concerned.
3264
+ */
3265
+ if (has_symlink_leading_path(new_name, strlen(new_name)))
3266
+ return 0;
3267
+
3268
+ return error(_("%s: already exists in working directory"), new_name);
3269
+ }
3270
+ else if ((errno != ENOENT) && (errno != ENOTDIR))
3271
+ return error("%s: %s", new_name, strerror(errno));
3272
+ return 0;
3273
+}
3274
+
3275
/*
3276
* Check and apply the patch in-core; leave the result in patch->result
3277
* for the caller to write it out to the final destination.