Package: devscripts
Version: 2.10.35
Severity: normal
Tags: patch
debcommit fails if it is run on a git repository with no existing
commits. To reproduce:
> mkdir -p new-git-repo/debian
> git init new-git-repo
> cd new-git-repo
> *create debian/changelog*
> git add .
> debcommit
Expected results: a commit
Actual output:
> fatal: No HEAD commit to compare with (yet)
> debcommit: unable to determine commit message using git (do you mean
> "debcommit -a" or did you forget to run "git add"?)
> Try using the -m flag.
The problem is that you can't run "git diff --cached" on a repository
with no commits in it. The patch I've included does a show-ref test on
HEAD before trying to diff, and if it fails it just takes the entire
debian/changelog by diffing it with /dev/null :-)
Now, I'll be honest and say that I'm not sure that this works in every
scenario, just the ones I've tested. I've made a posting to the git
mailing list about the test's effectivness, and I will post any
additional information I get as soon as I get it, so if you want to
delay this until then that's fine by me.
Cheers,
Eric Gerlach
-- Package-specific info:
--- /etc/devscripts.conf ---
--- ~/.devscripts ---
Not present
-- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.26-1-686 (SMP w/1 CPU core)
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages devscripts depends on:
ii dpkg-dev 1.14.20 Debian package development tools
ii libc6 2.7-13 GNU C Library: Shared libraries
ii perl 5.10.0-13 Larry Wall's Practical Extraction
Versions of packages devscripts recommends:
ii at 3.1.10.1 Delayed job execution and batch pr
ii bsd-mailx [mailx] 8.1.2-0.20071201cvs-3 A simple mail user agent
ii conkeror [www-brow 0.9~git080629-1 keyboard focused web browser with
ii dctrl-tools 2.13.0 Command-line tools to process Debi
ii debian-keyring 2008.07.22 GnuPG (and obsolete PGP) keys of D
ii debian-maintainers 1.42 GPG keys of Debian maintainers
ii dput 0.9.2.32 Debian package upload tool
ii equivs 2.0.7-0.1 Circumvent Debian package dependen
ii fakeroot 1.9.5 Gives a fake root environment
ii git-core 1:1.5.6.5-1 fast, scalable, distributed revisi
ii gnupg 1.4.9-3 GNU privacy guard - a free PGP rep
ii libauthen-sasl-per 2.12-1 Authen::SASL - SASL Authentication
ii libcrypt-ssleay-pe 0.57-1+b1 Support for https protocol in LWP
ii libparse-debcontro 2.005-2 Easy OO parsing of Debian control-
ii libsoap-lite-perl 0.710.08-1 Client and server side SOAP implem
ii libterm-size-perl 0.2-4+b1 Perl extension for retrieving term
ii libtimedate-perl 1.1600-9 Time and date functions for Perl
ii liburi-perl 1.35.dfsg.1-1 Manipulates and accesses URI strin
ii libwww-perl 5.813-1 WWW client/server library for Perl
ii libyaml-syck-perl 1.05-1 Fast, lightweight YAML loader and
ii lintian 1.24.2.1 Debian package checker
ii lsb-release 3.2-19 Linux Standard Base version report
ii mailx 1:20071201-3 Transitional package for mailx ren
ii man-db 2.5.2-2 on-line manual pager
ii openssh-client [ss 1:5.1p1-2 secure shell client, an rlogin/rsh
ii patch 2.5.9-5 Apply a diff file to an original
ii patchutils 0.2.31-4 Utilities to work with patches
ii strace 4.5.17+cvs080723-2 A system call tracer
ii unzip 5.52-12 De-archiver for .zip files
ii wdiff 0.5-18 Compares two files word by word
ii wget 1.11.4-1 retrieves files from the web
Versions of packages devscripts suggests:
ii build-essential 11.4 Informational list of build-essent
pn cvs-buildpackage <none> (no description available)
pn devscripts-el <none> (no description available)
pn gnuplot <none> (no description available)
pn libfile-desktopentry-perl <none> (no description available)
pn libnet-smtp-ssl-perl <none> (no description available)
pn mutt <none> (no description available)
pn svn-buildpackage <none> (no description available)
-- no debconf information
--- /usr/bin/debcommit.old 2008-07-26 17:19:54.000000000 -0400
+++ /usr/bin/debcommit 2008-09-05 19:55:43.000000000 -0400
@@ -580,11 +580,19 @@
} elsif ($prog eq 'bzr') {
@diffcmd = ($prog, 'diff', '--diff-options', '-wu');
} elsif ($prog eq 'git') {
- if ($all) {
- @diffcmd = ('git', 'diff', '-w', '--no-color');
- } else {
- @diffcmd = ('git', 'diff', '-w', '--cached', '--no-color');
- }
+ # Test to see if there is a valid head in this tree
+ my @test_empty_git_cmd = ('git', 'show-ref', '-h', '-q');
+ # Reutrn value of system will should be 1<<8 = 256
+ if (system(@test_empty_git_cmd) == 256) {
+ # No valid head! Rather than fail, cheat and use 'diff'
+ @diffcmd = ('diff', '-u', '/dev/null');
+ } else {
+ if ($all) {
+ @diffcmd = ('git', 'diff', '-w', '--no-color');
+ } else {
+ @diffcmd = ('git', 'diff', '-w', '--cached', '--no-color');
+ }
+ }
} elsif ($prog eq 'svn') {
@diffcmd = ($prog, 'diff', '--diff-cmd', '/usr/bin/diff',
'--extensions', '-wu');
} elsif ($prog eq 'svk') {