rev-parse: introduce --is-bare-repository
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:46 UTC
493c774e58a05bbbac06e4ae1654ca3d24e4e5cf
4 files changed
+10
-7
Documentation/git-rev-parse.txt
+3
@@ -93,6 +93,9 @@ OPTIONS
93
When the current working directory is below the repository
94
directory print "true", otherwise "false".
95
96
+--is-bare-repository::
97
+ When the repository is bare print "true", otherwise "false".
98
+
99
--short, --short=number::
100
Instead of outputting the full SHA1 values of object names try to
101
abbreviate them to a shorter unique name. When no length is specified
builtin-rev-parse.c
+5
@@ -352,6 +352,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
352
: "false");
353
continue;
354
}
355
+ if (!strcmp(arg, "--is-bare-repository")) {
356
+ printf("%s\n", is_bare_repository() ? "true"
357
+ : "false");
358
+ continue;
359
+ }
360
if (!prefixcmp(arg, "--since=")) {
361
show_datestring("--max-age=", arg+8);
362
continue;
git-sh-setup.sh
+1
-5
@@ -29,11 +29,7 @@ set_reflog_action() {
29
}
30
31
is_bare_repository () {
32
- git-config --bool --get core.bare ||
33
- case "$GIT_DIR" in
34
- .git | */.git) echo false ;;
35
- *) echo true ;;
36
- esac
32
+ git-rev-parse --is-bare-repository
33
}
34
35
cd_to_toplevel () {
git-svn.perl
+1
-2
@@ -594,8 +594,7 @@ sub post_fetch_checkout {
594
my $index = $ENV{GIT_INDEX_FILE} || "$ENV{GIT_DIR}/index";
595
return if -f $index;
596
597
- chomp(my $bare = `git config --bool --get core.bare`);
598
- return if $bare eq 'true';
597
+ return if command_oneline(qw/rev-parse --is-bare-repository/) eq 'true';
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 ",