]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
git-merge-changelog: Fix essential functionality (regr. 2023-05-21).
authorBruno Haible <bruno@clisp.org>
Tue, 29 Jul 2025 07:11:40 +0000 (09:11 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 29 Jul 2025 07:11:40 +0000 (09:11 +0200)
Fixes two mistakes in commit a8921605af342b9061e04e18fc952d386e5a071c.

Reported by Patrice Dumas <pertusus@free.fr> in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-07/msg00181.html>.

* lib/git-merge-changelog.c (main): Fix off-by-one mistakes in crucial
places.

ChangeLog
lib/git-merge-changelog.c

index a5a766deec567e431478a9b32e70f0df0dbc5ab3..e18ef6504860c8405a91bbe00d1fc570968a74ee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-07-29  Bruno Haible  <bruno@clisp.org>
+
+       git-merge-changelog: Fix essential functionality (regr. 2023-05-21).
+       Fixes two mistakes in commit a8921605af342b9061e04e18fc952d386e5a071c.
+       Reported by Patrice Dumas <pertusus@free.fr> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2025-07/msg00181.html>.
+       * lib/git-merge-changelog.c (main): Fix off-by-one mistakes in crucial
+       places.
+
 2025-07-28  Paul Eggert  <eggert@cs.ucla.edu>
 
        float-h: change IBM long double to match GCC 15
index 190dafc140dc1a94c869c56faeec78dbde28de96..cc496bb4cbd4b251d3ae3797ca61fb5fb5e8dc35 100644 (file)
@@ -1242,10 +1242,9 @@ There is NO WARRANTY, to the extent permitted by law.\n\
                 {
                   /* An addition to the top of modified_file.
                      Apply it to the top of mainstream_file.  */
-                  idx_t j;
-                  for (j = edit->j2; j > edit->j1; )
+                  ptrdiff_t j;
+                  for (j = edit->j2; j >= edit->j1; j--)
                     {
-                      j--;
                       struct entry *added_entry = modified_file.entries[j];
                       gl_list_add_first (result_entries, added_entry);
                     }
@@ -1623,11 +1622,10 @@ There is NO WARRANTY, to the extent permitted by law.\n\
                           {
                             gl_list_node_t node_for_insert =
                               result_entries_pointers[k_first];
-                            idx_t j;
+                            ptrdiff_t j;
                             idx_t i;
-                            for (j = edit->j2; j > edit->j1; )
+                            for (j = edit->j2; j >= edit->j1; j--)
                               {
-                                j--;
                                 struct entry *new_entry = modified_file.entries[j];
                                 gl_list_add_before (result_entries, node_for_insert, new_entry);
                               }