summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Lederhofer <matled@gmx.net>2007-06-03 16:46:36 +0200
committerJunio C Hamano <gitster@pobox.com>2007-06-06 16:07:53 -0700
commit493c774e58a05bbbac06e4ae1654ca3d24e4e5cf (patch)
tree0ba0afdae1fcb024f1323d34abff3049c26a5a1e
parent4faac2468de86f4dfd482d55d7c9adc7f2796f07 (diff)
downloadgit-493c774e58a05bbbac06e4ae1654ca3d24e4e5cf.tar.gz
rev-parse: introduce --is-bare-repository
Signed-off-by: Matthias Lederhofer <matled@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--Documentation/git-rev-parse.txt3
-rw-r--r--builtin-rev-parse.c5
-rwxr-xr-xgit-sh-setup.sh6
-rwxr-xr-xgit-svn.perl3
4 files changed, 10 insertions, 7 deletions
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 5fcec19a56..c817d1614a 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -93,6 +93,9 @@ OPTIONS
When the current working directory is below the repository
directory print "true", otherwise "false".
+--is-bare-repository::
+ When the repository is bare print "true", otherwise "false".
+
--short, --short=number::
Instead of outputting the full SHA1 values of object names try to
abbreviate them to a shorter unique name. When no length is specified
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 37addb25fa..71d5162595 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -352,6 +352,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
: "false");
continue;
}
+ if (!strcmp(arg, "--is-bare-repository")) {
+ printf("%s\n", is_bare_repository() ? "true"
+ : "false");
+ continue;
+ }
if (!prefixcmp(arg, "--since=")) {
show_datestring("--max-age=", arg+8);
continue;
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index f24c7f2d23..9ac657a70e 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -29,11 +29,7 @@ set_reflog_action() {
}
is_bare_repository () {
- git-config --bool --get core.bare ||
- case "$GIT_DIR" in
- .git | */.git) echo false ;;
- *) echo true ;;
- esac
+ git-rev-parse --is-bare-repository
}
cd_to_toplevel () {
diff --git a/git-svn.perl b/git-svn.perl
index e35006142a..e3a5cbb3d7 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -594,8 +594,7 @@ sub post_fetch_checkout {
my $index = $ENV{GIT_INDEX_FILE} || "$ENV{GIT_DIR}/index";
return if -f $index;
- chomp(my $bare = `git config --bool --get core.bare`);
- return if $bare eq 'true';
+ return if command_oneline(qw/rev-parse --is-bare-repository/) eq 'true';
return if command_oneline(qw/rev-parse --is-inside-git-dir/) eq 'true';
command_noisy(qw/read-tree -m -u -v HEAD HEAD/);
print STDERR "Checked out HEAD:\n ",