git cannot represent empty directories by default
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| usd-importer |
Undecided
|
Robie Basak | ||
| dgit (Debian) |
New
|
Unknown
|
Bug Description
At least src:software-
in the source package, e.g. in 0.96.20.5 in xenial on Ubuntu, and git
(and thus the Ubuntu git importer) fail to
properly represent the srcpkg's contents in the import.
Specifically, tests/aptroot/
Given that git does not represent empty directories, I'm not sure what
we should do here.
List of known affected packages:
apache2
apparmor
debootstrap
exim4
gettext
mongodb
nagios-nrpe
ssl-cert
supermin
qemu
nmap
[Workaround]
Use the --no-verify to ignore the error.
Related branches
- Nish Aravamudan: Approve on 2017-05-22
-
Diff: 264 lines (+183/-18)5 files modifiedgitubuntu/clone.py (+19/-0)
gitubuntu/git_repository.py (+131/-0)
gitubuntu/importer.py (+2/-18)
hooks/post-checkout (+15/-0)
hooks/pre-commit (+16/-0)
Nish Aravamudan (nacc) wrote : | #1 |
Changed in usd-importer: | |
assignee: | nobody → Robie Basak (racb) |
status: | New → Confirmed |
Christian Ehrhardt (paelzer) wrote : | #3 |
I haven't looked at the others yet, but for the exim4 case that is a dir called "Local".
BTW this easily finds offenders:
$ find . -depth -empty
What I find interesting is that they maintain it in git at https:/
There the clue for them is that they only maintain the Debian dir itself which is free of issues. The "Local" dir in this case is from exim4 tarball.
It would be a major change in tree structure if we would do so as well and keep content outside of debian/ as tarball only. But since we already restore tarballs as needed we could use that.
OTOH we would also loose a lot of ability like easily comparing old and new content between package versions. And also the permanent "dirtiness" of the Tree when unpacked would be something I'd not like.
The suggestions of searches lead to files like .gitkeep, and "usd build" could maybe build and restore those as needed.
Looking forward to discuss later today ....
Christian Ehrhardt (paelzer) wrote : | #4 |
well the empty also spots empty files :-/, but one can add "-type d" to fix that.
I wanted to comlete the circle for exim and since it is developed upstream in git as well there is no empty Dir there either.
When upstream creates their tarballs from git the dir is created.
description: | updated |
description: | updated |
description: | updated |
Changed in dgit (Debian): | |
status: | Unknown → New |
description: | updated |
Changed in usd-importer: | |
status: | Confirmed → Fix Released |
Christian Ehrhardt (paelzer) wrote : | #6 |
also affects apache2 (xenial at least)
WARNING: empty directories exist but are not tracked by git:
docs/manual/
docs/manual/
These will silently disappear on commit, causing extraneous
unintended changes. See: LP: #1687057.
description: | updated |
description: | updated |
Also affects samba ?
(c)inaddy@
ERROR: Empty directories exist and will disappear on commit, causing
extraneous unintended changes:
source4/
See LP: #1687057.
Use "git commit --no-verify ..." to ignore this problem.
pre-commit hook failed.
Bryce Harrington (bryce) wrote : | #8 |
There may also be old branches affected as well
$ git checkout remotes/
Branch 'xenial-security' set up to track remote branch 'ubuntu/
Switched to a new branch 'xenial-security'
WARNING: empty directories exist but are not tracked by git:
crypto/des/t
include
These will silently disappear on commit, causing extraneous
unintended changes. See: LP: #1687057.
Bryce Harrington (bryce) wrote : | #9 |
Christian's right that 99% of suggestions are to add a .gitkeep or similar, but found a couple other kludgy workaround ideas:
1. Add the empty dir as a submodule
https:/
find . -type d -empty -delete -exec git submodule add -f https:/
2. Add a broken symlink in the empty dir
https:/
mkdir empty
ln -s .this.directory empty/.keep
git add -f empty/.keep
git commit -m synthetic-dir
Not sure what side effects or ramifications these would have.
For a proper solution, sounds like git upstream might accept a well-coded fix, but that's probably too out of scope for us for now.
Paride Legovini (paride) wrote : | #10 |
The official git FAQ [1] suggest using an en .gitignore file as a placeholder for empty directories. This is also what git-svn does, see the --placeholder-
Paride
[1] https:/
Paride Legovini (paride) wrote : | #11 |
typo fix: an *empty* .gitignore file
Robie Basak (racb) wrote : Re: [Bug 1687057] Re: git cannot represent empty directories by default | #12 |
On Mon, Jun 29, 2020 at 12:37:33PM -0000, Paride Legovini wrote:
> The official git FAQ [1] suggest using an en .gitignore file as a
> placeholder for empty directories. This is also what git-svn does, see
> the --placeholder-
Unfortunately that's not an option for git-ubuntu since we can't change
the source that we're importing.
Or if we do, then we have to do it in a reversible way, such as how we
do the .git escaping (if .git is present then it gets imported into git
as ..git).
Otherwise we end up in a situation where a build based on git-ubuntu
sources would fail to build, or result in a different build, from a
build from the source package that git-ubuntu imported.
Paride Legovini (paride) wrote : | #13 |
As I hit this with apache2 I tried to figure out a solution.
If we use an empty file as placeholder in empty directories then I think the build won't fail, as the diff with the orig source tree would still be empty. There's also a list of file patterns that dpkg-source ignores when checking the diff (see `dpkg-source --help`):
'(?:^|/
so an empty .git-ubuntu-
This file is ignored by dpkg-source (as it matches the first regex and also because it's empty), but it's *also* auto-removed by dh_clean, which runs before the actual build. (See dh_clean(1), where it's documented that *~ files are removed). This should ensure we get identical build results.
Affects src:apparmor, src:gettext, src:ssl-cert, src:supermin,