Package: git-merge-changelog
Version: 20240117+stable-1
Severity: grave
Tags: patch upstream
Justification: renders package unusable
X-Debbugs-Cc: [email protected]

Dear Maintainer,

*** Reporter, please consider answering these questions, where appropriate ***

   * What led up to the situation?

I configured git-merge-changelog as my merge driver, as documented.

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

Then I did "git pull" in a git repository with a ChangeLog, in which I had
a commit of my own, that modified ChangeLog.

   * What was the outcome of this action?

Either my ChangeLog change was lost (reported at
https://lists.gnu.org/archive/html/bug-gnulib/2025-07/msg00181.html)
or my ChangeLog change overwrote the first of the pulled
ChangeLog changes (reported at
https://lists.gnu.org/archive/html/bug-gnulib/2025-07/msg00198.html).

   * What outcome did you expect instead?

I expected the ChangeLog to contain all pulled entries,
plus my own one on top.
That's precisely the point of using 'git-merge-changelog'.

*** End of the template - remove these template lines ***


-- System Information:
Debian Release: trixie/sid
  APT prefers noble-updates
  APT policy: (500, 'noble-updates'), (500, 'noble-security'), (500, 'noble'), 
(100, 'noble-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.8.0-63-generic (SMP w/12 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages git-merge-changelog depends on:
ii  libc6  2.39-0ubuntu8.5

git-merge-changelog recommends no packages.

git-merge-changelog suggests no packages.

-- no debconf information
>From 21b208f43ab851f9d0747cd45ec67b1b3827e8a2 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Tue, 29 Jul 2025 09:11:40 +0200
Subject: [PATCH 1/4] git-merge-changelog: Fix essential functionality (regr.
 2023-05-21).

Fixes two mistakes in commit a8921605af342b9061e04e18fc952d386e5a071c.

Reported by Patrice Dumas <[email protected]> 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/ChangeLog b/ChangeLog
index a5a766deec..e18ef65048 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-07-29  Bruno Haible  <[email protected]>
+
+       git-merge-changelog: Fix essential functionality (regr. 2023-05-21).
+       Fixes two mistakes in commit a8921605af342b9061e04e18fc952d386e5a071c.
+       Reported by Patrice Dumas <[email protected]> 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  <[email protected]>
 
        float-h: change IBM long double to match GCC 15
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

Reply via email to