Commit 8a14049
committed
Fix
**Problem**:
`diff-hl-resolved-reference-revision` fails to work correctly when `diff-hl-reference-revision` is set as a buffer-local variable.
Example:
```emacs-lisp
(setq-local diff-hl-reference-revision "test-rev")
```
**Cause**:
When the implementation for backends like Hg (and similarly Bzr) uses `with-temp-buffer`, buffer-local variables from the original buffer context are not accessible. Consequently, `diff-hl-reference-revision` evaluates to `nil` within the temporary buffer.
For 'Hg as an exmaple,
```emacs-lisp
(with-temp-buffer
(vc-hg-command (current-buffer) 0 nil
"identify" "-r" diff-hl-reference-revision
"-i")
...)
```
This leads to an incorrect command being executed:
* **Expected hg command**: `hg --config ui.report_untrusted=0 identify -r test-rev -i .`
* **Actual hg command**: `hg --config ui.report_untrusted=0 identify -r -i .`
**Fix**:
To resolve this, the value of `diff-hl-reference-revision` is now copied into a non-buffer-local variable (e.g., `original-diff-hl-reference-revision`) *before* entering the `with-temp-buffer` block. This non-buffer-local variable is then used within the temporary buffer context, ensuring the correct revision is always passed to the underlying version control command.
**Tests**:
I have tested it in my hg repo. Also added a test in `diff-hl-test.el`.diff-hl-resolved-reference-revision for Hg and Bzr with buffer-local diff-hl-reference-revision.1 parent c1cecb2 commit 8a14049
2 files changed
Lines changed: 32 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1442 | 1442 | | |
1443 | 1443 | | |
1444 | 1444 | | |
1445 | | - | |
1446 | | - | |
1447 | | - | |
1448 | | - | |
1449 | | - | |
1450 | | - | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
1451 | 1454 | | |
1452 | | - | |
1453 | | - | |
1454 | | - | |
1455 | | - | |
1456 | | - | |
1457 | | - | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
1458 | 1464 | | |
1459 | 1465 | | |
1460 | 1466 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
226 | 240 | | |
227 | 241 | | |
228 | 242 | | |
0 commit comments