Merge branch 'jc/apply' into next
authorJunio C Hamano <junkio@cox.net>
Wed, 17 May 2006 23:56:20 +0000 (16:56 -0700)
committerJunio C Hamano <junkio@cox.net>
Wed, 17 May 2006 23:56:20 +0000 (16:56 -0700)
* jc/apply:
apply --cached: do not check newly added file in the working tree

1  2 
apply.c
diff --combined apply.c
index 5bd50733656eee24f59486553f5afaaac9a784bc,0ed9d132e88f52c678a4a64caf3b49d5bc04ee2e..5341e309224b227f2fb430c448192cd7642348cf
+++ b/apply.c
@@@ -8,7 -8,6 +8,7 @@@
   */
  #include <fnmatch.h>
  #include "cache.h"
 +#include "cache-tree.h"
  #include "quote.h"
  #include "blob.h"
  #include "delta.h"
@@@ -1712,10 -1711,12 +1712,12 @@@ static int check_patch(struct patch *pa
        if (new_name && (patch->is_new | patch->is_rename | patch->is_copy)) {
                if (check_index && cache_name_pos(new_name, strlen(new_name)) >= 0)
                        return error("%s: already exists in index", new_name);
-               if (!cached && !lstat(new_name, &st))
-                       return error("%s: already exists in working directory", new_name);
-               if (errno != ENOENT)
-                       return error("%s: %s", new_name, strerror(errno));
+               if (!cached) {
+                       if (!lstat(new_name, &st))
+                               return error("%s: already exists in working directory", new_name);
+                       if (errno != ENOENT)
+                               return error("%s: %s", new_name, strerror(errno));
+               }
                if (!patch->new_mode) {
                        if (patch->is_new)
                                patch->new_mode = S_IFREG | 0644;
@@@ -1916,7 -1917,6 +1918,7 @@@ static void remove_file(struct patch *p
        if (write_index) {
                if (remove_file_from_cache(patch->old_name) < 0)
                        die("unable to remove %s from index", patch->old_name);
 +              cache_tree_invalidate_path(active_cache_tree, patch->old_name);
        }
        if (!cached)
                unlink(patch->old_name);
@@@ -2018,9 -2018,8 +2020,9 @@@ static void create_file(struct patch *p
  
        if (!mode)
                mode = S_IFREG | 0644;
 -      create_one_file(path, mode, buf, size); 
 +      create_one_file(path, mode, buf, size);
        add_index_file(path, mode, buf, size);
 +      cache_tree_invalidate_path(active_cache_tree, path);
  }
  
  static void write_out_one_result(struct patch *patch)