diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-02-07 12:25:40 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-02-07 13:05:08 -0600 |
commit | c4f05d27c09ffff3217383138c36387709bcf599 (patch) | |
tree | a1d316ae6fd62516a53bc33b5279c1c44622b44f /bin | |
parent | 928d8f45111cfb66cb7177f6a17562999043f06a (diff) | |
download | conf-c4f05d27c09ffff3217383138c36387709bcf599.tar.gz conf-c4f05d27c09ffff3217383138c36387709bcf599.zip |
properly handle a repository with no commits
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/fancy-prompt | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/bin/fancy-prompt b/bin/fancy-prompt index d06403f..4dbc642 100755 --- a/bin/fancy-prompt +++ b/bin/fancy-prompt @@ -299,16 +299,23 @@ sub darcs_info { sub git_info { my ($git_dir) = @_; + my $HEAD = `git rev-parse --short HEAD 2>/dev/null`; + my $dirty = ''; - if (system(q[git diff --no-ext-diff --ignore-submodules --quiet --exit-code])) { - $dirty .= '*'; + if ($HEAD) { + if (system(q[git diff --no-ext-diff --ignore-submodules --quiet --exit-code])) { + $dirty .= '*'; + } + if (system(q[git diff-index --cached --quiet --ignore-submodules HEAD])) { + $dirty .= '+'; + } } - if (system(q[git diff-index --cached --quiet --ignore-submodules HEAD])) { - $dirty .= '+'; + else { + $dirty = '?'; } chomp(my $branch = `git symbolic-ref -q HEAD 2>/dev/null` - || `git rev-parse --short HEAD`); + || $HEAD); $branch =~ s{^refs/heads/}{}; my $local_commits = ''; |