Skip to content

Commit 208acbf

Browse files
pcloudsgitster
authored andcommitted
object.h: centralize object flag allocation
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 79fcbf7 commit 208acbf

File tree

11 files changed

+24
-7
lines changed

11 files changed

+24
-7
lines changed

bisect.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
2121
static const char *argv_show_branch[] = {"show-branch", NULL, NULL};
2222
static const char *argv_update_ref[] = {"update-ref", "--no-deref", "BISECT_HEAD", NULL, NULL};
2323

24-
/* bits #0-15 in revision.h */
25-
24+
/* Remember to update object flag allocation in object.h */
2625
#define COUNTED (1u<<16)
2726

2827
/*

builtin/blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static unsigned blame_copy_score;
7474
#define BLAME_DEFAULT_MOVE_SCORE 20
7575
#define BLAME_DEFAULT_COPY_SCORE 40
7676

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

bundle.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ static int list_refs(struct ref_list *r, int argc, const char **argv)
124124
return 0;
125125
}
126126

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

129130
int verify_bundle(struct bundle_header *header, int verbose)

commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ void sort_in_topological_order(struct commit_list **list, enum rev_sort_order so
731731

732732
/* merge-base stuff */
733733

734-
/* bits #0..15 in revision.h */
734+
/* Remember to update object flag allocation in object.h */
735735
#define PARENT1 (1u<<16)
736736
#define PARENT2 (1u<<17)
737737
#define STALE (1u<<18)

fetch-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static int agent_supported;
2626
static struct lock_file shallow_lock;
2727
static const char *alternate_shallow_file;
2828

29+
/* Remember to update object flag allocation in object.h */
2930
#define COMPLETE (1U << 0)
3031
#define COMMON (1U << 1)
3132
#define COMMON_REF (1U << 2)

http-push.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ enum XML_Status {
6464
#define LOCK_TIME 600
6565
#define LOCK_REFRESH 30
6666

67-
/* bits #0-15 in revision.h */
68-
67+
/* Remember to update object flag allocation in object.h */
6968
#define LOCAL (1u<<16)
7069
#define REMOTE (1u<<17)
7170
#define FETCHING (1u<<18)

object.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ struct object_array {
2626
#define OBJECT_ARRAY_INIT { 0, 0, NULL }
2727

2828
#define TYPE_BITS 3
29+
/*
30+
* object flag allocation:
31+
* revision.h: 0---------10
32+
* fetch-pack.c: 0---4
33+
* walker.c: 0-2
34+
* upload-pack.c: 11----------------19
35+
* builtin/blame.c: 12-13
36+
* bisect.c: 16
37+
* bundle.c: 16
38+
* http-push.c: 16-----19
39+
* commit.c: 16-----19
40+
* sha1_name.c: 20
41+
*/
2942
#define FLAG_BITS 27
3043

3144
/*

revision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "commit.h"
88
#include "diff.h"
99

10+
/* Remember to update object flag allocation in object.h */
1011
#define SEEN (1u<<0)
1112
#define UNINTERESTING (1u<<1)
1213
#define TREESAME (1u<<2)

sha1_name.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,8 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned l
819819
* For future extension, ':/!' is reserved. If you want to match a message
820820
* beginning with a '!', you have to repeat the exclamation mark.
821821
*/
822+
823+
/* Remember to update object flag allocation in object.h */
822824
#define ONELINE_SEEN (1u<<20)
823825

824826
static int handle_one_ref(const char *path,

upload-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

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

20-
/* bits #0..7 in revision.h, #8..10 in commit.c */
20+
/* Remember to update object flag allocation in object.h */
2121
#define THEY_HAVE (1u << 11)
2222
#define OUR_REF (1u << 12)
2323
#define WANTED (1u << 13)

0 commit comments

Comments
 (0)