#1124398 git-deborig can leave working tree dirty

#1124398#5
Date:
2025-12-31 13:04:22 UTC
From:
To:
git-deborig:

 1. Installs a new .git/info/attributes
 2. Does some stuff
 3. Deletes the .git/info/attributes or restores a preexisting one

This is not sound.  If it crashes during 2 (whether because it detects
errors, or maybe got a signal or something) the .git/info/attributes
file is left in place.

After that, the user's git tree may start to behave oddly.
Furthermore, currently, there isn't even any note left in
the .git/info/attributes to say what happened!

The corruption is only that gitattributes are defused when not
expected.  This will become worse if we make git-deborig defuse *all*
the attributes, not just export-*.

Looking at the git documentation, I think git-deborig needs to use a
playtree.

Ian.

#1124398#10
Date:
2025-12-31 17:01:18 UTC
From:
To:
The more serious of these two bugs

  #1124383  git-deborig can capriciously leave gitattributes defused

has been significantly mitiigated bu 42684a225d21 (commit messabe
below).  I want to represent the various behaviours in the BTS, so I'm
cloning it, so that the fixed/found and done states can be different.

The new bug "git-deborig can leave working tree dirty" is in dgit 14.0
only, and replaces the more serious #1124383 (which is present in
13.20 and has existed in git-deborig since before it arrived in
src:dgit).


Both #1124383 and

  #1124384   git-deborig needs to use $negate_harmful_gitattrs

can be fully fixed by the folowing set of code changes:

 * Arrange for git-deborig to use a playtree;

 * Partially revert 42684a225d21, fishing out the .git/info/attributes
   writing code (minus the save/restore) and use it in the playtree;

 * Make the .git/info/attributes content use $negate_harmful_gitattrs
   rather than open-coding some gitattributes to suppress.

Ian.

  42684a225d210c558cb642b5fd6aae298b96a5d2

  git-deborig: Defuse all harmful gitattributes, by editing the working tree

  This relates to thse bugs:
    #1111548  tag2upload service makes .origs with un-defused gitattributes
    #1124383  git-deborig can capriciously leave gitattributes defused
    #1124384  git-deborig needs to use $negate_harmful_gitattrs

  The problem in tag2upload (#1111548) is because git-debpush replaces the
  .git/info/attributes file installed by tag2upload's dgit setup-gitattributes
  with one which doesn't defuse *all* the attributes (#1124384).

  Ideally we'd use a playtree (#1124383) but that's a bigger job than I have
  time for now.  Instead, we can take a different approach:

   - Remove the working tree's copy of .gitattributes
   - Use git-archive --worktree-attributes
   - Put the working tree's .gitattributes back later

  I think removing .gitattributes ought to completely neuter existing
  gitattributes transformations (at least on Unix).

  So this fixes tag2upload (#1111548); greatly mitigates the corrupted config
  hazard (#1124383) by turning it into a much more visible damaged working tree
  hazard; and sidesteps for now the need for a full attribute list (#1124384).

  Closes: #1111548
  Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>