Use new semantics of is_bare/inside_git_dir/inside_work_tree
Up to now to check for a working tree this was used: !is_bare && !inside_git_dir (the check for bare is redundant because is_inside_git_dir returned already 1 for bare repositories). Now the check is: inside_work_tree && !inside_git_dir Signed-off-by: Matthias Lederhofer <matled@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matthias Lederhofer committed
Jun 3, 2007 at 16:48 UTC
7ae3df8c0aa3b7337ae9ac7b6184ac05985bf996
5 files changed
+14
-14
builtin-ls-files.c
+1
-1
@@ -470,7 +470,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
470
}
471
472
if (require_work_tree &&
473
- (is_bare_repository() || is_inside_git_dir()))
473
+ (!is_inside_work_tree() || is_inside_git_dir()))
474
die("This operation must be run in a work tree");
475
476
pathspec = get_pathspec(prefix, argv + i);
git-sh-setup.sh
+1
-1
@@ -44,7 +44,7 @@ cd_to_toplevel () {
44
}
45
46
require_work_tree () {
47
- test $(is_bare_repository) = false &&
47
+ test $(git-rev-parse --is-inside-work-tree) = true &&
48
test $(git-rev-parse --is-inside-git-dir) = false ||
49
die "fatal: $0 cannot be used without a working tree."
50
}
git-svn.perl
+1
-1
@@ -594,7 +594,7 @@ sub post_fetch_checkout {
594
my $index = $ENV{GIT_INDEX_FILE} || "$ENV{GIT_DIR}/index";
595
return if -f $index;
596
597
- return if command_oneline(qw/rev-parse --is-bare-repository/) eq 'true';
597
+ return if command_oneline(qw/rev-parse --is-inside-work-tree/) eq 'false';
598
return if command_oneline(qw/rev-parse --is-inside-git-dir/) eq 'true';
599
command_noisy(qw/read-tree -m -u -v HEAD HEAD/);
600
print STDERR "Checked out HEAD:\n ",
git.c
+10
-10
@@ -224,7 +224,7 @@ const char git_version_string[] = GIT_VERSION;
224
* require working tree to be present -- anything uses this needs
225
* RUN_SETUP for reading from the configuration file.
226
*/
227
-#define NOT_BARE (1<<2)
227
+#define NEED_WORK_TREE (1<<2)
228
229
static void handle_internal_command(int argc, const char **argv, char **envp)
230
{
@@ -234,7 +234,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
234
int (*fn)(int, const char **, const char *);
235
int option;
236
} commands[] = {
237
- { "add", cmd_add, RUN_SETUP | NOT_BARE },
237
+ { "add", cmd_add, RUN_SETUP | NEED_WORK_TREE },
238
{ "annotate", cmd_annotate, RUN_SETUP | USE_PAGER },
239
{ "apply", cmd_apply },
240
{ "archive", cmd_archive },
@@ -244,9 +244,9 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
244
{ "cat-file", cmd_cat_file, RUN_SETUP },
245
{ "checkout-index", cmd_checkout_index, RUN_SETUP },
246
{ "check-ref-format", cmd_check_ref_format },
247
- { "check-attr", cmd_check_attr, RUN_SETUP | NOT_BARE },
247
+ { "check-attr", cmd_check_attr, RUN_SETUP | NEED_WORK_TREE },
248
{ "cherry", cmd_cherry, RUN_SETUP },
249
- { "cherry-pick", cmd_cherry_pick, RUN_SETUP | NOT_BARE },
249
+ { "cherry-pick", cmd_cherry_pick, RUN_SETUP | NEED_WORK_TREE },
250
{ "commit-tree", cmd_commit_tree, RUN_SETUP },
251
{ "config", cmd_config },
252
{ "count-objects", cmd_count_objects, RUN_SETUP },
@@ -274,7 +274,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
274
{ "mailsplit", cmd_mailsplit },
275
{ "merge-base", cmd_merge_base, RUN_SETUP },
276
{ "merge-file", cmd_merge_file },
277
- { "mv", cmd_mv, RUN_SETUP | NOT_BARE },
277
+ { "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE },
278
{ "name-rev", cmd_name_rev, RUN_SETUP },
279
{ "pack-objects", cmd_pack_objects, RUN_SETUP },
280
{ "pickaxe", cmd_blame, RUN_SETUP | USE_PAGER },
@@ -287,9 +287,9 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
287
{ "rerere", cmd_rerere, RUN_SETUP },
288
{ "rev-list", cmd_rev_list, RUN_SETUP },
289
{ "rev-parse", cmd_rev_parse, RUN_SETUP },
290
- { "revert", cmd_revert, RUN_SETUP | NOT_BARE },
291
- { "rm", cmd_rm, RUN_SETUP | NOT_BARE },
292
- { "runstatus", cmd_runstatus, RUN_SETUP | NOT_BARE },
290
+ { "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
291
+ { "rm", cmd_rm, RUN_SETUP | NEED_WORK_TREE },
292
+ { "runstatus", cmd_runstatus, RUN_SETUP | NEED_WORK_TREE },
293
{ "shortlog", cmd_shortlog, RUN_SETUP | USE_PAGER },
294
{ "show-branch", cmd_show_branch, RUN_SETUP },
295
{ "show", cmd_show, RUN_SETUP | USE_PAGER },
@@ -326,8 +326,8 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
326
prefix = setup_git_directory();
327
if (p->option & USE_PAGER)
328
setup_pager();
329
- if ((p->option & NOT_BARE) &&
330
- (is_bare_repository() || is_inside_git_dir()))
329
+ if ((p->option & NEED_WORK_TREE) &&
330
+ (!is_inside_work_tree() || is_inside_git_dir()))
331
die("%s must be run in a work tree", cmd);
332
trace_argv_printf(argv, argc, "trace: built-in: git");
333
setup.c
+1
-1
@@ -95,7 +95,7 @@ void verify_non_filename(const char *prefix, const char *arg)
95
const char *name;
96
struct stat st;
97
98
- if (is_inside_git_dir())
98
+ if (!is_inside_work_tree() || is_inside_git_dir())
99
return;
100
if (*arg == '-')
101
return; /* flag */