# Git patch shows tab but files doesn't

2 messages from 2016-02-12 to 2016-02-12. Participants: Jagan Teki, Jeff King.
Thread: https://gitlist.dev/t/41400

## Jagan Teki, 2016-02-12 16:02

Subject: Git patch shows tab but files doesn't
Message-ID: <CAD6G_RTJuNsR6qawgco1H+ocKPThk1HsQLvhQigmzUb_c7UdaQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAD6G_RTJuNsR6qawgco1H%2BocKPThk1HsQLvhQigmzUb_c7UdaQ%40mail.gmail.com

```
Hi,

I edited a file as one space between #define and macro and tab space
between macro and BIT value, similar as below.

#define USE_FSR           BIT(6)
#define SNOR_WR         BIT(7)

Once I created the patch looks different as tab space between #define
and macro and 2 tab spaces between macro and BIT value looks like it's
added tab spaces while creating a patch as below.

+#define        USE_FSR                              BIT(6)
+#define        SNOR_WR                            BIT(7)

Any help how to fix this, was it an issues with vim or do we have any
git-config fixes for this?

-- 
Jagan.

```

## Jeff King, 2016-02-12 18:32

Subject: Re: Git patch shows tab but files doesn't
Message-ID: <20160212183238.GB19973@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20160212183238.GB19973%40sigill.intra.peff.net
In-Reply-To: <CAD6G_RTJuNsR6qawgco1H+ocKPThk1HsQLvhQigmzUb_c7UdaQ@mail.gmail.com>

```
On Fri, Feb 12, 2016 at 09:32:32PM +0530, Jagan Teki wrote:

> Hi,
> 
> I edited a file as one space between #define and macro and tab space
> between macro and BIT value, similar as below.
> 
> #define USE_FSR           BIT(6)
> #define SNOR_WR         BIT(7)
> 
> Once I created the patch looks different as tab space between #define
> and macro and 2 tab spaces between macro and BIT value looks like it's
> added tab spaces while creating a patch as below.
> 
> +#define        USE_FSR                              BIT(6)
> +#define        SNOR_WR                            BIT(7)
> 
> Any help how to fix this, was it an issues with vim or do we have any
> git-config fixes for this?

It's hard to tell from your output, but you can often get tab
realignment on your terminal when viewing a patch, because the tabs are
shifted in by one character (the leading "+"). So if your terminal
is showing (as most do) a tab as "skip to the next tabstop", then:

  1. The size of particular tabs may look quite different if they move
     from an exact tabstop to the next character (or vice versa).

     If the space between your "#define" and the macro name is actually
     a tab, then I'd expect it to exhibit this behavior with a tabstop
     of 8 (because #define is 7 chars).

  2. Spaces don't exhibit this, so two lines which _are_ aligned in the
     source for a specific tabstop may not be in the patch.

Piping the diff (and your file) through "cat -A" can often show more
clearly what's going on.

-Peff

```
