t / t6003-rev-list-topo-order.shon commit treewide: correct several "up-to-date" to "up to date" (7560f54)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Jon Seymour
   4#
   5
   6test_description='Tests git rev-list --topo-order functionality'
   7
   8. ./test-lib.sh
   9. "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions
  10
  11list_duplicates()
  12{
  13    "$@" | sort | uniq -d
  14}
  15
  16date >path0
  17git update-index --add path0
  18save_tag tree git write-tree
  19on_dates "00:00" "00:00" hide_error save_tag root unique_commit root tree
  20on_dates "00:01" "00:01" save_tag l0 unique_commit l0 tree -p root
  21on_dates "00:02" "00:02" save_tag l1 unique_commit l1 tree -p l0
  22on_dates "00:03" "00:03" save_tag l2 unique_commit l2 tree -p l1
  23on_dates "00:04" "00:04" save_tag a0 unique_commit a0 tree -p l2
  24on_dates "00:05" "00:05" save_tag a1 unique_commit a1 tree -p a0
  25on_dates "00:06" "00:06" save_tag b1 unique_commit b1 tree -p a0
  26on_dates "00:07" "00:07" save_tag c1 unique_commit c1 tree -p b1
  27on_dates "00:08" "00:08" as_author foobar@example.com save_tag b2 unique_commit b2 tree -p b1
  28on_dates "00:09" "00:09" save_tag b3 unique_commit b3 tree -p b2
  29on_dates "00:10" "00:10" save_tag c2 unique_commit c2 tree -p c1 -p b2
  30on_dates "00:11" "00:11" save_tag c3 unique_commit c3 tree -p c2
  31on_dates "00:12" "00:00" save_tag a2 unique_commit a2 tree -p a1
  32on_dates "00:13" "00:01" save_tag a3 unique_commit a3 tree -p a2
  33on_dates "00:14" "00:14" save_tag b4 unique_commit b4 tree -p b3 -p a3
  34on_dates "00:15" "00:15" save_tag a4 unique_commit a4 tree -p a3 -p b4 -p c3
  35on_dates "00:16" "00:16" save_tag l3 unique_commit l3 tree -p a4
  36on_dates "00:17" "00:17" save_tag l4 unique_commit l4 tree -p l3
  37on_dates "00:18" "00:18" save_tag l5 unique_commit l5 tree -p l4
  38on_dates "00:19" "00:19" save_tag m1 unique_commit m1 tree -p a4 -p c3
  39on_dates "00:20" "00:20" save_tag m2 unique_commit m2 tree -p c3 -p a4
  40on_dates "00:21" "00:21" hide_error save_tag alt_root unique_commit alt_root tree
  41on_dates "00:22" "00:22" save_tag r0 unique_commit r0 tree -p alt_root
  42on_dates "00:23" "00:23" save_tag r1 unique_commit r1 tree -p r0
  43on_dates "00:24" "00:24" save_tag l5r1 unique_commit l5r1 tree -p l5 -p r1
  44on_dates "00:25" "00:25" save_tag r1l5 unique_commit r1l5 tree -p r1 -p l5
  45
  46
  47hide_error save_tag e1 as_author e@example.com unique_commit e1 tree
  48save_tag e2 as_author e@example.com unique_commit e2 tree -p e1
  49save_tag f1 as_author f@example.com unique_commit f1 tree -p e1
  50save_tag e3 as_author e@example.com unique_commit e3 tree -p e2
  51save_tag f2 as_author f@example.com unique_commit f2 tree -p f1
  52save_tag e4 as_author e@example.com unique_commit e4 tree -p e3 -p f2
  53save_tag e5 as_author e@example.com unique_commit e5 tree -p e4
  54save_tag f3 as_author f@example.com unique_commit f3 tree -p f2
  55save_tag f4 as_author f@example.com unique_commit f4 tree -p f3
  56save_tag e6 as_author e@example.com unique_commit e6 tree -p e5 -p f4
  57save_tag f5 as_author f@example.com unique_commit f5 tree -p f4
  58save_tag f6 as_author f@example.com unique_commit f6 tree -p f5 -p e6
  59save_tag e7 as_author e@example.com unique_commit e7 tree -p e6
  60save_tag e8 as_author e@example.com unique_commit e8 tree -p e7
  61save_tag e9 as_author e@example.com unique_commit e9 tree -p e8
  62save_tag f7 as_author f@example.com unique_commit f7 tree -p f6
  63save_tag f8 as_author f@example.com unique_commit f8 tree -p f7
  64save_tag f9 as_author f@example.com unique_commit f9 tree -p f8
  65save_tag e10 as_author e@example.com unique_commit e1 tree -p e9 -p f8
  66
  67hide_error save_tag g0 unique_commit g0 tree
  68save_tag g1 unique_commit g1 tree -p g0
  69save_tag h1 unique_commit g2 tree -p g0
  70save_tag g2 unique_commit g3 tree -p g1 -p h1
  71save_tag h2 unique_commit g4 tree -p g2
  72save_tag g3 unique_commit g5 tree -p g2
  73save_tag g4 unique_commit g6 tree -p g3 -p h2
  74
  75git update-ref HEAD $(tag l5)
  76
  77test_output_expect_success 'rev-list has correct number of entries' 'git rev-list HEAD | wc -l | tr -d \" \"' <<EOF
  7819
  79EOF
  80
  81test_output_expect_success 'simple topo order' 'git rev-list --topo-order  HEAD' <<EOF
  82l5
  83l4
  84l3
  85a4
  86c3
  87c2
  88c1
  89b4
  90a3
  91a2
  92a1
  93b3
  94b2
  95b1
  96a0
  97l2
  98l1
  99l0
 100root
 101EOF
 102
 103test_output_expect_success 'simple date order' 'git rev-list --date-order  HEAD' <<EOF
 104l5
 105l4
 106l3
 107a4
 108b4
 109a3
 110a2
 111c3
 112c2
 113b3
 114b2
 115c1
 116b1
 117a1
 118a0
 119l2
 120l1
 121l0
 122root
 123EOF
 124
 125test_output_expect_success 'simple author-date order' 'git rev-list --author-date-order  HEAD' <<EOF
 126l5
 127l4
 128l3
 129a4
 130b4
 131c3
 132c2
 133b3
 134b2
 135c1
 136b1
 137a3
 138a2
 139a1
 140a0
 141l2
 142l1
 143l0
 144root
 145EOF
 146
 147test_output_expect_success 'two diamonds topo order (g6)' 'git rev-list --topo-order  g4' <<EOF
 148g4
 149h2
 150g3
 151g2
 152h1
 153g1
 154g0
 155EOF
 156
 157test_output_expect_success 'multiple heads' 'git rev-list --topo-order a3 b3 c3' <<EOF
 158a3
 159a2
 160a1
 161c3
 162c2
 163c1
 164b3
 165b2
 166b1
 167a0
 168l2
 169l1
 170l0
 171root
 172EOF
 173
 174test_output_expect_success 'multiple heads, prune at a1' 'git rev-list --topo-order a3 b3 c3 ^a1' <<EOF
 175a3
 176a2
 177c3
 178c2
 179c1
 180b3
 181b2
 182b1
 183EOF
 184
 185test_output_expect_success 'multiple heads, prune at l1' 'git rev-list --topo-order a3 b3 c3 ^l1' <<EOF
 186a3
 187a2
 188a1
 189c3
 190c2
 191c1
 192b3
 193b2
 194b1
 195a0
 196l2
 197EOF
 198
 199test_output_expect_success 'cross-epoch, head at l5, prune at l1' 'git rev-list --topo-order l5 ^l1' <<EOF
 200l5
 201l4
 202l3
 203a4
 204c3
 205c2
 206c1
 207b4
 208a3
 209a2
 210a1
 211b3
 212b2
 213b1
 214a0
 215l2
 216EOF
 217
 218test_output_expect_success 'duplicated head arguments' 'git rev-list --topo-order l5 l5 ^l1' <<EOF
 219l5
 220l4
 221l3
 222a4
 223c3
 224c2
 225c1
 226b4
 227a3
 228a2
 229a1
 230b3
 231b2
 232b1
 233a0
 234l2
 235EOF
 236
 237test_output_expect_success 'prune near topo' 'git rev-list --topo-order a4 ^c3' <<EOF
 238a4
 239b4
 240a3
 241a2
 242a1
 243b3
 244EOF
 245
 246test_output_expect_success "head has no parent" 'git rev-list --topo-order  root' <<EOF
 247root
 248EOF
 249
 250test_output_expect_success "two nodes - one head, one base" 'git rev-list --topo-order  l0' <<EOF
 251l0
 252root
 253EOF
 254
 255test_output_expect_success "three nodes one head, one internal, one base" 'git rev-list --topo-order  l1' <<EOF
 256l1
 257l0
 258root
 259EOF
 260
 261test_output_expect_success "linear prune l2 ^root" 'git rev-list --topo-order  l2 ^root' <<EOF
 262l2
 263l1
 264l0
 265EOF
 266
 267test_output_expect_success "linear prune l2 ^l0" 'git rev-list --topo-order  l2 ^l0' <<EOF
 268l2
 269l1
 270EOF
 271
 272test_output_expect_success "linear prune l2 ^l1" 'git rev-list --topo-order  l2 ^l1' <<EOF
 273l2
 274EOF
 275
 276test_output_expect_success "linear prune l5 ^a4" 'git rev-list --topo-order  l5 ^a4' <<EOF
 277l5
 278l4
 279l3
 280EOF
 281
 282test_output_expect_success "linear prune l5 ^l3" 'git rev-list --topo-order  l5 ^l3' <<EOF
 283l5
 284l4
 285EOF
 286
 287test_output_expect_success "linear prune l5 ^l4" 'git rev-list --topo-order  l5 ^l4' <<EOF
 288l5
 289EOF
 290
 291test_output_expect_success "max-count 10 - topo order" 'git rev-list --topo-order  --max-count=10 l5' <<EOF
 292l5
 293l4
 294l3
 295a4
 296c3
 297c2
 298c1
 299b4
 300a3
 301a2
 302EOF
 303
 304test_output_expect_success "max-count 10 - non topo order" 'git rev-list --max-count=10 l5' <<EOF
 305l5
 306l4
 307l3
 308a4
 309b4
 310a3
 311a2
 312c3
 313c2
 314b3
 315EOF
 316
 317test_output_expect_success '--max-age=c3, no --topo-order' "git rev-list --max-age=$(commit_date c3) l5" <<EOF
 318l5
 319l4
 320l3
 321a4
 322b4
 323a3
 324a2
 325c3
 326EOF
 327
 328#
 329# this test fails on --topo-order - a fix is required
 330#
 331#test_output_expect_success '--max-age=c3, --topo-order' "git rev-list --topo-order --max-age=$(commit_date c3) l5" <<EOF
 332#l5
 333#l4
 334#l3
 335#a4
 336#c3
 337#b4
 338#a3
 339#a2
 340#EOF
 341
 342test_output_expect_success 'one specified head reachable from another a4, c3, --topo-order' "list_duplicates git rev-list --topo-order a4 c3" <<EOF
 343EOF
 344
 345test_output_expect_success 'one specified head reachable from another c3, a4, --topo-order' "list_duplicates git rev-list --topo-order c3 a4" <<EOF
 346EOF
 347
 348test_output_expect_success 'one specified head reachable from another a4, c3, no --topo-order' "list_duplicates git rev-list a4 c3" <<EOF
 349EOF
 350
 351test_output_expect_success 'one specified head reachable from another c3, a4, no --topo-order' "list_duplicates git rev-list c3 a4" <<EOF
 352EOF
 353
 354test_output_expect_success 'graph with c3 and a4 parents of head' "list_duplicates git rev-list m1" <<EOF
 355EOF
 356
 357test_output_expect_success 'graph with a4 and c3 parents of head' "list_duplicates git rev-list m2" <<EOF
 358EOF
 359
 360test_expect_success "head ^head --topo-order" 'git rev-list --topo-order  a3 ^a3' <<EOF
 361EOF
 362
 363test_expect_success "head ^head no --topo-order" 'git rev-list a3 ^a3' <<EOF
 364EOF
 365
 366test_output_expect_success 'simple topo order (l5r1)' 'git rev-list --topo-order  l5r1' <<EOF
 367l5r1
 368r1
 369r0
 370alt_root
 371l5
 372l4
 373l3
 374a4
 375c3
 376c2
 377c1
 378b4
 379a3
 380a2
 381a1
 382b3
 383b2
 384b1
 385a0
 386l2
 387l1
 388l0
 389root
 390EOF
 391
 392test_output_expect_success 'simple topo order (r1l5)' 'git rev-list --topo-order  r1l5' <<EOF
 393r1l5
 394l5
 395l4
 396l3
 397a4
 398c3
 399c2
 400c1
 401b4
 402a3
 403a2
 404a1
 405b3
 406b2
 407b1
 408a0
 409l2
 410l1
 411l0
 412root
 413r1
 414r0
 415alt_root
 416EOF
 417
 418test_output_expect_success "don't print things unreachable from one branch" "git rev-list a3 ^b3 --topo-order" <<EOF
 419a3
 420a2
 421a1
 422EOF
 423
 424test_output_expect_success "--topo-order a4 l3" "git rev-list --topo-order a4 l3" <<EOF
 425l3
 426a4
 427c3
 428c2
 429c1
 430b4
 431a3
 432a2
 433a1
 434b3
 435b2
 436b1
 437a0
 438l2
 439l1
 440l0
 441root
 442EOF
 443
 444#
 445#
 446
 447test_done