[debhelper-devel] Bug#760033: debhelper: dh_clean removes Git refs information with certain suffixes like .orig, .rej, ...

Michael Prokop mika at debian.org
Sun Aug 31 06:18:58 UTC 2014


Package: debhelper
Version: 9.20140817
Severity: critical
Justification: causes serious data loss


I had a branch named "mika/678696.orig" in one of my Git
repositories and when executing git-buildpackage in it I suddenly
lost Git information for that branch, the reason being dh_clean.

Demonstration with a minimal example:

,---- [ demo ]
| % git init
| Initialized empty Git repository in /tmp/tmp.rDCKYGKXqx/.git/
| % echo init > foo
| % git add foo
| % git commit -m 'init'
| [master (root-commit) 1179777] init
|  1 file changed, 1 insertion(+)
|  create mode 100644 foo
| % git checkout -b demo.orig
| Switched to a new branch 'demo.orig'
| % echo 2nd commit > foo
| % git commit -a -m '2nd commit'
| [demo.orig 65f5bb1] 2nd commit
|  1 file changed, 1 insertion(+), 1 deletion(-)
| % git log --oneline
| 65f5bb1 2nd commit
| 1179777 init
| % mkdir debian
| % touch debian/control
| % dh_clean
| dh_clean: No compatibility level specified in debian/compat
| dh_clean: This package will soon FTBFS; time to fix it!
| dh_clean: Compatibility levels before 5 are deprecated (level 1 in use)
| % git log
| fatal: bad default revision 'HEAD'
| % git status
| On branch demo.orig
|
| Initial commit
|
| Changes to be committed:
|   (use "git rm --cached <file>..." to unstage)
|
|         new file:   foo
|
| Untracked files:
|   (use "git add <file>..." to include in what will be committed)
|
|         debian/
`----

The problem is in dh_clean which is getting rid of certain files,
quoting dh_clean's source code:

,---- [ dh_clean ]
| # Remove other temp files.
| complex_doit("find . $find_options \\( \\( -type f -a \\
|         \\( -name '#*#' -o -name '.*~' -o -name '*~' -o -name DEADJOE \\
|          -o -name '*.orig' -o -name '*.rej' -o -name '*.bak' \\
|          -o -name '.*.orig' -o -name .*.rej -o -name '.SUMS' \\
|          -o -name TAGS -o \\( -path '*/.deps/*' -a -name '*.P' \\) \\
|         \\) -exec rm -f {} + \\) -o \\
|         \\( -type d -a -name autom4te.cache -prune -exec rm -rf {} + \\) \\)");
`----

The situation before executing dh_clean is:

,---- [ git files ]
| % find . -name \*.orig
| ./.git/refs/heads/demo.orig
| ./.git/logs/refs/heads/demo.orig
| %
`----

while *after* executing dh_clean all the demo.orig files in the git
repos are gone.

FTR: this of course doesn't affect just branch names ending with
".orig" but also all the other suffixes/file names listed in above's
dh_clean code snippet. Other VCS might be affected as well, but I
didn't check that.

Command lines for easy reproduction:

  cd $(mktemp -d)
  git init
  echo init > foo
  git add foo
  git commit -m 'init'
  git checkout -b demo.orig
  echo 2nd commit > foo
  git commit -a -m '2nd commit'
  git log --oneline
  mkdir debian
  touch debian/control
  dh_clean

Feel free to adjust severity as needed.

regards,
-mika-




More information about the debhelper-devel mailing list