]> git.ipfire.org Git - thirdparty/git.git/commit
sequencer: truncate labels to accommodate loose refs
authorMark Ruvald Pedersen <mped@demant.com>
Thu, 10 Aug 2023 16:34:59 +0000 (16:34 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 10 Aug 2023 17:12:29 +0000 (10:12 -0700)
commit7481d2bfca7fd36f63fd437508be2bca338c9477
tree673f3341b56bd8f1ed432ef5bd626c2425f096ea
parentfb7d80edcae482f4fa5d4be0227dc3054734e5f3
sequencer: truncate labels to accommodate loose refs

Some commits may have unusually long subject lines. When those subject
lines are used as labels in the `--rebase-merges` mode of `git rebase`,
they can cause errors when writing the corresponding loose refs because
most file systems have a maximal file name length of 255 (`NAME_MAX`).
The symptom looks like this:

$ git rebase --continue
error: cannot lock ref 'refs/rewritten/SANITIZED-SUBJECT': Unable to create '.git/refs/rewritten/SANITIZED-SUBJECT.lock': File name too long - where SANITIZED-SUBJECT is very long

Let's accommodate this situation by truncating the labels.

Care must be taken in case the subject line contains multi-byte
characters so as not to truncate in the middle of a character.

Signed-off-by: Mark Ruvald Pedersen <mped@demant.com>
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-compat-util.h
sequencer.c