author | Junio C Hamano <gitster@pobox.com> | |
Sun, 1 Jul 2007 20:10:42 +0000 (13:10 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 1 Jul 2007 20:10:42 +0000 (13:10 -0700) |
* ei/worktree+filter:
filter-branch: always export GIT_DIR if it is set
setup_git_directory: fix segfault if repository is found in cwd
test GIT_WORK_TREE
extend rev-parse test for --is-inside-work-tree
Use new semantics of is_bare/inside_git_dir/inside_work_tree
introduce GIT_WORK_TREE to specify the work tree
test git rev-parse
rev-parse: introduce --is-bare-repository
rev-parse: document --is-inside-git-dir
filter-branch: always export GIT_DIR if it is set
setup_git_directory: fix segfault if repository is found in cwd
test GIT_WORK_TREE
extend rev-parse test for --is-inside-work-tree
Use new semantics of is_bare/inside_git_dir/inside_work_tree
introduce GIT_WORK_TREE to specify the work tree
test git rev-parse
rev-parse: introduce --is-bare-repository
rev-parse: document --is-inside-git-dir
1 | 2 | |||
---|---|---|---|---|
Documentation/config.txt | patch | | diff1 | | diff2 | | blob | history |
Documentation/git-rev-parse.txt | patch | | diff1 | | diff2 | | blob | history |
Documentation/git.txt | patch | | diff1 | | diff2 | | blob | history |
builtin-ls-files.c | patch | | diff1 | | diff2 | | blob | history |
cache.h | patch | | diff1 | | diff2 | | blob | history |
connect.c | patch | | diff1 | | diff2 | | blob | history |
git-filter-branch.sh | patch | | diff1 | | diff2 | | blob | history |
git-svn.perl | patch | | diff1 | | diff2 | | blob | history |
git.c | patch | | diff1 | | diff2 | | blob | history |
setup.c | patch | | diff1 | | diff2 | | blob | history |
t/test-lib.sh | patch | | diff1 | | diff2 | | blob | history |
diff --cc Documentation/config.txt
Simple merge
diff --cc Documentation/git-rev-parse.txt
Simple merge
diff --cc Documentation/git.txt
Simple merge
diff --cc builtin-ls-files.c
Simple merge
diff --cc cache.h
Simple merge
diff --cc connect.c
Simple merge
diff --cc git-filter-branch.sh
Simple merge
diff --cc git-svn.perl
Simple merge
diff --cc git.c
index cfec5d70ee42852f3819fe46e99ebc70f089ccc7,cd3910afea0cc0e66e720413b2e03d8f00964ff6..b6bf5ad5ec97699f0a1f4d6c6616c7c9a240d144
+++ b/git.c
* require working tree to be present -- anything uses this needs
* RUN_SETUP for reading from the configuration file.
*/
- #define NOT_BARE (1<<2)
+ #define NEED_WORK_TREE (1<<2)
-static void handle_internal_command(int argc, const char **argv, char **envp)
+struct cmd_struct {
+ const char *cmd;
+ int (*fn)(int, const char **, const char *);
+ int option;
+};
+
+static int run_command(struct cmd_struct *p, int argc, const char **argv)
+{
+ int status;
+ struct stat st;
+ const char *prefix;
+
+ prefix = NULL;
+ if (p->option & RUN_SETUP)
+ prefix = setup_git_directory();
+ if (p->option & USE_PAGER)
+ setup_pager();
- if (p->option & NOT_BARE) {
- if (is_bare_repository() || is_inside_git_dir())
- die("%s must be run in a work tree", p->cmd);
- }
++ if ((p->option & NEED_WORK_TREE) &&
++ (!is_inside_work_tree() || is_inside_git_dir()))
++ die("%s must be run in a work tree", p->cmd);
+ trace_argv_printf(argv, argc, "trace: built-in: git");
+
+ status = p->fn(argc, argv, prefix);
+ if (status)
+ return status;
+
+ /* Somebody closed stdout? */
+ if (fstat(fileno(stdout), &st))
+ return 0;
+ /* Ignore write errors for pipes and sockets.. */
+ if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode))
+ return 0;
+
+ /* Check for ENOSPC and EIO errors.. */
+ if (fflush(stdout))
+ die("write failure on standard output: %s", strerror(errno));
+ if (ferror(stdout))
+ die("unknown write failure on standard output");
+ if (fclose(stdout))
+ die("close failed on standard output: %s", strerror(errno));
+ return 0;
+}
+
+static void handle_internal_command(int argc, const char **argv)
{
const char *cmd = argv[0];
- static struct cmd_struct {
- const char *cmd;
- int (*fn)(int, const char **, const char *);
- int option;
- } commands[] = {
+ static struct cmd_struct commands[] = {
- { "add", cmd_add, RUN_SETUP | NOT_BARE },
+ { "add", cmd_add, RUN_SETUP | NEED_WORK_TREE },
{ "annotate", cmd_annotate, RUN_SETUP | USE_PAGER },
{ "apply", cmd_apply },
{ "archive", cmd_archive },
diff --cc setup.c
Simple merge
diff --cc t/test-lib.sh
Simple merge