File: 0001-git-merge-changelog-Fix-essential-functionality-regr.patch

package info (click to toggle)
gnulib 20250303-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 188,836 kB
  • sloc: ansic: 378,598; sh: 30,630; python: 8,358; cpp: 2,811; yacc: 1,846; perl: 920; makefile: 577; lisp: 328; sed: 11; java: 5
file content (52 lines) | stat: -rw-r--r-- 2,230 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Forwarded: https://lists.gnu.org/archive/html/bug-gnulib/2025-07/msg00209.html
From: Bruno Haible <bruno@clisp.org>
Date: Tue, 29 Jul 2025 09:11:40 +0200
Subject: [PATCH] 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.
---
 ChangeLog                 |  9 +++++++++
 lib/git-merge-changelog.c | 10 ++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/lib/git-merge-changelog.c b/lib/git-merge-changelog.c
index 190dafc140..cc496bb4cb 100644
--- a/lib/git-merge-changelog.c
+++ b/lib/git-merge-changelog.c
@@ -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);
                               }
-- 
2.50.1