Package: git-buildpackage
Version: 0.9.22
Severity: important
X-Debbugs-Cc: h...@pexip.com

Dear Maintainer,

*** Reporter, please consider answering these questions, where appropriate ***

   * What led up to the situation?
   * What exactly did you do (or not do) that was effective (or
     ineffective)?
   * What was the outcome of this action?
   * What outcome did you expect instead?

*** End of the template - remove these template lines ***
import-dsc leaves a dangling treeish when importing a dsc with multiple 
components.

For example, sqlite3

```
$ dget --download-only --quiet --allow-unauthenticated 
http://ftp.debian.org/debian/pool/main/s/sqlite3/sqlite3_3.34.1-3.dsc
$ gbp import-dsc -v --pristine-tar sqlite3_3.34.1-3.dsc
gbp:debug: ['git', 'rev-parse', '--show-cdup']
gbp:debug: Upstream version: 3.34.1
gbp:debug: Debian version: 3
gbp:debug: Upstream tarball: /tmp/sqlite3/sqlite3_3.34.1.orig.tar.xz
gbp:debug: Additional tarballs: /tmp/sqlite3/sqlite3_3.34.1.orig-www.tar.xz
gbp:debug: Debian patch: /tmp/sqlite3/sqlite3_3.34.1-3.debian.tar.xz
gbp:info: No git repository found, creating one.
gbp:debug: ['git', 'init']
gbp:debug: ['git', 'rev-parse', '--show-cdup']
gbp:debug: ['git', 'rev-parse', '--is-bare-repository']
gbp:debug: ['git', 'rev-parse', '--git-dir']
gbp:debug: tar ['-C', '/tmp/sqlite3/tmp4mt7atb8', '-a', '-xf', 
'/tmp/sqlite3/sqlite3_3.34.1.orig.tar.xz'] []
gbp:info: Found component tarball 'sqlite3_3.34.1.orig-www.tar.xz'
gbp:debug: tar ['-C', '/tmp/sqlite3/tmp4mt7atb8/tmpcrfvrq1w', '-a', '-xf', 
'/tmp/sqlite3/sqlite3_3.34.1.orig-www.tar.xz'] []
gbp:debug: rm ['-rf', '/tmp/sqlite3/tmp4mt7atb8/tmpcrfvrq1w'] []
gbp:debug: ['git', 'tag', '-l', 'debian/3.34.1-3']
gbp:debug: ['git', 'tag', '-l', 'debian/3.34.1-3']
gbp:debug: ['git', 'tag', '-l', 'upstream/3.34.1']
gbp:debug: ['git', 'tag', '-l', 'upstream/3.34.1']
gbp:debug: ['git', 'tag', '-l', 'upstream/3.34.1']
gbp:debug: ['git', 'tag', '-l', 'upstream/3.34.1']
gbp:debug: ['git', 'add', '-f', '.']
gbp:debug: ['git', 'write-tree']
gbp:debug: ['git', 'commit-tree', '1d6f0d8b6276d7ee72fa76fcd2e4cd2d35b86b33']
gbp:debug: ['git', 'update-ref', '-m', 'gbp: Import Upstream version 3.34.1', 
'refs/heads/master', 'cefbc7af913751e761e8b9ff7beb83e0d3f59abe']
gbp:debug: ['git', 'symbolic-ref', 'HEAD']
gbp:debug: ['git', 'show-ref', 'refs/heads/master']
gbp:debug: ['git', 'branch', 'upstream', 'master']
gbp:debug: ['git', 'tag', '-m', 'Upstream version 3.34.1', 'upstream/3.34.1', 
'cefbc7af913751e761e8b9ff7beb83e0d3f59abe']
gbp:debug: ['git', 'show-ref', '--verify', 'refs/heads/master']
gbp:debug: tar ['-C', '.', '-a', '-xf', 
'/tmp/sqlite3/sqlite3_3.34.1-3.debian.tar.xz'] []
gbp:debug: ['git', 'rev-parse', '--quiet', '--verify', 
'cefbc7af913751e761e8b9ff7beb83e0d3f59abe^{commit}']
gbp:debug: ['git', 'branch', '--contains', 
'cefbc7af913751e761e8b9ff7beb83e0d3f59abe']
gbp:debug: ['git', 'add', '-f', '.']
gbp:debug: ['git', 'write-tree']
gbp:debug: ['git', 'rev-parse', '--quiet', '--verify', 'master']
gbp:debug: ['git', 'commit-tree', 'a39172afdec174692199169ccecf1578cfc4b84e', 
'-p', 'cefbc7af913751e761e8b9ff7beb83e0d3f59abe']
gbp:debug: ['git', 'update-ref', '-m', 'gbp: Import Debian changes 3.34.1-3', 
'refs/heads/master', '9ab03e07211eb7c103ebd31fabc5325f47cd2d8d', 
'cefbc7af913751e761e8b9ff7beb83e0d3f59abe']
gbp:debug: ['git', 'tag', '-m', 'Debian release 3.34.1-3', 'debian/3.34.1-3', 
'9ab03e07211eb7c103ebd31fabc5325f47cd2d8d']
gbp:debug: ['git', 'ls-tree', '-z', 'cefbc7af913751e761e8b9ff7beb83e0d3f59abe', 
'--']
gbp:debug: ['git', 'mktree', '-z']
gbp:debug: ['git', 'ls-tree', '-z', 'cefbc7af913751e761e8b9ff7beb83e0d3f59abe', 
'--']
gbp:debug: Creating pristine tar commit 
'/tmp/sqlite3/sqlite3_3.34.1.orig-www.tar.xz' from 
'caa99a00bc6709686138dd8813a810f6fa9eef90'
gbp:debug: pristine-tar [] ['commit', 
'/tmp/sqlite3/sqlite3_3.34.1.orig-www.tar.xz', 
'caa99a00bc6709686138dd8813a810f6fa9eef90']
gbp:debug: pristine-tar [] ['commit', 
'/tmp/sqlite3/sqlite3_3.34.1.orig.tar.xz', 
'b8d2ba8963a49f910bb8dfe27e0a3926c3f9a72c']
gbp:debug: ['git', 'symbolic-ref', 'HEAD']
gbp:debug: ['git', 'show-ref', 'refs/heads/master']
gbp:debug: ['git', 'rev-parse', '--quiet', '--verify', 'master']
gbp:debug: ['git', 'reset', '--quiet', '--hard', 
'9ab03e07211eb7c103ebd31fabc5325f47cd2d8d', '--']
gbp:debug: rm ['-rf', '/tmp/sqlite3/tmp4mt7atb8'] []
gbp:info: Version '3.34.1-3' imported under '/tmp/sqlite3/sqlite3'
```

