mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
diff kitten: Add support for files that are identical apart from mode changes
Fixes #6611
This commit is contained in:
@@ -78,6 +78,8 @@ Detailed list of changes
|
|||||||
|
|
||||||
- ssh kitten: Fix a regression causing hostname directives in :file:`ssh.conf` not matching when username is specified (:disc:`6609`)
|
- ssh kitten: Fix a regression causing hostname directives in :file:`ssh.conf` not matching when username is specified (:disc:`6609`)
|
||||||
|
|
||||||
|
- diff kitten: Add support for files that are identical apart from mode changes (:iss:`6611`)
|
||||||
|
|
||||||
|
|
||||||
0.29.2 [2023-07-27]
|
0.29.2 [2023-07-27]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|||||||
@@ -312,6 +312,16 @@ func (self *Collection) collect_files(left, right string) error {
|
|||||||
if ld != rd {
|
if ld != rd {
|
||||||
changed_names.Add(n)
|
changed_names.Add(n)
|
||||||
self.add_change(left_path_map[n], right_path_map[n])
|
self.add_change(left_path_map[n], right_path_map[n])
|
||||||
|
} else {
|
||||||
|
if lstat, err := os.Stat(left_path_map[n]); err == nil {
|
||||||
|
if rstat, err := os.Stat(right_path_map[n]); err == nil {
|
||||||
|
if lstat.Mode() != rstat.Mode() {
|
||||||
|
// identical files with only a mode change
|
||||||
|
changed_names.Add(n)
|
||||||
|
self.add_change(left_path_map[n], right_path_map[n])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
removed := left_names.Subtract(common_names)
|
removed := left_names.Subtract(common_names)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -571,7 +572,15 @@ func lines_for_diff(left_path string, right_path string, patch *Patch, columns,
|
|||||||
is_full_width: true,
|
is_full_width: true,
|
||||||
}
|
}
|
||||||
if patch.Len() == 0 {
|
if patch.Len() == 0 {
|
||||||
for _, line := range splitlines("The files are identical", columns-margin_size) {
|
txt := "The files are identical"
|
||||||
|
if lstat, err := os.Stat(left_path); err == nil {
|
||||||
|
if rstat, err := os.Stat(right_path); err == nil {
|
||||||
|
if lstat.Mode() != rstat.Mode() {
|
||||||
|
txt = fmt.Sprintf("Mode changed: %s to %s", lstat.Mode(), rstat.Mode())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, line := range splitlines(txt, columns-margin_size) {
|
||||||
sl := ScreenLine{}
|
sl := ScreenLine{}
|
||||||
sl.left.marked_up_text = line
|
sl.left.marked_up_text = line
|
||||||
ht.screen_lines = append(ht.screen_lines, &sl)
|
ht.screen_lines = append(ht.screen_lines, &sl)
|
||||||
|
|||||||
Reference in New Issue
Block a user