* [PATCH 0/2] Small log simplifications @ 2012-07-27 17:21 Martin von Zweigbergk 2012-07-27 17:21 ` [PATCH 1/2] remove unnecessary parameter from get_patch_ids() Martin von Zweigbergk 2012-07-27 17:21 ` [PATCH 2/2] log: remove redundant check for merge commit Martin von Zweigbergk 0 siblings, 2 replies; 10+ messages in thread From: Martin von Zweigbergk @ 2012-07-27 17:21 UTC (permalink / raw) To: git; +Cc: Martin von Zweigbergk These are just some things I noticed while looking at the revision walking code. I'm not very familiar with the code at all, so the patches may very well be completely wrong; view them as newbie questions in patch-form if you like. Martin von Zweigbergk (2): remove unnecessary parameter from get_patch_ids() log: remove redundant check for merge commit builtin/log.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) -- 1.7.11.1.104.ge7b44f1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] remove unnecessary parameter from get_patch_ids() 2012-07-27 17:21 [PATCH 0/2] Small log simplifications Martin von Zweigbergk @ 2012-07-27 17:21 ` Martin von Zweigbergk 2012-07-27 22:44 ` Junio C Hamano 2012-07-27 17:21 ` [PATCH 2/2] log: remove redundant check for merge commit Martin von Zweigbergk 1 sibling, 1 reply; 10+ messages in thread From: Martin von Zweigbergk @ 2012-07-27 17:21 UTC (permalink / raw) To: git; +Cc: Martin von Zweigbergk get_patch_ids() takes an already initialized rev_info and a prefix. The prefix is used when initalizing a second rev_info. Since the initialized rev_info already has a prefix and it seems the prefix doesn't change, we can used the prefix from the initialized rev_info to initialize the second rev_info. Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> --- builtin/log.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/log.c b/builtin/log.c index ecc2793..7a92e3f 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -696,7 +696,7 @@ static int reopen_stdout(struct commit *commit, const char *subject, return 0; } -static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const char *prefix) +static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids) { struct rev_info check_rev; struct commit *commit; @@ -717,7 +717,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha init_patch_ids(ids); /* given a range a..b get all patch ids for b..a */ - init_revisions(&check_rev, prefix); + init_revisions(&check_rev, rev->prefix); o1->flags ^= UNINTERESTING; o2->flags ^= UNINTERESTING; add_pending_object(&check_rev, o1, "o1"); @@ -1306,7 +1306,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) if (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0) return 0; } - get_patch_ids(&rev, &ids, prefix); + get_patch_ids(&rev, &ids); } if (!use_stdout) @@ -1525,7 +1525,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) return 0; } - get_patch_ids(&revs, &ids, prefix); + get_patch_ids(&revs, &ids); if (limit && add_pending_commit(limit, &revs, UNINTERESTING)) die(_("Unknown commit %s"), limit); -- 1.7.11.1.104.ge7b44f1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] remove unnecessary parameter from get_patch_ids() 2012-07-27 17:21 ` [PATCH 1/2] remove unnecessary parameter from get_patch_ids() Martin von Zweigbergk @ 2012-07-27 22:44 ` Junio C Hamano 2012-07-28 1:54 ` Martin von Zweigbergk 0 siblings, 1 reply; 10+ messages in thread From: Junio C Hamano @ 2012-07-27 22:44 UTC (permalink / raw) To: Martin von Zweigbergk; +Cc: git Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes: > get_patch_ids() takes an already initialized rev_info and a > prefix. The prefix is used when initalizing a second rev_info. Since > the initialized rev_info already has a prefix and it seems the prefix > doesn't change, we can used the prefix from the initialized rev_info > to initialize the second rev_info. s/it seems the prefix doesn't change/the prefix never changes/; > Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> I think this change shouldn't change the behaviour and is good. Just FYI, during the revision traversal, prefix affects two things in the current code: (1) it is used as the basename for prune data that determine which parts of the tree structure to pay attention to (e.g. "cd t && git log ."). (2) it is used as the basename for diff output when revs->diffopt is used (e.g. "cd t && git log -p"). And check_rev is used with neither. It does not want to prune any part of the tree nor it wants to filter with fancier options like grep/pickaxe (i.e. it does not use setup_revisions()). In that sense it probably does not even matter if you did not pass rev->prefix down to check_rev, and instead gave NULL to it, but that only holds true in the current codebase, so I think what your patch does is the right thing to do. Thanks. > builtin/log.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/builtin/log.c b/builtin/log.c > index ecc2793..7a92e3f 100644 > --- a/builtin/log.c > +++ b/builtin/log.c > @@ -696,7 +696,7 @@ static int reopen_stdout(struct commit *commit, const char *subject, > return 0; > } > > -static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const char *prefix) > +static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids) > { > struct rev_info check_rev; > struct commit *commit; > @@ -717,7 +717,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha > init_patch_ids(ids); > > /* given a range a..b get all patch ids for b..a */ > - init_revisions(&check_rev, prefix); > + init_revisions(&check_rev, rev->prefix); > o1->flags ^= UNINTERESTING; > o2->flags ^= UNINTERESTING; > add_pending_object(&check_rev, o1, "o1"); > @@ -1306,7 +1306,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) > if (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0) > return 0; > } > - get_patch_ids(&rev, &ids, prefix); > + get_patch_ids(&rev, &ids); > } > > if (!use_stdout) > @@ -1525,7 +1525,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) > return 0; > } > > - get_patch_ids(&revs, &ids, prefix); > + get_patch_ids(&revs, &ids); > > if (limit && add_pending_commit(limit, &revs, UNINTERESTING)) > die(_("Unknown commit %s"), limit); ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] remove unnecessary parameter from get_patch_ids() 2012-07-27 22:44 ` Junio C Hamano @ 2012-07-28 1:54 ` Martin von Zweigbergk 0 siblings, 0 replies; 10+ messages in thread From: Martin von Zweigbergk @ 2012-07-28 1:54 UTC (permalink / raw) To: Junio C Hamano; +Cc: git On Fri, Jul 27, 2012 at 3:44 PM, Junio C Hamano <gitster@pobox.com> wrote: > Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes: > > s/it seems the prefix doesn't change/the prefix never changes/; :-) Thanks for confirming. > In that sense it probably does not even matter if you did not pass > rev->prefix down to check_rev, and instead gave NULL to it, but that > only holds true in the current codebase, so I think what your patch > does is the right thing to do. Makes sense. Thanks for explaining! ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] log: remove redundant check for merge commit 2012-07-27 17:21 [PATCH 0/2] Small log simplifications Martin von Zweigbergk 2012-07-27 17:21 ` [PATCH 1/2] remove unnecessary parameter from get_patch_ids() Martin von Zweigbergk @ 2012-07-27 17:21 ` Martin von Zweigbergk 2012-07-27 22:30 ` Junio C Hamano 1 sibling, 1 reply; 10+ messages in thread From: Martin von Zweigbergk @ 2012-07-27 17:21 UTC (permalink / raw) To: git; +Cc: Martin von Zweigbergk While walking the revision list in get_patch_ids and cmd_cherry, we ignore merges by checking if there is more than one parent. However, since the revision walk was initialized with revs.ignore_merges = 1, this would never happen. Remove the unnecessary checks. Also re-initializing rev_info fields to the same values already set in init_revisions(). Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> --- builtin/log.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/builtin/log.c b/builtin/log.c index 7a92e3f..8182a18 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -726,10 +726,6 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids) die(_("revision walk setup failed")); while ((commit = get_revision(&check_rev)) != NULL) { - /* ignore merges */ - if (commit->parents && commit->parents->next) - continue; - add_commit_patch_id(commit, ids); } @@ -1509,8 +1505,6 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) init_revisions(&revs, prefix); revs.diff = 1; - revs.combine_merges = 0; - revs.ignore_merges = 1; DIFF_OPT_SET(&revs.diffopt, RECURSIVE); if (add_pending_commit(head, &revs, 0)) @@ -1534,10 +1528,6 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) if (prepare_revision_walk(&revs)) die(_("revision walk setup failed")); while ((commit = get_revision(&revs)) != NULL) { - /* ignore merges */ - if (commit->parents && commit->parents->next) - continue; - commit_list_insert(commit, &list); } -- 1.7.11.1.104.ge7b44f1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] log: remove redundant check for merge commit 2012-07-27 17:21 ` [PATCH 2/2] log: remove redundant check for merge commit Martin von Zweigbergk @ 2012-07-27 22:30 ` Junio C Hamano 2012-07-28 4:52 ` Martin von Zweigbergk 0 siblings, 1 reply; 10+ messages in thread From: Junio C Hamano @ 2012-07-27 22:30 UTC (permalink / raw) To: Martin von Zweigbergk; +Cc: git Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes: > While walking the revision list in get_patch_ids and cmd_cherry, we > ignore merges by checking if there is more than one parent. However, > since the revision walk was initialized with revs.ignore_merges = 1, > this would never happen. Remove the unnecessary checks. > > Also re-initializing rev_info fields to the same values already set in > init_revisions(). > > Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> I think the in-loop checks were totally redundant. I suspect that explicit initialization to revs.ignore_merges outself can be called belt-and-braces defensive programming to avoid getting surprised by future changes to what init_revisions() would do, so I do not have strong preference either way. > --- > builtin/log.c | 10 ---------- > 1 file changed, 10 deletions(-) > > diff --git a/builtin/log.c b/builtin/log.c > index 7a92e3f..8182a18 100644 > --- a/builtin/log.c > +++ b/builtin/log.c > @@ -726,10 +726,6 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids) > die(_("revision walk setup failed")); > > while ((commit = get_revision(&check_rev)) != NULL) { > - /* ignore merges */ > - if (commit->parents && commit->parents->next) > - continue; > - > add_commit_patch_id(commit, ids); > } > > @@ -1509,8 +1505,6 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) > > init_revisions(&revs, prefix); > revs.diff = 1; > - revs.combine_merges = 0; > - revs.ignore_merges = 1; > DIFF_OPT_SET(&revs.diffopt, RECURSIVE); > > if (add_pending_commit(head, &revs, 0)) > @@ -1534,10 +1528,6 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) > if (prepare_revision_walk(&revs)) > die(_("revision walk setup failed")); > while ((commit = get_revision(&revs)) != NULL) { > - /* ignore merges */ > - if (commit->parents && commit->parents->next) > - continue; > - > commit_list_insert(commit, &list); > } ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] log: remove redundant check for merge commit 2012-07-27 22:30 ` Junio C Hamano @ 2012-07-28 4:52 ` Martin von Zweigbergk 2012-07-28 5:58 ` Junio C Hamano 0 siblings, 1 reply; 10+ messages in thread From: Martin von Zweigbergk @ 2012-07-28 4:52 UTC (permalink / raw) To: Junio C Hamano; +Cc: git On Fri, Jul 27, 2012 at 3:30 PM, Junio C Hamano <gitster@pobox.com> wrote: > Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes: >> Also re-initializing rev_info fields to the same values already set in >> init_revisions(). Oops, that should have been " _avoid_ re-initializing". > I suspect that > explicit initialization to revs.ignore_merges outself can be called > belt-and-braces defensive programming to avoid getting surprised by > future changes to what init_revisions() would do, so I do not have > strong preference either way. I suspected the same, but OTOH, if it was ever changed, one would have to go through all call sites anyway. I checked the other calls to init_revisions (48 of them, I think) and I found only 3 other places where a field was re-initialized to the same value. In this case it was done inconsistently even within the file. Seeing init_revisions() followed by "revs.ignore_merges = 1;" in one place but not the other can easily lead one to believe that the other place does not ignore merges. Do you want a reroll with updated commit messages (the missing "avoid" above, the dropped "seems like" about the prefix in 1/2)? Since you don't have a strong preference about the explicit initialization, I assume I can leave those hunks in. I would clarify my reasoning, though. Martin ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] log: remove redundant check for merge commit 2012-07-28 4:52 ` Martin von Zweigbergk @ 2012-07-28 5:58 ` Junio C Hamano [not found] ` <7vzk6kwf6l.fsf@alter.siamese.dyndns.org> 0 siblings, 1 reply; 10+ messages in thread From: Junio C Hamano @ 2012-07-28 5:58 UTC (permalink / raw) To: Martin von Zweigbergk; +Cc: git Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes: > Do you want a reroll with updated commit messages (the missing "avoid" > above, the dropped "seems like" about the prefix in 1/2)? Nah, I've already queued them with log message tweaks. Thanks for asking, though. ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <7vzk6kwf6l.fsf@alter.siamese.dyndns.org>]
[parent not found: <CAOeW2eG4mKTWm7PEGF_t0F9c_X1gkQaDw7HSrCiZaDte7PvOdQ@mail.gmail.com>]
* Re: [PATCH 2/2] log: remove redundant check for merge commit [not found] ` <CAOeW2eG4mKTWm7PEGF_t0F9c_X1gkQaDw7HSrCiZaDte7PvOdQ@mail.gmail.com> @ 2012-07-29 4:57 ` Martin von Zweigbergk 2012-07-29 6:24 ` Junio C Hamano 0 siblings, 1 reply; 10+ messages in thread From: Martin von Zweigbergk @ 2012-07-29 4:57 UTC (permalink / raw) To: Git; +Cc: Junio C Hamano Sorry, I meant to CC the list. See below. On Sat, Jul 28, 2012 at 9:56 PM, Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> wrote: > On Fri, Jul 27, 2012 at 11:52 PM, Junio C Hamano <gitster@pobox.com> wrote: >> Junio C Hamano <gitster@pobox.com> writes: >> >> It seems to have some interaction with your other topic, though. >> These two patches alone will pass the existing tests, but merging it >> with mz/rebase-range breaks t3412. I didn't look into it, but >> perhaps this breaks "git cherry" in some way? > > Yes, it breaks "git cherry" quite badly, by not ignoring merges at > all. I incorrectly assumed that ignore_merges was about revision > traversal, but now I think it's only diff output from 'git log' (and > possibly others). What I think tricked me was seeing that > "ignore_merges = 1" closely followed by a comment saying "ignore > merges". But now I think the explicit code to "ignore merges" is > necessary (as show by the failing test case), but can be replaced by > "rev_info.max_parents = 1". Setting "ignore_merges = 1", OTOH, now > seems doubly redundant: not only does it set the same value as was set > in init_revisions, but it's also irrelevant. Since cherry doesn't > generate any diff output, I think ignore_merges is never used. > Flipping the values of all of "ignore_merges", "combine_merges" and > "diff" does not have any effect on test cases at least. I hope my > explanation makes some sense at least... > > I'll send a reroll when I get time. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] log: remove redundant check for merge commit 2012-07-29 4:57 ` Martin von Zweigbergk @ 2012-07-29 6:24 ` Junio C Hamano 0 siblings, 0 replies; 10+ messages in thread From: Junio C Hamano @ 2012-07-29 6:24 UTC (permalink / raw) To: Martin von Zweigbergk; +Cc: Git Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes: >> I incorrectly assumed that ignore_merges was about revision >> traversal, but now I think it's only diff output from 'git log' (and >> possibly others). Yeah, I realized the same after I wrote the response last night and went to bed. I am glad you figured all out yourself. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-07-29 6:25 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-07-27 17:21 [PATCH 0/2] Small log simplifications Martin von Zweigbergk 2012-07-27 17:21 ` [PATCH 1/2] remove unnecessary parameter from get_patch_ids() Martin von Zweigbergk 2012-07-27 22:44 ` Junio C Hamano 2012-07-28 1:54 ` Martin von Zweigbergk 2012-07-27 17:21 ` [PATCH 2/2] log: remove redundant check for merge commit Martin von Zweigbergk 2012-07-27 22:30 ` Junio C Hamano 2012-07-28 4:52 ` Martin von Zweigbergk 2012-07-28 5:58 ` Junio C Hamano [not found] ` <7vzk6kwf6l.fsf@alter.siamese.dyndns.org> [not found] ` <CAOeW2eG4mKTWm7PEGF_t0F9c_X1gkQaDw7HSrCiZaDte7PvOdQ@mail.gmail.com> 2012-07-29 4:57 ` Martin von Zweigbergk 2012-07-29 6:24 ` Junio C Hamano
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).