2

(related question for context; tested with git version 2.30.2 on Debian 11)

I have written a git custom diff and filter normalising my .po files to make them diff-able by git diff and by GitLab Merge Requests:

[diff "podiff"]
    textconv = "$(git rev-parse --show-toplevel)"/podiff
    cachetextconv = true
[filter "pocomments"]
    clean = "$(git rev-parse --show-toplevel)"/podiff
    smudge = "$(git rev-parse --show-toplevel)"/podiff
    required

As these files are edited by a number of tools which themselves cannot be convinced to produce diff-able output (notably the MonoDevelop gettext plugin and Poedit), I have taken this "last resort" to somehow get these files under - effective, usable - version control.

Now, according to the manual, I should be able to leave out the smudge filter - but when I remove it, I get variations of "smudge filter failed" on various git operations.

E.g. I start with a clean git status, open poedit, update the catalogue (which forces it to be re-ordered by source file location), exit poedit and start git diff =>

$ git diff
fatal: Internationalization/de.po: smudge-Filter 'pocomments' fehlgeschlagen.

The moment I restore the smudge entry, it works again.

I am vexed, as the documentation suggests a different behaviour (emphasis mine):

In the .gitattributes file, you can set a filter for particular paths and then set up scripts that will process files just before they’re checked out (“smudge”[)] and just before they’re staged (“clean”[)]

(Section Git Attributes | Keyword Expansion)

A filter driver consists of a clean command and a smudge command, either of which can be left unspecified.
[...]
Upon checkout, when the smudge command is specified [...]
Similarly, the clean command is used to convert the contents of worktree file upon checkin.
[...]
If a filter must succeed in order to make the stored contents usable, you can declare that the filter is required [...]

(Section gitattributes | filter)

  • No smudge should happen on git diff - but apparently does.
  • A non-existing smudge filter should be incapable of failing but apparently does.

How does it really work? What is the correct minimal form for my use case?

Is it just impossible to require a filter that only cleans or only smudges? And if I do not require it - what exactly does that mean? The manual is silent.

(Added gettext keyword to invite X/Y answers: Maybe there is a much better solution if I just start further up the toolchain - fiddling with git config and the like always invites problems as third-party tools like GitLab and the various GUIs and IDE integrations cannot or do not even try to handle them.)

0

You must log in to answer this question.

Browse other questions tagged .