Menu

#19 Error: gits unexpected status output (missing branch)

v0.10
open
nobody
None
5
2015-04-22
2014-03-10
No

I get a missing branch(?) when performing 'status', bug in hits or a local configuration problem? TIA, Robert

>gits status
gits unexpected status output (missing branch):  at /usr/local/bin/gits line 2720.
  • OS-X 10.9.2
  • gitslave via homebrew (brew install gitslave)
  • gits --version
  • gits version 2.0.2
  • git version 1.9.0
  • This is perl 5, version 16, subversion 2 (v5.16.2) built for darwin-thread-multi
    (with 3 registered patches, see perl -V for more detail)

Discussion

  • justin stofle

    justin stofle - 2014-03-11

    git version 1.8.5.2 (Apple Git-48) and UP no longer prints status messages with a leading '# '. So the regex on line 2720 fails. You can comment it out or fix the regex and the problem will go away.

     

    Last edit: justin stofle 2014-03-11
  • Robert N/SushiHangover

    Thanks! I just commented it out as I do not really work with detached HEADs (Not sure when else you would not be on a branch...).

    I guess when I pulled/installed the 2.0.2 git from "brew install git --HEAD" I did not notice the change in the status output...

     
  • Robert N/SushiHangover

    Just found the same issue with "gits detach" and on branch checkouts.

    I pulled/installed the head of gitslave from the repo to see if the issue still exists, there are more areas, but here are some of the areas that I came across:

    1014: while ($msg =~ s/(^[^\#].*\n)//)
    1019" die "gits unexpected status output (missing branch): $msg" unless ($msg =~ s/^\# (?:On branch |(Not currently on any branch.))(.+)?\n//);
    3052: while ($msg =~ s/(^[^\#].*\n)//)
    3057: die "gits unexpected status output (missing branch): $msg" unless ($msg =~ s/^\# (?:On branch |Not currently on any branch.)(.+)?\n//);
    3208: while ($msg =~ s/(^[^\#].*\n)//)
    3213: unless ($msg =~ s/^\# (?:On branch |Not currently on any branch.)(.+)?\n//)
    
    gits --version
    gits version Untagged (22062774e1b91f702e988316fa1070aab7d3ec13)
    git version 1.9.0
    This is perl 5, version 16, subversion 2 (v5.16.2) built for darwin-thread-multi
    (with 3 registered patches, see perl -V for more detail)
    Perl OS declared as darwin
    
     

    Last edit: Robert N/SushiHangover 2014-03-11
  • justin stofle

    justin stofle - 2014-03-11

    I was able to fix this by commenting out lines 2715-2718 and changing the regex on line 2720 to s/^(?:# )?(?:On branch |Not currently on any branch.)(.+)?\n?//

    Lines 2714 through 2720 now look like this:

    my ($premove);
    #while ($msg =~ s/(^[^#].*\n)//)
    #{
    # $premove .= $1;
    #}

    die "gits unexpected status output (missing branch): $msg" unless ($msg =~ s/^(?:# )?(?:On branch |Not currently on any branch.)(.+)?\n?//);

     

    Last edit: justin stofle 2014-03-11
  • Robert N/SushiHangover

    Thanks Justin.

    I pulled the latest code, applied your change to multiple areas... Status, attach, detach all seem to be fine...

    -R

    diff --git a/gits b/gits
    index 6ab5eed..6ea8f73 100755
    --- a/gits
    +++ b/gits
    @@ -1011,12 +1011,7 @@ sub releasecheck($@)
         }
    
         my ($premove);
    
    -    while ($msg =~ s/(^[^\#].*\n)//)
    -    {
    -      $premove .= $1;
    -    }
    -
    -    die "gits unexpected status output (missing branch): $msg" unless ($msg =~ s/^\# (?:On branch |(Not currently on any branch.))(.+)?\n//);
    +    die "gits unexpected status output (missing branch): $msg" unless ($msg =~ s/^(?:# )?(?:On branch |Not currently on any branch.)(.+)?\n?//);
         my $localbranch = $2;
         if ($1 =~ /^Not/)
         {
    @@ -3049,12 +3044,7 @@ elsif ($ARGV[0] eq 'status')
         $okcnt++;
    
         my ($premove);
    
    -    while ($msg =~ s/(^[^\#].*\n)//)
    -    {
    -      $premove .= $1;
    -    }
    -
    -    die "gits unexpected status output (missing branch): $msg" unless ($msg =~ s/^\# (?:On branch |Not currently on any branch.)(.+)?\n//);
    +    die "gits unexpected status output (missing branch): $msg" unless ($msg =~ s/^(?:# )?(?:On branch |Not currently on any branch.)(.+)?\n?//);
         my $localbranch = $1 ? $1 : "(no branch)";
         $branch = $localbranch unless ($branch);
         unless ($branch eq $localbranch)
    @@ -3205,12 +3195,7 @@ elsif ($ARGV[0] eq 'statuses')
           $okcnt++;
    
           my ($premove);
    
    -      while ($msg =~ s/(^[^\#].*\n)//)
    -      {
    -   $premove .= $1;
    -      }
    -
    -      unless ($msg =~ s/^\# (?:On branch |Not currently on any branch.)(.+)?\n//)
    +      unless ($msg =~ s/^(?:# )?(?:On branch |Not currently on any branch.)(.+)?\n?//)
           {
        # <TODO>some way for do_checkout to only operate on some slaves</TODO>
        $msg .= do_checkout(2, @oldbranch);
    
     
  • James T. Tanis

    James T. Tanis - 2015-03-27

    Hi folks,
    While gits definitely needs to be overhauled for the change in "git status" output introduced in 1.8.5, for the time being we can ask git to continue to give us the old-style output. When one looks closely at the gits code, it becomes (almost painfully) apparent that the hash-mark prefix is expected in many, many regexps, not just those mentioned in the previous patch offerings. The following patch, simply makes gits ask git to give us the old-syle status output whenever such is relevant.

    diff --git a/gits b/gits
    index 202bb32..c2582c5 100755
    --- a/gits
    +++ b/gits
    @@ -59,7 +59,7 @@ my ($returncode) = 0;
    my $pagination;
    delete($ENV{'GIT_DIR'});
    our($fromcheckout);
    -our($git) = 'git';
    +our($git) = 'git -c status.displayCommentPrefix=true';

    # Some people are stupid enough to set CDPATH and that screws up the formatting
    delete($ENV{'CDPATH'});

     
  • Joel Purra

    Joel Purra - 2015-04-22

    If you're using brew on Mac OS X, I've added the gitslave fork to a custom tap. The above fix is included in this fork.

    :::bash
    brew tap joelpurra/joelpurra
    brew install --devel joelpurra/joelpurra/gitslave
    

    The tap is so that brew can keep track of updates to the fork.

     

Log in to post a comment.

MongoDB Logo MongoDB