@@ -1420,44 +1420,59 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
1420
1420
}
1421
1421
if (!get_sha1_committish (this , from_sha1 ) &&
1422
1422
!get_sha1_committish (next , sha1 )) {
1423
- struct commit * a , * b ;
1424
- struct commit_list * exclude ;
1425
-
1426
- a = lookup_commit_reference (from_sha1 );
1427
- b = lookup_commit_reference (sha1 );
1428
- if (!a || !b ) {
1429
- if (revs -> ignore_missing )
1430
- return 0 ;
1431
- die (symmetric ?
1432
- "Invalid symmetric difference expression %s...%s" :
1433
- "Invalid revision range %s..%s" ,
1434
- arg , next );
1435
- }
1423
+ struct object * a_obj , * b_obj ;
1436
1424
1437
1425
if (!cant_be_filename ) {
1438
1426
* dotdot = '.' ;
1439
1427
verify_non_filename (revs -> prefix , arg );
1440
1428
}
1441
1429
1442
- if (symmetric ) {
1430
+ a_obj = parse_object (from_sha1 );
1431
+ b_obj = parse_object (sha1 );
1432
+ if (!a_obj || !b_obj ) {
1433
+ missing :
1434
+ if (revs -> ignore_missing )
1435
+ return 0 ;
1436
+ die (symmetric
1437
+ ? "Invalid symmetric difference expression %s"
1438
+ : "Invalid revision range %s" , arg );
1439
+ }
1440
+
1441
+ if (!symmetric ) {
1442
+ /* just A..B */
1443
+ a_flags = flags_exclude ;
1444
+ } else {
1445
+ /* A...B -- find merge bases between the two */
1446
+ struct commit * a , * b ;
1447
+ struct commit_list * exclude ;
1448
+
1449
+ a = (a_obj -> type == OBJ_COMMIT
1450
+ ? (struct commit * )a_obj
1451
+ : lookup_commit_reference (a_obj -> sha1 ));
1452
+ b = (b_obj -> type == OBJ_COMMIT
1453
+ ? (struct commit * )b_obj
1454
+ : lookup_commit_reference (b_obj -> sha1 ));
1455
+ if (!a || !b )
1456
+ goto missing ;
1443
1457
exclude = get_merge_bases (a , b , 1 );
1444
1458
add_rev_cmdline_list (revs , exclude ,
1445
1459
REV_CMD_MERGE_BASE ,
1446
1460
flags_exclude );
1447
1461
add_pending_commit_list (revs , exclude ,
1448
1462
flags_exclude );
1449
1463
free_commit_list (exclude );
1464
+
1450
1465
a_flags = flags | SYMMETRIC_LEFT ;
1451
- } else
1452
- a_flags = flags_exclude ;
1453
- a -> object . flags |= a_flags ;
1454
- b -> object . flags |= flags ;
1455
- add_rev_cmdline (revs , & a -> object , this ,
1466
+ }
1467
+
1468
+ a_obj -> flags |= a_flags ;
1469
+ b_obj -> flags |= flags ;
1470
+ add_rev_cmdline (revs , a_obj , this ,
1456
1471
REV_CMD_LEFT , a_flags );
1457
- add_rev_cmdline (revs , & b -> object , next ,
1472
+ add_rev_cmdline (revs , b_obj , next ,
1458
1473
REV_CMD_RIGHT , flags );
1459
- add_pending_object (revs , & a -> object , this );
1460
- add_pending_object (revs , & b -> object , next );
1474
+ add_pending_object (revs , a_obj , this );
1475
+ add_pending_object (revs , b_obj , next );
1461
1476
return 0 ;
1462
1477
}
1463
1478
* dotdot = '.' ;
0 commit comments