Skip to content

Commit

Permalink
rev-parse: introduce --is-bare-repository
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Matthias Lederhofer authored and Junio C Hamano committed Jun 6, 2007
1 parent 4faac24 commit 493c774
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Documentation/git-rev-parse.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions builtin-rev-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions git-sh-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
3 changes: 1 addition & 2 deletions git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ",
Expand Down

0 comments on commit 493c774

Please sign in to comment.