git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git add --interactive patch improvement for split hunks

From
UWUlrich Windl <ulrich.windl@rz.uni-regensburg.de>
Date
Jun 24, 2021, 10:35 UTC
Message-ID
<60D45FE4020000A100041FCE@gwsmtp.uni-regensburg.de>
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,?]?
Next: Jeff King
Message 1 of 9 in “git add --interactive patch improvement for split hunks”
  1. Ulrich WindlJun 24, 2021
  2. Jeff KingJun 24, 2021
  3. Antw: [EXT] Re: git add --interactive patch improvement for split hunksUlrich Windl, Jun 28, 2021
  4. Ævar Arnfjörð BjarmasonJun 28, 2021
  5. Jeff KingJun 30, 2021
  6. Junio C HamanoJun 30, 2021
  7. Jeff KingJun 30, 2021
  8. Ævar Arnfjörð BjarmasonJun 30, 2021
  9. Jeff KingJun 30, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.