Re: Git patch shows tab but files doesn't
On Fri, Feb 12, 2016 at 09:32:32PM +0530, Jagan Teki wrote:
Show 17 quoted lines
> 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