Merge branch 'nd/worktree' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 3 Sep 2008 22:35:37 +0000 (15:35 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Sep 2008 22:35:37 +0000 (15:35 -0700)
* nd/worktree:
setup_git_directory(): fix move to worktree toplevel directory
update-index: fix worktree setup
read-tree: setup worktree if merge is required
grep: fix worktree setup
diff*: fix worktree setup

1  2 
builtin-grep.c
builtin-update-index.c
diff --combined builtin-grep.c
index f59f95f1758f891f8068f1d12222d415c6595957,3ded1ba9da9166c09fb1b65d315499e24036466d..3a51662a35878ae6b5965c90abb747b5b27c5493
@@@ -774,7 -774,7 +774,7 @@@ int cmd_grep(int argc, const char **arg
                        /* Make sure we do not get outside of paths */
                        for (i = 0; paths[i]; i++)
                                if (strncmp(prefix, paths[i], opt.prefix_length))
 -                                      die("git-grep: cannot generate relative filenames containing '..'");
 +                                      die("git grep: cannot generate relative filenames containing '..'");
                }
        }
        else if (prefix) {
                paths[1] = NULL;
        }
  
-       if (!list.nr)
+       if (!list.nr) {
+               if (!cached)
+                       setup_work_tree();
                return !grep_cache(&opt, paths, cached);
+       }
  
        if (cached)
                die("both --cached and trees are given.");
diff --combined builtin-update-index.c
index e5bb2a03cbc047392b866ad1128cba58f98af5ba,f2c90ff1cd573d25bf90ef71ac36c0738f2d74e4..5637d417aac668a61af3c50d8b1acd2b31f5af8a
@@@ -262,7 -262,7 +262,7 @@@ static void chmod_path(int flip, const 
        report("chmod %cx '%s'", flip, path);
        return;
   fail:
 -      die("git-update-index: cannot chmod %cx '%s'", flip, path);
 +      die("git update-index: cannot chmod %cx '%s'", flip, path);
  }
  
  static void update_one(const char *path, const char *prefix, int prefix_length)
  
        if (force_remove) {
                if (remove_file_from_cache(p))
 -                      die("git-update-index: unable to remove %s", path);
 +                      die("git update-index: unable to remove %s", path);
                report("remove '%s'", path);
                goto free_return;
        }
@@@ -351,7 -351,7 +351,7 @@@ static void read_index_info(int line_te
                if (line_termination && path_name[0] == '"') {
                        strbuf_reset(&uq);
                        if (unquote_c_style(&uq, path_name, NULL)) {
 -                              die("git-update-index: bad quoting of path name");
 +                              die("git update-index: bad quoting of path name");
                        }
                        path_name = uq.buf;
                }
                if (!mode) {
                        /* mode == 0 means there is no such path -- remove */
                        if (remove_file_from_cache(path_name))
 -                              die("git-update-index: unable to remove %s",
 +                              die("git update-index: unable to remove %s",
                                    ptr);
                }
                else {
                         */
                        ptr[-42] = ptr[-1] = 0;
                        if (add_cacheinfo(mode, sha1, path_name, stage))
 -                              die("git-update-index: unable to update %s",
 +                              die("git update-index: unable to update %s",
                                    path_name);
                }
                continue;
@@@ -614,10 -614,12 +614,12 @@@ int cmd_update_index(int argc, const ch
                                continue;
                        }
                        if (!strcmp(path, "--refresh")) {
+                               setup_work_tree();
                                has_errors |= refresh_cache(refresh_flags);
                                continue;
                        }
                        if (!strcmp(path, "--really-refresh")) {
+                               setup_work_tree();
                                has_errors |= refresh_cache(REFRESH_REALLY | refresh_flags);
                                continue;
                        }
                                unsigned int mode;
  
                                if (i+3 >= argc)
 -                                      die("git-update-index: --cacheinfo <mode> <sha1> <path>");
 +                                      die("git update-index: --cacheinfo <mode> <sha1> <path>");
  
                                if (strtoul_ui(argv[i+1], 8, &mode) ||
                                    get_sha1_hex(argv[i+2], sha1) ||
                                    add_cacheinfo(mode, sha1, argv[i+3], 0))
 -                                      die("git-update-index: --cacheinfo"
 +                                      die("git update-index: --cacheinfo"
                                            " cannot add %s", argv[i+3]);
                                i += 3;
                                continue;
                        if (!strcmp(path, "--chmod=-x") ||
                            !strcmp(path, "--chmod=+x")) {
                                if (argc <= i+1)
 -                                      die("git-update-index: %s <path>", path);
 +                                      die("git update-index: %s <path>", path);
                                set_executable_bit = path[8];
                                continue;
                        }
                                goto finish;
                        }
                        if (!strcmp(path, "--again") || !strcmp(path, "-g")) {
+                               setup_work_tree();
                                has_errors = do_reupdate(argc - i, argv + i,
                                                         prefix, prefix_length);
                                if (has_errors)
                                usage(update_index_usage);
                        die("unknown option %s", path);
                }
+               setup_work_tree();
                p = prefix_path(prefix, prefix_length, path);
                update_one(p, NULL, 0);
                if (set_executable_bit)
  
                strbuf_init(&buf, 0);
                strbuf_init(&nbuf, 0);
+               setup_work_tree();
                while (strbuf_getline(&buf, stdin, line_termination) != EOF) {
                        const char *p;
                        if (line_termination && buf.buf[0] == '"') {