git/list[1] front-page[2] threads[3] people[4] search[5] about
 

"git pull --rebase" fails if pager.pull is true, after producing a colorized diff it cannot apply

From
Per Cederqvist <cederp@opera.com>
Date
Aug 3, 2015, 15:21 UTC
Message-ID
<CAP=KgsTp=D1cSPmudDVEe32Q8gHhfSfuL7+V9YGZ65F1ZDUFiA@mail.gmail.com>
If you run:
    git config pager.pull true

in the hope of getting the output of "git pull" via a pager, you are in for a surpise the next time you run "git pull --rebase" and it has to rebase your work. It will fail with a nonsensical error message:

Show 11 quoted lines
> Applying: First B commit
> fatal: unrecognized input
> Repository lacks necessary blobs to fall back on 3-way merge.
> Cannot fall back to three-way merge.
> Patch failed at 0001 First B commit
> The copy of the patch that failed is found in:
>    /home/cederp/badcolor/repo-b/.git/rebase-apply/patch
>
> When you have resolved this problem, run "git rebase --continue".
> If you prefer to skip this patch, run "git rebase --skip" instead.
> To check out the original branch and stop rebasing, run "git rebase --abort".

Using "cat -vet" to look at the problematic patch, you can see that there are embedded escape codes that tries to colorize the patch.

This bug is dependent on the TERM setting. On my system (Ubuntu 14.04) it reproduces if TERM=vt220 or TERM=rxvt-unicode, but not if TERM=dumb. It might depend on the color.diff setting as well, but it does reproduce with the default setting.

The following script reproduces the problem. I've tried both git 2.4.3 and git 2.5.0.

----- cut here ----- #!/bin/sh set -e -x

# All created files are created inside the "badcolor" directory. mkdir badcolor cd badcolor

# Create a bare repo. mkdir upstream.git (cd upstream.git && git init --bare)

# Make an initial commit. git clone upstream.git repo-a (cd repo-a && echo one > a && git add a && git commit -m"First A commit") (cd repo-a && git push origin master)

# Make a second clone. git clone upstream.git repo-b

# Make one more commit, that the second clone won't have for a while. (cd repo-a && echo two > a && git add a && git commit -m"Second A commit") (cd repo-a && git push origin master)

# Create a third commit; this make the history non-linear, but since # the commit only touched a new file it should be trivial to linearize # it. (cd repo-b && echo one > b && git add b && git commit -m"First B commit")

# Set pager.pull true so that we trigger the bug. (cd repo-b && git config pager.pull true)

# Attempt to make the history linear. This command will fail if TERM # specifies a color-capable terminal.

(cd repo-b && git pull --rebase)

exit 0 ----- cut here -----

Thanks,
    /ceder
-- 
Per Cederqvist <cederp@opera.com>
Next: Jeff King
Message 1 of 8 in “"git pull --rebase" fails if pager.pull is true, after producing a colorized diff it cannot apply”
  1. Per CederqvistAug 3, 2015
  2. Jeff KingAug 9, 2015
  3. Jeff KingAug 10, 2015
  4. 1/2 pager_in_use: use git_env_boolJeff King, Aug 10, 2015
  5. 2/2 pager_in_use: make sure output is still going to pagerJeff King, Aug 10, 2015
  6. Johannes SchindelinAug 10, 2015
  7. Jeff KingAug 10, 2015
  8. Per CederqvistAug 11, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.