Skip to content

Commit 35977f2

Browse files
committed
Merge branch 'lp/maint-diff-three-dash-with-graph' into maint
"log -p --graph" used with "--stat" had a few formatting error. By Lucian Poston * lp/maint-diff-three-dash-with-graph: t4202: add test for "log --graph --stat -p" separator lines log --graph: fix break in graph lines log --graph --stat: three-dash separator should come after graph lines
2 parents a4da338 + e2c5966 commit 35977f2

File tree

3 files changed

+299
-2
lines changed

3 files changed

+299
-2
lines changed

diff.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4414,6 +4414,12 @@ void diff_flush(struct diff_options *options)
44144414

44154415
if (output_format & DIFF_FORMAT_PATCH) {
44164416
if (separator) {
4417+
if (options->output_prefix) {
4418+
struct strbuf *msg = NULL;
4419+
msg = options->output_prefix(options,
4420+
options->output_prefix_data);
4421+
fwrite(msg->buf, msg->len, 1, stdout);
4422+
}
44174423
putc(options->line_termination, options->file);
44184424
if (options->stat_sep) {
44194425
/* attach patch instead of inline */

log-tree.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,14 +711,15 @@ int log_tree_diff_flush(struct rev_info *opt)
711711
opt->verbose_header &&
712712
opt->commit_format != CMIT_FMT_ONELINE) {
713713
int pch = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
714-
if ((pch & opt->diffopt.output_format) == pch)
715-
printf("---");
716714
if (opt->diffopt.output_prefix) {
717715
struct strbuf *msg = NULL;
718716
msg = opt->diffopt.output_prefix(&opt->diffopt,
719717
opt->diffopt.output_prefix_data);
720718
fwrite(msg->buf, msg->len, 1, stdout);
721719
}
720+
if ((pch & opt->diffopt.output_format) == pch) {
721+
printf("---");
722+
}
722723
putchar('\n');
723724
}
724725
}

t/t4202-log.sh

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,4 +516,294 @@ test_expect_success 'show added path under "--follow -M"' '
516516
)
517517
'
518518

