Skip to content

Commit

Permalink
object.h: centralize object flag allocation
Browse files Browse the repository at this point in the history
While the field "flags" is mainly used by the revision walker, it is
also used in many other places. Centralize the whole flag allocation to
one place for a better overview (and easier to move flags if we have
too).

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Mar 25, 2014
1 parent 79fcbf7 commit 208acbf
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 7 deletions.
3 changes: 1 addition & 2 deletions bisect.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
static const char *argv_show_branch[] = {"show-branch", NULL, NULL};
static const char *argv_update_ref[] = {"update-ref", "--no-deref", "BISECT_HEAD", NULL, NULL};

/* bits #0-15 in revision.h */

/* Remember to update object flag allocation in object.h */
#define COUNTED (1u<<16)

/*
Expand Down
2 changes: 1 addition & 1 deletion builtin/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static unsigned blame_copy_score;
#define BLAME_DEFAULT_MOVE_SCORE 20
#define BLAME_DEFAULT_COPY_SCORE 40

/* bits #0..7 in revision.h, #8..11 used for merge_bases() in commit.c */
/* Remember to update object flag allocation in object.h */
#define METAINFO_SHOWN (1u<<12)
#define MORE_THAN_ONE_PATH (1u<<13)

Expand Down
1 change: 1 addition & 0 deletions bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ static int list_refs(struct ref_list *r, int argc, const char **argv)
return 0;
}

/* Remember to update object flag allocation in object.h */
#define PREREQ_MARK (1u<<16)

int verify_bundle(struct bundle_header *header, int verbose)
Expand Down
2 changes: 1 addition & 1 deletion commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ void sort_in_topological_order(struct commit_list **list, enum rev_sort_order so

/* merge-base stuff */

/* bits #0..15 in revision.h */
/* Remember to update object flag allocation in object.h */
#define PARENT1 (1u<<16)
#define PARENT2 (1u<<17)
#define STALE (1u<<18)
Expand Down
1 change: 1 addition & 0 deletions fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static int agent_supported;
static struct lock_file shallow_lock;
static const char *alternate_shallow_file;

/* Remember to update object flag allocation in object.h */
#define COMPLETE (1U << 0)
#define COMMON (1U << 1)
#define COMMON_REF (1U << 2)
Expand Down
3 changes: 1 addition & 2 deletions http-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ enum XML_Status {
#define LOCK_TIME 600
#define LOCK_REFRESH 30

/* bits #0-15 in revision.h */

/* Remember to update object flag allocation in object.h */
#define LOCAL (1u<<16)
#define REMOTE (1u<<17)
#define FETCHING (1u<<18)
Expand Down
13 changes: 13 additions & 0 deletions object.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ struct object_array {
#define OBJECT_ARRAY_INIT { 0, 0, NULL }

#define TYPE_BITS 3
/*
* object flag allocation:
* revision.h: 0---------10
* fetch-pack.c: 0---4
* walker.c: 0-2
* upload-pack.c: 11----------------19
* builtin/blame.c: 12-13
* bisect.c: 16
* bundle.c: 16
* http-push.c: 16-----19
* commit.c: 16-----19
* sha1_name.c: 20
*/
#define FLAG_BITS 27

/*
Expand Down
1 change: 1 addition & 0 deletions revision.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "commit.h"
#include "diff.h"

/* Remember to update object flag allocation in object.h */
#define SEEN (1u<<0)
#define UNINTERESTING (1u<<1)
#define TREESAME (1u<<2)
Expand Down
2 changes: 2 additions & 0 deletions sha1_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,8 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned l
* For future extension, ':/!' is reserved. If you want to match a message
* beginning with a '!', you have to repeat the exclamation mark.
*/

/* Remember to update object flag allocation in object.h */
#define ONELINE_SEEN (1u<<20)

static int handle_one_ref(const char *path,
Expand Down
2 changes: 1 addition & 1 deletion upload-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

static const char upload_pack_usage[] = "git upload-pack [--strict] [--timeout=<n>] <dir>";

/* bits #0..7 in revision.h, #8..10 in commit.c */
/* Remember to update object flag allocation in object.h */
#define THEY_HAVE (1u << 11)
#define OUR_REF (1u << 12)
#define WANTED (1u << 13)
Expand Down
1 change: 1 addition & 0 deletions walker.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static int process_tree(struct walker *walker, struct tree *tree)
return 0;
}

/* Remember to update object flag allocation in object.h */
#define COMPLETE (1U << 0)
#define SEEN (1U << 1)
#define TO_SCAN (1U << 2)
Expand Down

0 comments on commit 208acbf

Please sign in to comment.