-
Notifications
You must be signed in to change notification settings - Fork 146
object.c: localize global the_repository variable into r #545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: maint
Are you sure you want to change the base?
Changes from all commits
60ffcbd
21e58f7
346cbec
34734be
55a21d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,6 +375,7 @@ static void check_object(struct object *obj) | |
static void check_connectivity(void) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Taylor Blau wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Eric Sunshine wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, parth gala wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Taylor Blau wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Taylor Blau wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Jeff King wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Taylor Blau wrote (reply to this):
|
||
{ | ||
int i, max; | ||
struct repository *r = the_repository; | ||
|
||
/* Traverse the pending reachable objects */ | ||
traverse_reachable(); | ||
|
@@ -400,12 +401,12 @@ static void check_connectivity(void) | |
} | ||
|
||
/* Look up all the requirements, warn about missing objects.. */ | ||
max = get_max_object_index(); | ||
max = get_max_object_index(r); | ||
if (verbose) | ||
fprintf_ln(stderr, _("Checking connectivity (%d objects)"), max); | ||
|
||
for (i = 0; i < max; i++) { | ||
struct object *obj = get_indexed_object(i); | ||
struct object *obj = get_indexed_object(r, i); | ||
|
||
if (obj) | ||
check_object(obj); | ||
|
@@ -744,7 +745,8 @@ static int fsck_cache_tree(struct cache_tree *it) | |
|
||
static void mark_object_for_connectivity(const struct object_id *oid) | ||
{ | ||
struct object *obj = lookup_unknown_object(oid); | ||
struct repository *r = the_repository; | ||
struct object *obj = lookup_unknown_object(r, oid); | ||
obj->flags |= HAS_OBJ; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at object.c after this patch, it sounds as if the commit message oversells it a bit: the following functions still use
the_repository
:lookup_unknown_object()
parse_object_or_die()
clear_object_flags()
andclear_commit_marks_all()
Note: I am not saying that you should modify all of those in the same commit. Instead, I would propose to structure this PR into 6 commits, one per function in
object.c
that needs to take anr
parameter. Each commit will then add that parameter to only one function and adjust all callers of said function, either by using an already-availabler
variable, or by introducing such a variable and initializing it tothe_repository
(these callers, unless they are inbuiltin/*.c
, will have to be modified later to take anr
parameter instead of the local variable).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I failed to notice the
functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be wise to make a single commit for functions
get_max_object_index
andget_indexed_objects
given they have a complete overlap in terms of the functions calling them?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do as you wish, of course, but yes, my suggestion was to structure this by function whose signature is modified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good now, even if I would have preferred individual commits for the two functions (it is just so much easier to review that way).
Having said that, I think the commit message needs some work. Have you looked through the commit history (e.g. via
git log -G'struct repository \*r'
) to see how previous commit messages regarding similar changes were written?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did check previous such commits. Probably my messages need to be more comprehensive in describing their change. But since my commits are essentially doing the same stuff for all the different functions, do I have to keep repeating that message in every commit. Can you please elaborate how I can improve the messages ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not mean to imply that you should repeat a whole lot of text in all the commit messages. To the contrary, I wanted to point out that our commit messages try not to repeat what the associated diff already makes clear. In other words, they focus on the "why?" (unless obvious) over the "how?".
In that light, I would say that the following paragraph is even a bit verbose ;-)
Now, let's compare that to the (very short, maybe even too short) commit message of 90d3405:
My preference would be somewhere in the middle ;-) But then, my preference is also to do this one function at a time (i.e. change one function's signature per commit, adjusting all the callers in the same commit but nothing more), and as you see, the above-mentioned commit does not necessarily follow that rule.
Meaning: you have a lot of leeway how you want to structure and write your commits and commit messages.
You could even
/submit
right now 😄