git add --interactive patch improvement for split hunks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!


I noticed that git add -interactive's patch displays the function context for the diffs, but that function context is lost when the hunks are split.
It would help the user (especially for hunks covering multiple functioins) if function context were still provided for split hunks.


Maybe just consider this (buggy) example (with screen shot in case the lines get severely mangled):
(15/20) Stage this hunk [y,n,q,a,d,K,j,J,g,/,e,?]? n
@@ -1097,13 +1743,13 @@ static inline    void    bitmap_copy_bits(
     }
     else
     {
-        const unsigned        s_i    = FASTBIT(s_pos);
-        const unsigned        d_i    = FASTBIT(d_pos);
+        const unsigned        s_i    = FASTBIT(s_pos + count);
+        const unsigned        d_i    = FASTBIT(d_pos + count);
         const fastword_t    *s_fw_p;
         fastword_t        *d_fw_p;
 
-        for ( s_fw_p = src->fast_words + FASTWORD(s_pos),
-              d_fw_p = dst->fast_words + FASTWORD(d_pos);
+        for ( s_fw_p = src->fast_words + FASTWORD(s_pos + count),
+              d_fw_p = dst->fast_words + FASTWORD(d_pos + count);
               count >= FASTWORD_BITS;
               --s_fw_p, --d_fw_p, count -= FASTWORD_BITS )
         {
(16/20) Stage this hunk [y,n,q,a,d,K,j,J,g,/,s,e,?]? s
Split into 2 hunks.
@@ -1097,8 +1743,8 @@
     }
     else
     {
-        const unsigned        s_i    = FASTBIT(s_pos);
-        const unsigned        d_i    = FASTBIT(d_pos);
+        const unsigned        s_i    = FASTBIT(s_pos + count);
+        const unsigned        d_i    = FASTBIT(d_pos + count);
         const fastword_t    *s_fw_p;
         fastword_t        *d_fw_p;
 
(16/21) Stage this hunk [y,n,q,a,d,K,j,J,g,/,e,?]? n
@@ -1102,8 +1748,8 @@
         const fastword_t    *s_fw_p;
         fastword_t        *d_fw_p;
 
-        for ( s_fw_p = src->fast_words + FASTWORD(s_pos),
-              d_fw_p = dst->fast_words + FASTWORD(d_pos);
+        for ( s_fw_p = src->fast_words + FASTWORD(s_pos + count),
+              d_fw_p = dst->fast_words + FASTWORD(d_pos + count);
               count >= FASTWORD_BITS;
               --s_fw_p, --d_fw_p, count -= FASTWORD_BITS )
         {
(17/21) Stage this hunk [y,n,q,a,d,K,j,J,g,/,e,?]?



Attachment: Screenshot from 2021-06-24 12-29-38.png
Description: PNG image


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux