Skip to contentSkip to conversation

diff

DISCUSSION Tobin C. Harding 3 participants 4 messages Mar 13, 2017

lore
Share & tools
lore
#0 lore raw

On occasions diff output does not render the same as it does when editing a file. For example, while removing checkpatch tab warning the following diff was generated

-#define KS_WLAN_SET_WPS_ENABLE SIOCIWFIRSTPRIV + 4
-#define KS_WLAN_GET_WPS_ENABLE SIOCIWFIRSTPRIV + 5
+#define KS_WLAN_SET_WPS_ENABLE SIOCIWFIRSTPRIV + 4
+#define KS_WLAN_GET_WPS_ENABLE SIOCIWFIRSTPRIV + 5

However when editing the file the alignment was not changed, just tabs were inserted instead of spaces.

I had the same thing happen a few days ago (reproduced here from memory)

-static void foo(struct bar *barp, struct baz *bazp) +static void foo(struct bar *barp,
+ struct baz *bazp)

{
        ...

When editing the file the two s's in struct were aligned but not in the diff output. I reapplied this patch to a clean tree and it applied correctly.

How do maintainers visually parse this if the output is not identical in the diff and the file once applied?

thanks,
Tobin.

#1 lore raw
Quoted 15 lines · Tobin C. Harding

On occasions diff output does not render the same as it does when editing a file. For example, while removing checkpatch tab warning the following diff was generated

(quoted diff) +2 -2
-#define KS_WLAN_SET_WPS_ENABLE                 SIOCIWFIRSTPRIV + 4
-#define KS_WLAN_GET_WPS_ENABLE                 SIOCIWFIRSTPRIV + 5
+#define KS_WLAN_SET_WPS_ENABLE         SIOCIWFIRSTPRIV + 4
+#define KS_WLAN_GET_WPS_ENABLE         SIOCIWFIRSTPRIV + 5

However when editing the file the alignment was not changed, just tabs were inserted instead of spaces.

I had the same thing happen a few days ago (reproduced here from memory)

Review

Quoted 3 lines
(quoted diff) +2 -1
-static void foo(struct bar *barp, struct baz *bazp)
+static void foo(struct bar *barp,
+               struct baz *bazp)

You missed that there are really tabs in the real diff, you used all spaces here.

Quoted 9 lines
{
        ...

When editing the file the two s's in struct were aligned but not in the diff output. I reapplied this patch to a clean tree and it applied correctly.

How do maintainers visually parse this if the output is not identical in the diff and the file once applied?

We are used to reading diffs :)

we can edit them by hand as well, but that's a skill best left alone...

greg k-h

#2 lore raw
In reply to Tobin C. Harding
Quoted 11 lines · Tobin C. Harding

On occasions diff output does not render the same as it does when editing a file. For example, while removing checkpatch tab warning the following diff was generated

(quoted diff) +2 -2
-#define KS_WLAN_SET_WPS_ENABLE                 SIOCIWFIRSTPRIV + 4
-#define KS_WLAN_GET_WPS_ENABLE                 SIOCIWFIRSTPRIV + 5
+#define KS_WLAN_SET_WPS_ENABLE         SIOCIWFIRSTPRIV + 4
+#define KS_WLAN_GET_WPS_ENABLE         SIOCIWFIRSTPRIV + 5

However when editing the file the alignment was not changed, just tabs were inserted instead of spaces.

if the removed lines were using tabs which they should then they are moved by the inserted "-" while the added lines were using spaces and thus did not "jump" to the next tabstop.

Quoted 10 lines

I had the same thing happen a few days ago (reproduced here from memory)

(quoted diff) +2 -1
-static void foo(struct bar *barp, struct baz *bazp)
+static void foo(struct bar *barp,
+               struct baz *bazp)
{
        ...
Quoted 3 lines

When editing the file the two s's in struct were aligned but not in the diff output. I reapplied this patch to a clean tree and it applied correctly.

this is simply because the insertion is by tabs so when diff added the +/- output it moved the "static void foo..." but not the "struct baz" so this looks unaligned in the diff output while it actually is aligned properly.

Quoted 4 lines

How do maintainers visually parse this if the output is not identical in the diff and the file once applied?

checkpatch will warn if spaces were used and if its based on tabs I guess most can see if aligment is correct or not.

thx!
hofrat

#3 lore raw
Quoted 37 lines · Nicholas Mc Guire
Quoted 11 lines · Tobin C. Harding

On occasions diff output does not render the same as it does when editing a file. For example, while removing checkpatch tab warning the following diff was generated

(quoted diff) +2 -2
-#define KS_WLAN_SET_WPS_ENABLE                 SIOCIWFIRSTPRIV + 4
-#define KS_WLAN_GET_WPS_ENABLE                 SIOCIWFIRSTPRIV + 5
+#define KS_WLAN_SET_WPS_ENABLE         SIOCIWFIRSTPRIV + 4
+#define KS_WLAN_GET_WPS_ENABLE         SIOCIWFIRSTPRIV + 5

However when editing the file the alignment was not changed, just tabs were inserted instead of spaces.

if the removed lines were using tabs which they should then they are moved by the inserted "-" while the added lines were using spaces and thus did not "jump" to the next tabstop.

Quoted 10 lines

I had the same thing happen a few days ago (reproduced here from memory)

(quoted diff) +2 -1
-static void foo(struct bar *barp, struct baz *bazp)
+static void foo(struct bar *barp,
+               struct baz *bazp)
{
        ...
Quoted 3 lines

When editing the file the two s's in struct were aligned but not in the diff output. I reapplied this patch to a clean tree and it applied correctly.

this is simply because the insertion is by tabs so when diff added the +/- output it moved the "static void foo..." but not the "struct baz" so this looks unaligned in the diff output while it actually is aligned properly.

Quoted 1 line
Quoted 5 lines
Quoted 3 lines

How do maintainers visually parse this if the output is not identical in the diff and the file once applied?

checkpatch will warn if spaces were used and if its based on tabs I guess most can see if aligment is correct or not.

Nice explanation, thank you.

Regards,
Tobin.