Search code examples
ibm-midrangegit-diff

git diff odd characters on IBM i operating system


I am getting weird output when doing a git diff from bash on an IBM i machine (fka iSeries). For example, below there are ^[[ characters suffixed with an integer. How do I get these to show as a normal git diff without all the extra busyness.

^[[1mdiff --git a/libtest/GNUmakefile b/libtest/GNUmakefile^[[m
^[[1mindex 9e70664..65c3097 100644^[[m
^[[1m--- a/libtest/GNUmakefile^[[m
^[[1m+++ b/libtest/GNUmakefile^[[m
^[[36m@@ -153,6 +153,13 @@^[[m ^[[mifneq ($(findstring mingw, $(OS)),)^[[m
   LIBEXT = dll^[[m
   PICFLAGS=^[[m
 endif^[[m
^[[32m+^[[m
^[[32m+^[[m^[[32mifeq ($(OS), os400)^[[m
^[[32m+^[[m^[[32m  LIBEXT = a^[[m
^[[32m+^[[m^[[32m  SOFLAGS = -shared -static-libgcc^[[m
^[[32m+^[[m^[[32m  PICFLAGS += -pthread^[[m
^[[32m+^[[m^[[32mendif^[[m
^[[32m+^[[m

Solution

  • This is most likely due to git coloring and IBMi's translation of [ (bracket) characters.

    You can check whether git coloring is turned on by running the following:

    $ git config --list
    [email protected]
    user.name=Aaron Bartell
    color.ui=auto
    core.repositoryformatversion=0
    core.filemode=true
    core.bare=false
    core.logallrefupdates=true
    core.ignorecase=true
    

    In this case color.ui=auto is turning coloring on for everything. Run the following command to turn coloring off for just git diff:

    git config --global color.diff false

    Now when you run git diff it should look as you'd expect:

    diff --git a/libtest/GNUmakefile b/libtest/GNUmakefile
    index 9e70664..65c3097 100644
    --- a/libtest/GNUmakefile
    +++ b/libtest/GNUmakefile
    @@ -153,6 +153,13 @@ ifneq ($(findstring mingw, $(OS)),)
       LIBEXT = dll
       PICFLAGS=
     endif
    +
    +ifeq ($(OS), os400)
    +  LIBEXT = a
    +  SOFLAGS = -shared -static-libgcc
    +  PICFLAGS += -pthread
    +endif
    +