git log -p --merge [[--] paths...]
This adds Linus's wish, "--merge" flag, which makes the above expand to a rough equivalent to: git log -p HEAD MERGE_HEAD ^$(git-merge-base HEAD MERGE_HEAD) \ -- $(git-ls-files -u [paths...] | cut -f2 | uniq) Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Jul 3, 2006 at 02:59 UTC
ae3e5e1ef2271524882d6bb7c0469f777a255315
1 file changed
+51
-2
revision.c
+51
-2
@@ -549,6 +549,49 @@ static void add_pending_commit_list(struct rev_info *revs,
549
}
550
}
551
552
+static void prepare_show_merge(struct rev_info *revs)
553
+{
554
+ struct commit_list *bases;
555
+ struct commit *head, *other;
556
+ unsigned char sha1[20];
557
+ const char **prune = NULL;
558
+ int i, prune_num = 1; /* counting terminating NULL */
559
+
560
+ if (get_sha1("HEAD", sha1) || !(head = lookup_commit(sha1)))
561
+ die("--merge without HEAD?");
562
+ if (get_sha1("MERGE_HEAD", sha1) || !(other = lookup_commit(sha1)))
563
+ die("--merge without MERGE_HEAD?");
564
+ add_pending_object(revs, &head->object, "HEAD");
565
+ add_pending_object(revs, &other->object, "MERGE_HEAD");
566
+ bases = get_merge_bases(head, other, 1);
567
+ while (bases) {
568
+ struct commit *it = bases->item;
569
+ struct commit_list *n = bases->next;
570
+ free(bases);
571
+ bases = n;
572
+ it->object.flags |= UNINTERESTING;
573
+ add_pending_object(revs, &it->object, "(merge-base)");
574
+ }
575
+
576
+ if (!active_nr)
577
+ read_cache();
578
+ for (i = 0; i < active_nr; i++) {
579
+ struct cache_entry *ce = active_cache[i];
580
+ if (!ce_stage(ce))
581
+ continue;
582
+ if (ce_path_match(ce, revs->prune_data)) {
583
+ prune_num++;
584
+ prune = xrealloc(prune, sizeof(*prune) * prune_num);
585
+ prune[prune_num-2] = ce->name;
586
+ prune[prune_num-1] = NULL;
587
+ }
588
+ while ((i+1 < active_nr) &&
589
+ ce_same_name(ce, active_cache[i+1]))
590
+ i++;
591
+ }
592
+ revs->prune_data = prune;
593
+}
594
+
595
/*
596
* Parse revision information, filling in the "rev_info" structure,
597
* and removing the used arguments from the argument list.
@@ -558,7 +601,7 @@ static void add_pending_commit_list(struct rev_info *revs,
601
*/
602
int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def)
603
{
561
- int i, flags, seen_dashdash;
604
+ int i, flags, seen_dashdash, show_merge;
605
const char **unrecognized = argv + 1;
606
int left = 1;
607
@@ -575,7 +618,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
618
break;
619
}
620
578
- flags = 0;
621
+ flags = show_merge = 0;
622
for (i = 1; i < argc; i++) {
623
struct object *object;
624
const char *arg = argv[i];
@@ -642,6 +685,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
685
def = argv[i];
686
continue;
687
}
688
+ if (!strcmp(arg, "--merge")) {
689
+ show_merge = 1;
690
+ continue;
691
+ }
692
if (!strcmp(arg, "--topo-order")) {
693
revs->topo_order = 1;
694
continue;
@@ -863,6 +910,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
910
object = get_reference(revs, arg, sha1, flags ^ local_flags);
911
add_pending_object(revs, object, arg);
912
}
913
+ if (show_merge)
914
+ prepare_show_merge(revs);
915
if (def && !revs->pending.nr) {
916
unsigned char sha1[20];
917
struct object *object;