Re: git reset --hard can leave modified files
- From
Torsten Bögershausen <tboegi@web.de>
- Date
- May 4, 2022, 15:42 UTC
- Message-ID
- <20220504154228.wxk6scaqtzri5w42@tb-raspi4>
- In-Reply-To
- <CY5PR11MB608955D3020A85983471A260C6C19@CY5PR11MB6089.namprd11.prod.outlook.com>
On Mon, May 02, 2022 at 10:07:11PM +0000, Mirochnik, Oleg V wrote: []
Show 10 quoted lines
> > > > In other words > > (I may be wrong due a lack of time to dig deeper into the llvm repo) the problem > > seems to come from upstream. > > > > And we could find out, what upstream really wants and needs, and may be able > > to help here. > > > > Is this maybe something you can do, contact upstream ? > No, I could not as I'm not a llvm contributor.
You can become one ;-)
Show 5 quoted lines
> Here is another related discussion, hopefully could be useful -- https://reviews.llvm.org/D48494 > > Actually, I don't quite understand what your suggestions are. > > Are you telling it's not a git bug but an invalid setup in the llvm-project repo?
Yes
Show 7 quoted lines
> If so, then I'd suggest you (or git community) provide a clear description > (or link to a related document) what needs to be done to make it valid > and I'd ask one of our contributors to propose a correspondent fix into the upstream. > Or you agree it's a bug. > Then I'd ask to propose your recommendations as a temporary (or permanent) workaround. > > Could you please clarify?
Now, the documentation, which I think you ask for, is here: https://git-scm.com/docs/gitattributes
If I look at the repo, commit 4ff40855fcc0c1320f31350bc9e93d4d6ce6891f (HEAD -> git-bug-reproducer, origin/git-bug-reproducer)
and run the official eol-diagnostic tool: $ git ls-files --eol >eol-prob.txt and then $ grep "^i/crlf.*attr/text" eol-prob.txt I get 9 files listed, so I pick the first one for a discussion:
i/crlf w/crlf attr/text eol=crlf clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
What we have in the repo is a "conflict". The attributes says it is a text file, and the index file (what had been commited) has CRLF. Git can not resolve the conflict. (setting text=auto could work. Or normalize. Or both. Normalization is recomended anyway)
So, the solution would be to renormalize all files:
$ git add --renormalize . (The . is important)
After that you will see those 9 files modified, and they need to be commited.
In general, for a cross-platform project, it could be useful to set up a .gitattributes file in the top directory, with one line: * text=auto
That file can then be tweaked for BAT or sh files as needed.
That should all be in the documentation - if not, please ask and/or send us patches.