"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
got rebase or diff library bug
To:
gameoftrees@openbsd.org
Date:
Sat, 3 Aug 2024 02:22:26 +0200

Download raw body.

Thread
Weird things happen when you commit a change that adds a line without
terminating '\n' at the end of a file, and then rebase or histedit
that change.

$ cd src        # OpenBSD src checkout
$ got br -c master dummy
Switching work tree from refs/heads/master to refs/heads/dummy
$ tar xzvf ~/llvm18.tar.gz '*/GCNRegPressure.cpp'
gnu/llvm/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
$ hexdump -C gnu/llvm/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp | tail -3
000053d0  20 66 61 6c 73 65 3b 0a  0a 23 75 6e 64 65 66 20  | false;..#undef |
000053e0  50 46 58 0a 7d                                    |PFX.}|
000053e5
$ got ci -m whatever
M  gnu/llvm/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
Created commit 28d598d2212490682514aca54d70befb8e86e176
$ got up -c master
U  gnu/llvm/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
Updated to refs/heads/dummy: 141c93e2a20bfc66591c104e112b9ad964e23e22
$ got he
[... pick commit...]
$ hexdump -C gnu/llvm/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp | tail -3
000053e0  6e 20 66 61 6c 73 65 3b  0a 0a 23 75 6e 64 65 66  |n false;..#undef|
000053f0  20 50 46 58 0a 7d 2e 0a  34 37 31 63 0a           | PFX.}..471c.|
000053fd

In this case, ".\n471c\n" is reproducibly appended.  Some sort of
internal leakage from the diff library?


I just tried a simpler case in a dummy repository with a file "hello"

hello
world

then "echo -n fubar >>hello", and after commit and histedit... the
file is empty.

Commit diff before, from the histedit backup:

--- hello
+++ hello
@@ -1,2 +1,3 @@
 hello
 world
+fubar
\ No newline at end of file

Commit diff after histedit:

--- hello
+++ hello
@@ -1,2 +0,0 @@
-hello
-world

Ugh.

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de