Commits

Greg Ward committed 5c1398e

git: fix %r implementation to work if not at a branch head.
(If .git/HEAD does not look like a branch name, assume it is a commit ID.)

Comments (0)

Files changed (2)

                 found_branch = 1;
             }
             else {
+                /* if it's not a branch name, assume it is a commit ID */
                 debug(".git/HEAD doesn't look like a head ref: unknown branch");
                 result->branch = "(unknown)";
+                result->revision = strndup(buf, 12); /* XXX mem leak! */
             }
             if (context->options->show_revision && found_branch) {
                 char buf[1024];

tests/test-simple

 
     echo 3f786850e387550fdab836ed7e6dc881de23001b > .git/HEAD
     assert_vcprompt "git nobranch" "(unknown)"
-
-    # XXX this case not handled yet
-    #assert_vcprompt "git nobranch (show rev)" "(unknown):3f786850e385" "%b:%r"
+    assert_vcprompt "git nobranch (show rev)" "(unknown):3f786850e387" "%b:%r"
 
     echo "ref: refs/heads/foo" > .git/HEAD
     assert_vcprompt "git branch" "git:foo" "%n:%b"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.