* [PATCH] log --children
@ 2011-10-04 14:02 Jay Soffian
2011-10-04 20:12 ` Michael J Gruber
0 siblings, 1 reply; 6+ messages in thread
From: Jay Soffian @ 2011-10-04 14:02 UTC (permalink / raw)
To: git; +Cc: Jay Soffian, Junio C Hamano
Teach git-log to support --children, which was added by f35f5603f4
to the revision machinery, and by 72276a3ecb to rev-list, but
was never added to git-log.
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
log-tree.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/log-tree.c b/log-tree.c
index 24c295ea1d..e7694a3a4c 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -165,6 +165,14 @@ static void show_parents(struct commit *commit, int abbrev)
}
}
+static void show_children(struct rev_info *opt, struct commit *commit, int abbrev)
+{
+ struct commit_list *p = lookup_decoration(&opt->children, &commit->object);
+ for ( ; p; p = p->next) {
+ printf(" %s", find_unique_abbrev(p->item->object.sha1, abbrev));
+ }
+}
+
void show_decorations(struct rev_info *opt, struct commit *commit)
{
const char *prefix;
@@ -414,6 +422,8 @@ void show_log(struct rev_info *opt)
fputs(find_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
if (opt->print_parents)
show_parents(commit, abbrev_commit);
+ if (opt->children.name)
+ show_children(opt, commit, abbrev_commit);
show_decorations(opt, commit);
if (opt->graph && !graph_is_commit_finished(opt->graph)) {
putchar('\n');
@@ -473,6 +483,8 @@ void show_log(struct rev_info *opt)
stdout);
if (opt->print_parents)
show_parents(commit, abbrev_commit);
+ if (opt->children.name)
+ show_children(opt, commit, abbrev_commit);
if (parent)
printf(" (from %s)",
find_unique_abbrev(parent->object.sha1,
--
1.7.7.3.gaf8e
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] log --children
2011-10-04 14:02 [PATCH] log --children Jay Soffian
@ 2011-10-04 20:12 ` Michael J Gruber
2011-10-04 20:21 ` Junio C Hamano
2011-10-04 20:45 ` [PATCH v2] " Jay Soffian
0 siblings, 2 replies; 6+ messages in thread
From: Michael J Gruber @ 2011-10-04 20:12 UTC (permalink / raw)
To: Jay Soffian; +Cc: git, Junio C Hamano
Jay Soffian venit, vidit, dixit 04.10.2011 16:02:
> Teach git-log to support --children, which was added by f35f5603f4
> to the revision machinery, and by 72276a3ecb to rev-list, but
> was never added to git-log.
>
> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
> ---
> log-tree.c | 12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/log-tree.c b/log-tree.c
> index 24c295ea1d..e7694a3a4c 100644
> --- a/log-tree.c
> +++ b/log-tree.c
> @@ -165,6 +165,14 @@ static void show_parents(struct commit *commit, int abbrev)
> }
> }
>
> +static void show_children(struct rev_info *opt, struct commit *commit, int abbrev)
> +{
> + struct commit_list *p = lookup_decoration(&opt->children, &commit->object);
> + for ( ; p; p = p->next) {
> + printf(" %s", find_unique_abbrev(p->item->object.sha1, abbrev));
> + }
> +}
> +
> void show_decorations(struct rev_info *opt, struct commit *commit)
> {
> const char *prefix;
> @@ -414,6 +422,8 @@ void show_log(struct rev_info *opt)
> fputs(find_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
> if (opt->print_parents)
> show_parents(commit, abbrev_commit);
> + if (opt->children.name)
> + show_children(opt, commit, abbrev_commit);
That means that "log --children --parents" will print out the parents'
sha1s, then the children's. Is that a good default format, or should we
somehow deal with the case when both are specified?
> show_decorations(opt, commit);
> if (opt->graph && !graph_is_commit_finished(opt->graph)) {
> putchar('\n');
> @@ -473,6 +483,8 @@ void show_log(struct rev_info *opt)
> stdout);
> if (opt->print_parents)
> show_parents(commit, abbrev_commit);
> + if (opt->children.name)
> + show_children(opt, commit, abbrev_commit);
> if (parent)
> printf(" (from %s)",
> find_unique_abbrev(parent->object.sha1,
And I guess we would like to test this...
Michael
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] log --children
2011-10-04 20:12 ` Michael J Gruber
@ 2011-10-04 20:21 ` Junio C Hamano
2011-10-04 20:27 ` Michael J Gruber
2011-10-04 20:45 ` [PATCH v2] " Jay Soffian
1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2011-10-04 20:21 UTC (permalink / raw)
To: Michael J Gruber; +Cc: Jay Soffian, git
Michael J Gruber <git@drmicha.warpmail.net> writes:
>> @@ -414,6 +422,8 @@ void show_log(struct rev_info *opt)
>> fputs(find_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
>> if (opt->print_parents)
>> show_parents(commit, abbrev_commit);
>> + if (opt->children.name)
>> + show_children(opt, commit, abbrev_commit);
>
> That means that "log --children --parents" will print out the parents'
> sha1s, then the children's. Is that a good default format, or should we
> somehow deal with the case when both are specified?
I think these two options are muturally exclusive, not because of the
"mixed output getting confusing" reasons but because of traversal reasons.
IIRC, when parent rewriting is in effect, you cannot just say "a commit
that has these commits on its parents list is a child of these commits",
as you have to orphan and adopt it as a child of ancestor commits, which
the code introduced in f35f5603 does not do.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] log --children
2011-10-04 20:21 ` Junio C Hamano
@ 2011-10-04 20:27 ` Michael J Gruber
0 siblings, 0 replies; 6+ messages in thread
From: Michael J Gruber @ 2011-10-04 20:27 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jay Soffian, git
Junio C Hamano venit, vidit, dixit 04.10.2011 22:21:
> Michael J Gruber <git@drmicha.warpmail.net> writes:
>
>>> @@ -414,6 +422,8 @@ void show_log(struct rev_info *opt)
>>> fputs(find_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
>>> if (opt->print_parents)
>>> show_parents(commit, abbrev_commit);
>>> + if (opt->children.name)
>>> + show_children(opt, commit, abbrev_commit);
>>
>> That means that "log --children --parents" will print out the parents'
>> sha1s, then the children's. Is that a good default format, or should we
>> somehow deal with the case when both are specified?
>
> I think these two options are muturally exclusive, not because of the
> "mixed output getting confusing" reasons but because of traversal reasons.
> IIRC, when parent rewriting is in effect, you cannot just say "a commit
> that has these commits on its parents list is a child of these commits",
> as you have to orphan and adopt it as a child of ancestor commits, which
> the code introduced in f35f5603 does not do.
>
I didn't think --parents would switch on rewriting, but I guess all is good:
git rev-list -5 --parents --children origin/next
fatal: cannot combine --parents and --children
Should be the same for log.
Michael
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] log --children
2011-10-04 20:12 ` Michael J Gruber
2011-10-04 20:21 ` Junio C Hamano
@ 2011-10-04 20:45 ` Jay Soffian
2011-10-04 20:51 ` Michael J Gruber
1 sibling, 1 reply; 6+ messages in thread
From: Jay Soffian @ 2011-10-04 20:45 UTC (permalink / raw)
To: git; +Cc: Jay Soffian, Junio C Hamano, Michael J Gruber
Teach git-log to support --children, which was added by f35f5603f4
to the revision machinery, and by 72276a3ecb to rev-list, but
was never added to git-log.
Also add tests for 'log --children' and 'log --parents'.
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
On Tue, Oct 4, 2011 at 4:12 PM, Michael J Gruber <git@drmicha.warpmail.net> wrote:
> That means that "log --children --parents" will print out the parents'
> sha1s, then the children's. Is that a good default format, or should we
> somehow deal with the case when both are specified?
They are mutually exclusive:
$ git log --parents --children
fatal: cannot combine --parents and --children
> And I guess we would like to test this...
Good idea. :-)
j.
log-tree.c | 12 ++++++++++++
t/t4013-diff-various.sh | 2 ++
t/t4013/diff.log_--children | 34 ++++++++++++++++++++++++++++++++++
t/t4013/diff.log_--parents | 34 ++++++++++++++++++++++++++++++++++
4 files changed, 82 insertions(+), 0 deletions(-)
create mode 100644 t/t4013/diff.log_--children
create mode 100644 t/t4013/diff.log_--parents
diff --git a/log-tree.c b/log-tree.c
index 24c295ea1d..e7694a3a4c 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -165,6 +165,14 @@ static void show_parents(struct commit *commit, int abbrev)
}
}
+static void show_children(struct rev_info *opt, struct commit *commit, int abbrev)
+{
+ struct commit_list *p = lookup_decoration(&opt->children, &commit->object);
+ for ( ; p; p = p->next) {
+ printf(" %s", find_unique_abbrev(p->item->object.sha1, abbrev));
+ }
+}
+
void show_decorations(struct rev_info *opt, struct commit *commit)
{
const char *prefix;
@@ -414,6 +422,8 @@ void show_log(struct rev_info *opt)
fputs(find_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
if (opt->print_parents)
show_parents(commit, abbrev_commit);
+ if (opt->children.name)
+ show_children(opt, commit, abbrev_commit);
show_decorations(opt, commit);
if (opt->graph && !graph_is_commit_finished(opt->graph)) {
putchar('\n');
@@ -473,6 +483,8 @@ void show_log(struct rev_info *opt)
stdout);
if (opt->print_parents)
show_parents(commit, abbrev_commit);
+ if (opt->children.name)
+ show_children(opt, commit, abbrev_commit);
if (parent)
printf(" (from %s)",
find_unique_abbrev(parent->object.sha1,
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index 93a6f20871..a488325e2c 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -231,6 +231,8 @@ log -GF -p master
log -GF -p --pickaxe-all master
log --decorate --all
log --decorate=full --all
+log --parents
+log --children
rev-list --parents HEAD
rev-list --children HEAD
diff --git a/t/t4013/diff.log_--children b/t/t4013/diff.log_--children
new file mode 100644
index 0000000000..bb8ed432cf
--- /dev/null
+++ b/t/t4013/diff.log_--children
@@ -0,0 +1,34 @@
+$ git log --children
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:04:00 2006 +0000
+
+ Merge branch 'side'
+
+commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a 59d314ad6f356dd08601a4cd5e530381da3e3c64
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:03:00 2006 +0000
+
+ Side
+
+commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 59d314ad6f356dd08601a4cd5e530381da3e3c64
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:02:00 2006 +0000
+
+ Third
+
+commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:01:00 2006 +0000
+
+ Second
+
+ This is the second commit.
+
+commit 444ac553ac7612cc88969031b02b3767fb8a353a 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:00:00 2006 +0000
+
+ Initial
+$
diff --git a/t/t4013/diff.log_--parents b/t/t4013/diff.log_--parents
new file mode 100644
index 0000000000..bc4d44ff1f
--- /dev/null
+++ b/t/t4013/diff.log_--parents
@@ -0,0 +1,34 @@
+$ git log --parents
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
+Merge: 9a6d494 c7a2ab9
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:04:00 2006 +0000
+
+ Merge branch 'side'
+
+commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a 444ac553ac7612cc88969031b02b3767fb8a353a
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:03:00 2006 +0000
+
+ Side
+
+commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:02:00 2006 +0000
+
+ Third
+
+commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 444ac553ac7612cc88969031b02b3767fb8a353a
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:01:00 2006 +0000
+
+ Second
+
+ This is the second commit.
+
+commit 444ac553ac7612cc88969031b02b3767fb8a353a
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:00:00 2006 +0000
+
+ Initial
+$
--
1.7.7.3.gaf8e
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] log --children
2011-10-04 20:45 ` [PATCH v2] " Jay Soffian
@ 2011-10-04 20:51 ` Michael J Gruber
0 siblings, 0 replies; 6+ messages in thread
From: Michael J Gruber @ 2011-10-04 20:51 UTC (permalink / raw)
To: Jay Soffian; +Cc: git, Junio C Hamano
Jay Soffian venit, vidit, dixit 04.10.2011 22:45:
> Teach git-log to support --children, which was added by f35f5603f4
> to the revision machinery, and by 72276a3ecb to rev-list, but
> was never added to git-log.
>
> Also add tests for 'log --children' and 'log --parents'.
>
> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
> ---
> On Tue, Oct 4, 2011 at 4:12 PM, Michael J Gruber <git@drmicha.warpmail.net> wrote:
>> That means that "log --children --parents" will print out the parents'
>> sha1s, then the children's. Is that a good default format, or should we
>> somehow deal with the case when both are specified?
>
> They are mutually exclusive:
>
> $ git log --parents --children
> fatal: cannot combine --parents and --children
>
>> And I guess we would like to test this...
>
> Good idea. :-)
>
Thanks ;)
Looks good to me.
Michael
> j.
>
> log-tree.c | 12 ++++++++++++
> t/t4013-diff-various.sh | 2 ++
> t/t4013/diff.log_--children | 34 ++++++++++++++++++++++++++++++++++
> t/t4013/diff.log_--parents | 34 ++++++++++++++++++++++++++++++++++
> 4 files changed, 82 insertions(+), 0 deletions(-)
> create mode 100644 t/t4013/diff.log_--children
> create mode 100644 t/t4013/diff.log_--parents
>
> diff --git a/log-tree.c b/log-tree.c
> index 24c295ea1d..e7694a3a4c 100644
> --- a/log-tree.c
> +++ b/log-tree.c
> @@ -165,6 +165,14 @@ static void show_parents(struct commit *commit, int abbrev)
> }
> }
>
> +static void show_children(struct rev_info *opt, struct commit *commit, int abbrev)
> +{
> + struct commit_list *p = lookup_decoration(&opt->children, &commit->object);
> + for ( ; p; p = p->next) {
> + printf(" %s", find_unique_abbrev(p->item->object.sha1, abbrev));
> + }
> +}
> +
> void show_decorations(struct rev_info *opt, struct commit *commit)
> {
> const char *prefix;
> @@ -414,6 +422,8 @@ void show_log(struct rev_info *opt)
> fputs(find_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
> if (opt->print_parents)
> show_parents(commit, abbrev_commit);
> + if (opt->children.name)
> + show_children(opt, commit, abbrev_commit);
> show_decorations(opt, commit);
> if (opt->graph && !graph_is_commit_finished(opt->graph)) {
> putchar('\n');
> @@ -473,6 +483,8 @@ void show_log(struct rev_info *opt)
> stdout);
> if (opt->print_parents)
> show_parents(commit, abbrev_commit);
> + if (opt->children.name)
> + show_children(opt, commit, abbrev_commit);
> if (parent)
> printf(" (from %s)",
> find_unique_abbrev(parent->object.sha1,
> diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
> index 93a6f20871..a488325e2c 100755
> --- a/t/t4013-diff-various.sh
> +++ b/t/t4013-diff-various.sh
> @@ -231,6 +231,8 @@ log -GF -p master
> log -GF -p --pickaxe-all master
> log --decorate --all
> log --decorate=full --all
> +log --parents
> +log --children
>
> rev-list --parents HEAD
> rev-list --children HEAD
> diff --git a/t/t4013/diff.log_--children b/t/t4013/diff.log_--children
> new file mode 100644
> index 0000000000..bb8ed432cf
> --- /dev/null
> +++ b/t/t4013/diff.log_--children
> @@ -0,0 +1,34 @@
> +$ git log --children
> +commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
> +Merge: 9a6d494 c7a2ab9
> +Author: A U Thor <author@example.com>
> +Date: Mon Jun 26 00:04:00 2006 +0000
> +
> + Merge branch 'side'
> +
> +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a 59d314ad6f356dd08601a4cd5e530381da3e3c64
> +Author: A U Thor <author@example.com>
> +Date: Mon Jun 26 00:03:00 2006 +0000
> +
> + Side
> +
> +commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 59d314ad6f356dd08601a4cd5e530381da3e3c64
> +Author: A U Thor <author@example.com>
> +Date: Mon Jun 26 00:02:00 2006 +0000
> +
> + Third
> +
> +commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
> +Author: A U Thor <author@example.com>
> +Date: Mon Jun 26 00:01:00 2006 +0000
> +
> + Second
> +
> + This is the second commit.
> +
> +commit 444ac553ac7612cc88969031b02b3767fb8a353a 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
> +Author: A U Thor <author@example.com>
> +Date: Mon Jun 26 00:00:00 2006 +0000
> +
> + Initial
> +$
> diff --git a/t/t4013/diff.log_--parents b/t/t4013/diff.log_--parents
> new file mode 100644
> index 0000000000..bc4d44ff1f
> --- /dev/null
> +++ b/t/t4013/diff.log_--parents
> @@ -0,0 +1,34 @@
> +$ git log --parents
> +commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
> +Merge: 9a6d494 c7a2ab9
> +Author: A U Thor <author@example.com>
> +Date: Mon Jun 26 00:04:00 2006 +0000
> +
> + Merge branch 'side'
> +
> +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a 444ac553ac7612cc88969031b02b3767fb8a353a
> +Author: A U Thor <author@example.com>
> +Date: Mon Jun 26 00:03:00 2006 +0000
> +
> + Side
> +
> +commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44
> +Author: A U Thor <author@example.com>
> +Date: Mon Jun 26 00:02:00 2006 +0000
> +
> + Third
> +
> +commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 444ac553ac7612cc88969031b02b3767fb8a353a
> +Author: A U Thor <author@example.com>
> +Date: Mon Jun 26 00:01:00 2006 +0000
> +
> + Second
> +
> + This is the second commit.
> +
> +commit 444ac553ac7612cc88969031b02b3767fb8a353a
> +Author: A U Thor <author@example.com>
> +Date: Mon Jun 26 00:00:00 2006 +0000
> +
> + Initial
> +$
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-10-04 20:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-04 14:02 [PATCH] log --children Jay Soffian
2011-10-04 20:12 ` Michael J Gruber
2011-10-04 20:21 ` Junio C Hamano
2011-10-04 20:27 ` Michael J Gruber
2011-10-04 20:45 ` [PATCH v2] " Jay Soffian
2011-10-04 20:51 ` Michael J Gruber
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).