Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fresh Diff Support #129

Open
lewiseason opened this issue Apr 1, 2015 · 7 comments
Open

Fresh Diff Support #129

lewiseason opened this issue Apr 1, 2015 · 7 comments

Comments

@lewiseason
Copy link

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 the build directory - is there any scope for adding a fresh diff command?

Say I have a file called tmux.conf and a line in my .freshrc like this:

fresh --file tmux.conf

If I invoke fresh diff tmux.conf - fresh could do this:

diff ~/.dotfiles/tmux.conf ~/.fresh/build/tmux.conf

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!

@jasoncodes
Copy link
Member

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?

@lewiseason
Copy link
Author

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

@jasoncodes
Copy link
Member

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.

@lewiseason
Copy link
Author

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.

@twe4ked
Copy link
Member

twe4ked commented Apr 2, 2015

This is a cool idea. Perhaps the default could be git diff --no-index. I find diff's output hard to parse.

@lewiseason
Copy link
Author

That's certainly what I'd set it to - much easier to read. Plus - colours!

@jasoncodes
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants