Open lewiseason opened 9 years ago
This may not be as difficult to implement as it first appears. Everything is first built in ~/.fresh/build.new
and then that directory is renamed to ~/.fresh/build
once complete. If we skip the final rename and all symlink creation, we’d have something we can do diffs with. This would not cover anything done in fresh_after_build
though.
I prefer to think of this as something which will show you what will change rather than as something that will show you what you’re about to lose. The main difference would be the diff direction. I am thinking we will probably call this fresh diff
.
We probably also want to be able to customise the diff tool used. The default would call diff -r
but I myself would want to change this to use my vimdiff
wrapper which has support for the DirDiff plugin. Not yet sure where this config would be stored. FRESH_DIFF_TOOL
environment variable?
Whichever direction the diff is specified in, it protects me from accidentally blowing away configuration changes - which is brilliant - and this in particular sounds bang on (especially as it'll account for filters, which I didn't think about before).
Perhaps being consistent with the way Git itself handles diff tools would work? With defaults like:
FRESH_EXTERNAL_DIFF=diff
FRESH_DIFF_OPTS=-r
I’m not sure we should split the args off into a separate environment variable. “External” seems a bit redundant too as fresh doesn’t have an internal diff tool.
This is true. I suppose if you want to pass more options to diff, it's fairly plain that you need to specify which application you're calling - FRESH_DIFF_TOOL
sounds good.
This is a cool idea. Perhaps the default could be git diff --no-index
. I find diff
's output hard to parse.
That's certainly what I'd set it to - much easier to read. Plus - colours!
Cool. I didn’t know about git diff --no-index
. Since fresh already requires git, I am quite happy for this to be the default.
I doubt this is possible for files made up of multiple source files, but it might work for things like monolithic configuration files.
Things write to my fresh-managed files - it's a fact of life. I may change a setting in an application - which will write its config file (ignoring the fact its read only). As it's possible to know the source file in my
.dotfiles
directory for each file it creates in thebuild
directory - is there any scope for adding afresh diff
command?Say I have a file called
tmux.conf
and a line in my.freshrc
like this:If I invoke
fresh diff tmux.conf
- fresh could do this:and show me what (if any) changes have been made to my tmux file, so I can check if I'm about to blow anything away by running
fresh
, or am making changes. Thoughts?Edit: Also, fresh is absolutely fantastic. It keeps me sane working on different machines and is absolutely the most useful utility that I have (and have everywhere). Thank you!