gbp imports ok, but leaves a dangling tree-ish
```
$ git fsck --lost-found
Checking object directories: 100% (256/256), done.
dangling tree b8d2ba8963a49f910bb8dfe27e0a3926c3f9a72c
```

This means that if you push (not mirror), or prune dangling objects, you cannot 
checkout the main tarball.
```
$ git reflog expire --expire=now && git gc --aggressive --prune=now && git fsck 
--lost-found
Enumerating objects: 2909, done.
Counting objects: 100% (2909/2909), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2884/2884), done.
Writing objects: 100% (2909/2909), done.
Total 2909 (delta 730), reused 0 (delta 0), pack-reused 0
Checking object directories: 100% (256/256), done.
Checking objects: 100% (2909/2909), done.

$ git checkout pristine-tar
$ pristine-tar checkout sqlite3_3.34.1.orig.tar.xz
fatal: ambiguous argument 'b8d2ba8963a49f910bb8dfe27e0a3926c3f9a72c^{tree}': 
unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: not a valid object name: b8d2ba8963a49f910bb8dfe27e0a3926c3f9a72c^{tree}
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
pristine-tar: command failed: git archive --format=tar 
b8d2ba8963a49f910bb8dfe27e0a3926c3f9a72c\^\{tree\} | (cd 
'/tmp/pristine-tar.0K_dbuDp2t' && tar x)
```

After playing this afternoon, my quick fix is
```diff
diff --git a/gbp/deb/git.py b/gbp/deb/git.py
index 4a17c2d..8ec06b2 100644
--- a/gbp/deb/git.py
+++ b/gbp/deb/git.py
@@ -292,7 +292,7 @@ class DebianGitRepository(PkgGitRepository):
                        tarball the other ones additional tarballs.
         """
         components = [t.component for t in sources[1:]]
-        main_tree = self.tree_drop_dirs(upstream_tree, components)
+        main_tree = upstream_tree  # self.tree_drop_dirs(upstream_tree, 
components)

         try:
             for source in sources[1:]:
```

-- System Information:
Debian Release: 11.4
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-17-amd64 (SMP w/16 CPU threads)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=sh: 0: getcwd() failed: 
No such file or directory
UTF-8), LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages git-buildpackage depends on:
ii  devscripts             2.21.3+deb11u1
ii  git                    1:2.30.2-1
ii  man-db                 2.9.4-2
ii  python3                3.9.2-3
ii  python3-dateutil       2.8.1-6pexip3
ii  python3-pkg-resources  52.0.0-4
ii  sensible-utils         0.0.14

Versions of packages git-buildpackage recommends:
ii  cowbuilder        0.89
ii  pbuilder          0.231
ii  pristine-tar      1.49
ii  python3-requests  2.25.1+dfsg-2

Versions of packages git-buildpackage suggests:
pn  python3-notify2  <none>
ii  sudo             1.9.5p2-3
ii  unzip            6.0-26+deb11u1

-- no debconf information

Reply via email to