519+
cat >expect <<\EOF
520+
* commit COMMIT_OBJECT_NAME
521+
|\ Merge: MERGE_PARENTS
522+
| | Author: A U Thor <[email protected]>
523+
| |
524+
| | Merge HEADS DESCRIPTION
525+
| |
526+
| * commit COMMIT_OBJECT_NAME
527+
| | Author: A U Thor <[email protected]>
528+
| |
529+
| | reach
530+
| | ---
531+
| | reach.t | 1 +
532+
| | 1 file changed, 1 insertion(+)
533+
| |
534+
| | diff --git a/reach.t b/reach.t
535+
| | new file mode 100644
536+
| | index 0000000..10c9591
537+
| | --- /dev/null
538+
| | +++ b/reach.t
539+
| | @@ -0,0 +1 @@
540+
| | +reach
541+
| |
542+
| \
543+
*-. \ commit COMMIT_OBJECT_NAME
544+
|\ \ \ Merge: MERGE_PARENTS
545+
| | | | Author: A U Thor <[email protected]>
546+
| | | |
547+
| | | | Merge HEADS DESCRIPTION
548+
| | | |
549+
| | * | commit COMMIT_OBJECT_NAME
550+
| | |/ Author: A U Thor <[email protected]>
551+
| | |
552+
| | | octopus-b
553+
| | | ---
554+
| | | octopus-b.t | 1 +
555+
| | | 1 file changed, 1 insertion(+)
556+
| | |
557+
| | | diff --git a/octopus-b.t b/octopus-b.t
558+
| | | new file mode 100644
559+
| | | index 0000000..d5fcad0
560+
| | | --- /dev/null
561+
| | | +++ b/octopus-b.t
562+
| | | @@ -0,0 +1 @@
563+
| | | +octopus-b
564+
| | |
565+
| * | commit COMMIT_OBJECT_NAME
566+
| |/ Author: A U Thor <[email protected]>
567+
| |
568+
| | octopus-a
569+
| | ---
570+
| | octopus-a.t | 1 +
571+
| | 1 file changed, 1 insertion(+)
572+
| |
573+
| | diff --git a/octopus-a.t b/octopus-a.t
574+
| | new file mode 100644
575+
| | index 0000000..11ee015
576+
| | --- /dev/null
577+
| | +++ b/octopus-a.t
578+
| | @@ -0,0 +1 @@
579+
| | +octopus-a
580+
| |
581+
* | commit COMMIT_OBJECT_NAME
582+
|/ Author: A U Thor <[email protected]>
583+
|
584+
| seventh
585+
| ---
586+
| seventh.t | 1 +
587+
| 1 file changed, 1 insertion(+)
588+
|
589+
| diff --git a/seventh.t b/seventh.t
590+
| new file mode 100644
591+
| index 0000000..9744ffc
592+
| --- /dev/null
593+
| +++ b/seventh.t
594+
| @@ -0,0 +1 @@
595+
| +seventh
596+
|
597+
* commit COMMIT_OBJECT_NAME
598+
|\ Merge: MERGE_PARENTS
599+
| | Author: A U Thor <[email protected]>
600+
| |
601+
| | Merge branch 'tangle'
602+
| |
603+
| * commit COMMIT_OBJECT_NAME
604+
| |\ Merge: MERGE_PARENTS
605+
| | | Author: A U Thor <[email protected]>
606+
| | |
607+
| | | Merge branch 'side' (early part) into tangle
608+
| | |
609+
| * | commit COMMIT_OBJECT_NAME
610+
| |\ \ Merge: MERGE_PARENTS
611+
| | | | Author: A U Thor <[email protected]>
612+
| | | |
613+
| | | | Merge branch 'master' (early part) into tangle
614+
| | | |
615+
| * | | commit COMMIT_OBJECT_NAME
616+
| | | | Author: A U Thor <[email protected]>
617+
| | | |
618+
| | | | tangle-a
619+
| | | | ---
620+
| | | | tangle-a | 1 +
621+
| | | | 1 file changed, 1 insertion(+)
622+
| | | |
623+
| | | | diff --git a/tangle-a b/tangle-a
624+
| | | | new file mode 100644
625+
| | | | index 0000000..7898192
626+
| | | | --- /dev/null
627+
| | | | +++ b/tangle-a
628+
| | | | @@ -0,0 +1 @@
629+
| | | | +a
630+
| | | |
631+
* | | | commit COMMIT_OBJECT_NAME
632+
|\ \ \ \ Merge: MERGE_PARENTS
633+
| | | | | Author: A U Thor <[email protected]>
634+
| | | | |
635+
| | | | | Merge branch 'side'
636+
| | | | |
637+
| * | | | commit COMMIT_OBJECT_NAME
638+
| | |_|/ Author: A U Thor <[email protected]>
639+
| |/| |
640+
| | | | side-2
641+
| | | | ---
642+
| | | | 2 | 1 +
643+
| | | | 1 file changed, 1 insertion(+)
644+
| | | |
645+
| | | | diff --git a/2 b/2
646+
| | | | new file mode 100644
647+
| | | | index 0000000..0cfbf08
648+
| | | | --- /dev/null
649+
| | | | +++ b/2
650+
| | | | @@ -0,0 +1 @@
651+
| | | | +2
652+
| | | |
653+
| * | | commit COMMIT_OBJECT_NAME
654+
| | | | Author: A U Thor <[email protected]>
655+
| | | |
656+
| | | | side-1
657+
| | | | ---
658+
| | | | 1 | 1 +
659+
| | | | 1 file changed, 1 insertion(+)
660+
| | | |
661+
| | | | diff --git a/1 b/1
662+
| | | | new file mode 100644
663+
| | | | index 0000000..d00491f
664+
| | | | --- /dev/null
665+
| | | | +++ b/1
666+
| | | | @@ -0,0 +1 @@
667+
| | | | +1
668+
| | | |
669+
* | | | commit COMMIT_OBJECT_NAME
670+
| | | | Author: A U Thor <[email protected]>
671+
| | | |
672+
| | | | Second
673+
| | | | ---
674+
| | | | one | 1 +
675+
| | | | 1 file changed, 1 insertion(+)
676+
| | | |
677+
| | | | diff --git a/one b/one
678+
| | | | new file mode 100644
679+
| | | | index 0000000..9a33383
680+
| | | | --- /dev/null
681+
| | | | +++ b/one
682+
| | | | @@ -0,0 +1 @@
683+
| | | | +case
684+
| | | |
685+
* | | | commit COMMIT_OBJECT_NAME
686+
| |_|/ Author: A U Thor <[email protected]>
687+
|/| |
688+
| | | sixth
689+
| | | ---
690+
| | | a/two | 1 -
691+
| | | 1 file changed, 1 deletion(-)
692+
| | |
693+
| | | diff --git a/a/two b/a/two
694+
| | | deleted file mode 100644
695+
| | | index 9245af5..0000000
696+
| | | --- a/a/two
697+
| | | +++ /dev/null
698+
| | | @@ -1 +0,0 @@
699+
| | | -ni
700+
| | |
701+
* | | commit COMMIT_OBJECT_NAME
702+
| | | Author: A U Thor <[email protected]>
703+
| | |
704+
| | | fifth
705+
| | | ---
706+
| | | a/two | 1 +
707+
| | | 1 file changed, 1 insertion(+)
708+
| | |
709+
| | | diff --git a/a/two b/a/two
710+
| | | new file mode 100644
711+
| | | index 0000000..9245af5
712+
| | | --- /dev/null
713+
| | | +++ b/a/two
714+
| | | @@ -0,0 +1 @@
715+
| | | +ni
716+
| | |
717+
* | | commit COMMIT_OBJECT_NAME
718+
|/ / Author: A U Thor <[email protected]>
719+
| |
720+
| | fourth
721+
| | ---
722+
| | ein | 1 +
723+
| | 1 file changed, 1 insertion(+)
724+
| |
725+
| | diff --git a/ein b/ein
726+
| | new file mode 100644
727+
| | index 0000000..9d7e69f
728+
| | --- /dev/null
729+
| | +++ b/ein
730+
| | @@ -0,0 +1 @@
731+
| | +ichi
732+
| |
733+
* | commit COMMIT_OBJECT_NAME
734+
|/ Author: A U Thor <[email protected]>
735+
|
736+
| third
737+
| ---
738+
| ichi | 1 +
739+
| one | 1 -
740+
| 2 files changed, 1 insertion(+), 1 deletion(-)
741+
|
742+
| diff --git a/ichi b/ichi
743+
| new file mode 100644
744+
| index 0000000..9d7e69f
745+
| --- /dev/null
746+
| +++ b/ichi
747+
| @@ -0,0 +1 @@
748+
| +ichi
749+
| diff --git a/one b/one
750+
| deleted file mode 100644
751+
| index 9d7e69f..0000000
752+
| --- a/one
753+
| +++ /dev/null
754+
| @@ -1 +0,0 @@
755+
| -ichi
756+
|
757+
* commit COMMIT_OBJECT_NAME
758+
| Author: A U Thor <[email protected]>
759+
|
760+
| second
761+
| ---
762+
| one | 2 +-
763+
| 1 file changed, 1 insertion(+), 1 deletion(-)
764+
|
765+
| diff --git a/one b/one
766+
| index 5626abf..9d7e69f 100644
767+
| --- a/one
768+
| +++ b/one
769+
| @@ -1 +1 @@
770+
| -one
771+
| +ichi
772+
|
773+
* commit COMMIT_OBJECT_NAME
774+
Author: A U Thor <[email protected]>
775+
776+
initial
777+
---
778+
one | 1 +
779+
1 file changed, 1 insertion(+)
780+
781+
diff --git a/one b/one
782+
new file mode 100644
783+
index 0000000..5626abf
784+
--- /dev/null
785+
+++ b/one
786+
@@ -0,0 +1 @@
787+
+one
788+
EOF
789+
790+
sanitize_output () {
791+
sed -e 's/ *$//' \
792+
-e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
793+
-e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
794+
-e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
795+
-e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
796+
-e 's/, 0 deletions(-)//' \
797+
-e 's/, 0 insertions(+)//' \
798+
-e 's/ 1 files changed, / 1 file changed, /' \
799+
-e 's/, 1 deletions(-)/, 1 deletion(-)/' \
800+
-e 's/, 1 insertions(+)/, 1 insertion(+)/'
801+
}
802+
803+
test_expect_success 'log --graph with diff and stats' '
804+
git log --graph --pretty=short --stat -p >actual &&
805+
sanitize_output >actual.sanitized <actual &&
806+
test_cmp expect actual.sanitized
807+
'
808+
519809
test_done

0 commit comments

Comments
 (0)