Re: [PATCH 1/5] sequencer: factor code out of revert builtin

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

 



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. */
 
 /*
-- 
--
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]