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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: tog: implement diff view 'p' keymap to write patch file
To:
Mark Jamsek <mark@jamsek.com>
Cc:
Christian Weisgerber <naddy@mips.inka.de>, gameoftrees@openbsd.org
Date:
Mon, 12 Aug 2024 21:23:46 +0200

Download raw body.

Thread
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?