2

I'm using git filters (specifically clean) to sort some xml files before checking them into the repository. However, the local files remain as they were - even a smudge filter doesn't do anything (presumably since they haven't been checked out).

Thus, if we do a diff using an IDE for example, it will compare against the file on disk - thus showing incorrect diffs vs what was actually committed to the repo.

Is there any way to force git to re-check-out on commit, so that the local file mirrors what is in the staging area?

Moe Far
  • 2,742
  • 2
  • 23
  • 41
karlos
  • 3,965
  • 3
  • 16
  • 19
  • You can pass the pathname to a filter with `%F` (`%f`? I forget) so you could have it duplicate its output to a temp file and replace the original when done. – jthill May 20 '15 at 01:47
  • It's a little hard to understand what you're doing and trying to do. For example, what does it mean to use `git clean` to sort XML files? That doesn't really make sense. – Craig McQueen May 20 '15 at 01:49
  • 1
    @CraigMcQueen I think he's referring to the 'clean' and 'smudge' directions of a content filter set by the `filter` attribute, not the `git clean` command – jthill May 20 '15 at 03:06
  • 1
    @jthill you are correct, I updated the question to clarify this. I think the idea of piping the output with `%f` will work, I will experiment with using `tee` for this purpose. Still wondering however if I'm not doing something untoward or un-git-like - is there a different paradigm I should be following? How do others deal with things like XML files or other text-based files that are generated through UI tools and that might change ordering of elements, making it difficult to monitor differences accordingly? Or do you use XML diff tools instead? I found some but most seemed to be paid.. – karlos May 22 '15 at 21:26

1 Answers1

0

I proposed an alias in order to force the index to be checked out again.

But you can also limit the checkout to only the files with a smudge filter.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250