Re: Is "show-ref -h" a good test for an empty repository?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff King wrote:
On Sun, Sep 07, 2008 at 10:31:52AM -0700, Junio C Hamano wrote:

All depends on how "an empty repository" is defined.  My definition of an
empty repository would have been:

 - No objects in it;
 - No index;
 - No refs except symrefs.

Agreed. In the original message, he used the phrase "no existing
commits" which I latched onto (to mean "no existing commits on this
branch"). But the subject does say "empty repository". :)

Eric, maybe you can tell us more about what you're trying to accomplish?

Sure, I'm writing a patch for the debcommit script for the Debian project. It's a script which parses the Debian changelog for a package, generates a commit message, and commits to an SCM system.

The case I'm looking to protect against is the following:

$ mkdir -p new-repo/debian
$ cd new-repo
$ git init
$ vi debian/changelog (add a few lines)
$ git add debian/changelog
$ debcommit

(which runs
$ git diff --cached debian/changelog)

If I can test before the git-diff, then I can run "diff debian/changelog /dev/null" instead of the git-diff and all is well.

I don't want to test failure of the git-diff itself, because I want debcommit to fail if there's something wrong *other* than a new repo. Also, I want to use a git command to do it, because I don't have any guarantees about how things are setup, other than "we're using git."

I'm okay with debcommit proceeding if the repo has a commit but is borked from manually editing the HEAD ref, but I'm not sure how the maintainers of the script feel about that. So if it's possible to differentiate between the two cases, bonus, but not necessary.

So that's where I'm sitting. Jeff and Junio, thanks for the help and discussion. This is great :-)

(BTW, I'm leaning to the rev-parse right now; looking at the source it seems to be more precise, i.e. has fewer ways to fail)

Cheers,

Eric
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux