"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Mark Jamsek <mark@jamsek.com>
Subject:
Re: tog: implement diff view 'p' keymap to write patch file
To:
Stefan Sperling <stsp@stsp.name>
Cc:
Christian Weisgerber <naddy@mips.inka.de>, gameoftrees@openbsd.org
Date:
Tue, 13 Aug 2024 15:54:31 +1000

Download raw body.

Thread
Stefan Sperling <stsp@stsp.name> wrote:
> On Sun, Aug 11, 2024 at 04:52:17PM +1000, Mark Jamsek wrote:
> > Christian Weisgerber <naddy@mips.inka.de> wrote:
> > > Mark Jamsek:
> > > 
> > > > As mentioned in the log view 'm' keymap thread, this is the next step to
> > > > facilitate code review workflows with a new 'p' keymap to write out the
> > > > currently viewed diff to a patch file.
> > > > 
> > > > We write to a file in /tmp and report the path to the status line.
> > > 
> > > That's a weird place.  As a user, I never really need to look into
> > > /tmp or grab files from there.
> > > 
> > > Home directory?  Or simply the current working directory?  Just
> > > about everything in the Unix world defaults to writing to the cwd.
> > > That is a bit at odds with invoking tog in a worktree, but is it a
> > > good idea to diverge from such a fundamental convention?  IIRC,
> > > git-format-patch also dumps its output into the cwd, so typically
> > > the worktree/repository, for whatever that is worth.
> > 
> > Bearing in mind tog could be invoked with tog diff -r repo from anywhere
> > in the filesystem (and indeed the log and thus diff view can be reached
> > from most other tog cmd invocations that only unveil the repository) in
> > which case the cwd may not be unveiled. So with this constraint in mind
> > my first thought was to write to the cwd if it is a worktree or
> > repository, otherwise write it to the repository directory as that's
> > guaranteed to be unveiled in all tog invocations.
> > 
> > But when stsp suggested /tmp, I realised this made more sense. I think
> > it's preferable to write it to a consistent location rather than switch
> > it up on the user.
> > 
> > I agree with you that the cwd is a de facto standard and if we could I'd
> > prefer that convention but in this case we could only do it sometimes
> > and that inconsistency isn't ideal.
> > 
> > That said, if you think the repository directory would be better or if
> > you prefer the cwd when we can and $REPODIR or $TMP when we can't, I'm
> > happy to change it.
> 
> Unveiling cwd or $HOME for write access would indeed be a no-go.
> Doing so would expose ~/.ssh and other sensitive directories.
> If that's required then I'd rather leave this feature out entirely.
> 
> Given this, is there a better location than /tmp we could use?

I agree. Perhaps naddy might prefer if it's written to the worktree if
it's open--irrespective of whether it's the cwd--and /tmp in all other
cases. If so, I'm happy with that. The repository directory is readonly
and should remain as such though.

tbh, I prefer /tmp in all cases. Not only for consistency, but I have a
habit of leaving diffs lying around so having them garbage collected is
a bonus. I can move them from /tmp to other locations if I want, but a
primary workflow that motivated this feature is: review diff in tog
before mailing out, 'p' keymap to write out the diff, copy path, and
`:r path` into my editor when writing the email. So more often than not
they'll remain in /tmp.

In any case, I'll leave it up to naddy. If /tmp is a deal breaker and
there's no viable alternative that you like, let's leave it out.


-- 
Mark Jamsek <https://bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68