Merge branch 'kh/commit'
authorJunio C Hamano <gitster@pobox.com>
Thu, 1 Nov 2007 06:53:22 +0000 (23:53 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 1 Nov 2007 06:53:22 +0000 (23:53 -0700)
* kh/commit:
Export rerere() and launch_editor().
Introduce entry point add_interactive and add_files_to_cache
Enable wt-status to run against non-standard index file.
Enable wt-status output to a given FILE pointer.

1  2 
builtin-add.c
diff --combined builtin-add.c
index b8e6094b21599051c543b1f77c991363d9dfe181,966e14503821025f7782d79409b70f672fc45e45..dbbb05215fbcfad5d45e5d60e9d985760705d716
@@@ -12,6 -12,7 +12,7 @@@
  #include "diffcore.h"
  #include "commit.h"
  #include "revision.h"
+ #include "run-command.h"
  
  static const char builtin_add_usage[] =
  "git-add [-n] [-v] [-f] [--interactive | -i] [-u] [--refresh] [--] <filepattern>...";
@@@ -44,7 -45,6 +45,7 @@@ static void prune_directory(struct dir_
                        die("pathspec '%s' did not match any files",
                                        pathspec[i]);
        }
 +        free(seen);
  }
  
  static void fill_directory(struct dir_struct *dir, const char **pathspec,
@@@ -107,7 -107,7 +108,7 @@@ static void update_callback(struct diff
        }
  }
  
static void update(int verbose, const char *prefix, const char **files)
void add_files_to_cache(int verbose, const char *prefix, const char **files)
  {
        struct rev_info rev;
        init_revisions(&rev, prefix);
        rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
        rev.diffopt.format_callback = update_callback;
        rev.diffopt.format_callback_data = &verbose;
-       if (read_cache() < 0)
-               die("index file corrupt");
        run_diff_files(&rev, 0);
  }
  
@@@ -136,7 -134,6 +135,7 @@@ static void refresh(int verbose, const 
                if (!seen[i])
                        die("pathspec '%s' did not match any files", pathspec[i]);
        }
 +        free(seen);
  }
  
  static int git_add_config(const char *var, const char *value)
        return git_default_config(var, value);
  }
  
+ int interactive_add(void)
+ {
+       const char *argv[2] = { "add--interactive", NULL };
+       return run_command_v_opt(argv, RUN_GIT_CMD);
+ }
  static struct lock_file lock_file;
  
  static const char ignore_error[] =
@@@ -170,12 -174,9 +176,9 @@@ int cmd_add(int argc, const char **argv
                        add_interactive++;
        }
        if (add_interactive) {
-               const char *args[] = { "add--interactive", NULL };
-               if (add_interactive != 1 || argc != 2)
+               if (argc != 2)
                        die("add --interactive does not take any parameters");
-               execv_git_cmd(args);
-               exit(1);
+               exit(interactive_add());
        }
  
        git_config(git_add_config);
        }
  
        if (take_worktree_changes) {
-               update(verbose, prefix, argv + i);
+               if (read_cache() < 0)
+                       die("index file corrupt");
+               add_files_to_cache(verbose, prefix, argv + i);
                goto finish;
        }