Re: [PATCH 1/5] sequencer: factor code out of revert builtin
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Nov 15, 2011, 09:47 UTC
- Message-ID
- <20111115094739.GA23139@elie.hsd1.il.comcast.net>
- In-Reply-To
- <buo4ny5u4k6.fsf@dhlpc061.dev.necel.com>
Miles Bader wrote:
> Does git not use the common practice of self-contained headers?
It usually does, with two exceptions.
Headers do not usually include git-compat-util.h directly, which is a good thing, since it reminds callers to include git-compat-util.h before anything else.
Headers might sometimes forget to declare types defined in cache.h, which would be a mistake. For example, in branch.h we see:
int validate_new_branchname(const char *name, struct strbuf *ref, int force, int attr_only);
Which means the following code does not type-check:
#include "git-compat-util.h" #include "branch.h" #include "strbuf.h"
int demo(const char *name, struct strbuf *ref)
{
return validate_new_branchname(name, ref, 0, 0);
}Reordering the #includes to put strbuf.h before branch.h is a possible workaround. Adding the missing forward declaration is better:
diff --git i/branch.h w/branch.h index 1285158d..d5240a20 100644 --- i/branch.h +++ w/branch.h @@ -1,6 +1,9 @@ #ifndef BRANCH_H #define BRANCH_H +struct strbuf; +enum branch_track; + /* Functions for acting on the information about branches. */ /*