saltstack/salt — pull request #2107 by thekuffs (2012-09-27 02:28:02+00:00)
Title: Fix reversed diff on file.managed

I recently made some updates to config files with ```file.managed``` and found that the diff was reversed.

```
----------
State: - file
Name: /etc/supervisord.d/salt-bridge.conf
Function: managed
Result: True
Comment: File /etc/supervisord.d/salt-bridge.conf updated
Changes: diff: ---
+++
@@ -1,4 +1,4 @@
-[program:salt-bridge]
+[program: salt-bridge]
```

In this case, I was removing that whitespace, not adding it.

I've read through the code a couple times to make sure I hadn't misunderstood it. I think the confusion comes from #2077 where the code is ```unified_diff(slines, nlines)```. After reading the code related to #2077, I found that the file variables were just named inappropriately in ```file.comment```. In that commit ```slines``` ends up being the original unmodified file, and ```nlines``` is read into memory after the ```file.comment``` module is called.