I'm adding p9p plumbing support for a text editor/pager that I've been
writing. I'm using 9fans/go for it. Since I use it as my pager, I want
to be able to plumb git objects from git log to git show. I've added
the following rule to my plumbing rules, but something weird seems to
be happening to the working directory that it's executing plumb start
from:
type is text
data matches ('[a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]+')
plumb to pager
plumb start git show
This is my code that sends the plumbing message:
func plumb(content []byte, buff *demodel.CharBuffer, v
demodel.Viewport, click int) error {
fid, err := plumblib.Open("send", plan9.OWRITE)
if err != nil {
fmt.Printf("%v", err)
return err
}
wd, _ := os.Getwd()
println("Working directory", wd)
m := plumblib.Message{
Src: "de",
Dst: "",
Dir: wd,
Type: "text",
Data: content,
}
if click != 0 {
m.Attr = &plumblib.Attribute{Name: "click", Value: strconv.Itoa(click)}
}
return m.Send(fid)
}
(Note: I had to vendor
9fans.net/plumb for m.Send to work because of
https://github.com/9fans/go/pull/14)
The debugging println prints the correct working directory, so my
understanding is it should be executing the plumb start from the right
place, but instead I'm getting "fatal: bad object [hash]" errors from
git when I try to plumb a commit from any directory other than the
directory that the p9p plumber was started from.
Is there something obvious I'm missing or any hints for where to poke
around to debug?
- Dave