]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ds/reachable-topo-order'
authorJunio C Hamano <gitster@pobox.com>
Sun, 18 Nov 2018 09:23:52 +0000 (18:23 +0900)
committerJunio C Hamano <gitster@pobox.com>
Sun, 18 Nov 2018 09:23:52 +0000 (18:23 +0900)
The revision walker machinery learned to take advantage of the
commit generation numbers stored in the commit-graph file.

* ds/reachable-topo-order:
  t6012: make rev-list tests more interesting
  revision.c: generation-based topo-order algorithm
  commit/revisions: bookkeeping before refactoring
  revision.c: begin refactoring --topo-order logic
  test-reach: add rev-list tests
  test-reach: add run_three_modes method
  prio-queue: add 'peek' operation

1  2 
commit.c
commit.h
revision.c
revision.h
t/t6600-test-reach.sh

diff --cc commit.c
Simple merge
diff --cc commit.h
Simple merge
diff --cc revision.c
Simple merge
diff --cc revision.h
index 0d2abc2d36ec579c281135a2a3b866fb37911326,b0b3bb8025194592e75ec253a13e96ded0f747b0..7987bfcd2e9bd6ee7bac4f1cbeb10af17ab40b50
  #define SYMMETRIC_LEFT        (1u<<8)
  #define PATCHSAME     (1u<<9)
  #define BOTTOM                (1u<<10)
 -#define USER_GIVEN    (1u<<25) /* given directly by the user */
 +/*
 + * Indicates object was reached by traversal. i.e. not given by user on
 + * command-line or stdin.
 + * NEEDSWORK: NOT_USER_GIVEN doesn't apply to commits because we only support
 + * filtering trees and blobs, but it may be useful to support filtering commits
 + * in the future.
 + */
 +#define NOT_USER_GIVEN        (1u<<25)
  #define TRACK_LINEAR  (1u<<26)
 -#define ALL_REV_FLAGS (((1u<<11)-1) | USER_GIVEN | TRACK_LINEAR)
 +#define ALL_REV_FLAGS (((1u<<11)-1) | NOT_USER_GIVEN | TRACK_LINEAR)
 +
+ #define TOPO_WALK_EXPLORED    (1u<<27)
+ #define TOPO_WALK_INDEGREE    (1u<<28)
  #define DECORATE_SHORT_REFS   1
  #define DECORATE_FULL_REFS    2
  
index a0c64e617a187fd4513a9c0fa3d281e29ab14fe8,288f703b7b6c3effa06c9cbf755707f89b34dc99..b24d85003606bf2076902d944fb395bf55761d5a
@@@ -265,56 -243,88 +269,140 @@@ test_expect_success 'commit_contains:mi
        test_three_modes commit_contains --tag
  '
  
+ test_expect_success 'rev-list: basic topo-order' '
+       git rev-parse \
+               commit-6-6 commit-5-6 commit-4-6 commit-3-6 commit-2-6 commit-1-6 \
+               commit-6-5 commit-5-5 commit-4-5 commit-3-5 commit-2-5 commit-1-5 \
+               commit-6-4 commit-5-4 commit-4-4 commit-3-4 commit-2-4 commit-1-4 \
+               commit-6-3 commit-5-3 commit-4-3 commit-3-3 commit-2-3 commit-1-3 \
+               commit-6-2 commit-5-2 commit-4-2 commit-3-2 commit-2-2 commit-1-2 \
+               commit-6-1 commit-5-1 commit-4-1 commit-3-1 commit-2-1 commit-1-1 \
+       >expect &&
+       run_three_modes git rev-list --topo-order commit-6-6
+ '
+ test_expect_success 'rev-list: first-parent topo-order' '
+       git rev-parse \
+               commit-6-6 \
+               commit-6-5 \
+               commit-6-4 \
+               commit-6-3 \
+               commit-6-2 \
+               commit-6-1 commit-5-1 commit-4-1 commit-3-1 commit-2-1 commit-1-1 \
+       >expect &&
+       run_three_modes git rev-list --first-parent --topo-order commit-6-6
+ '
+ test_expect_success 'rev-list: range topo-order' '
+       git rev-parse \
+               commit-6-6 commit-5-6 commit-4-6 commit-3-6 commit-2-6 commit-1-6 \
+               commit-6-5 commit-5-5 commit-4-5 commit-3-5 commit-2-5 commit-1-5 \
+               commit-6-4 commit-5-4 commit-4-4 commit-3-4 commit-2-4 commit-1-4 \
+               commit-6-3 commit-5-3 commit-4-3 \
+               commit-6-2 commit-5-2 commit-4-2 \
+               commit-6-1 commit-5-1 commit-4-1 \
+       >expect &&
+       run_three_modes git rev-list --topo-order commit-3-3..commit-6-6
+ '
+ test_expect_success 'rev-list: range topo-order' '
+       git rev-parse \
+               commit-6-6 commit-5-6 commit-4-6 \
+               commit-6-5 commit-5-5 commit-4-5 \
+               commit-6-4 commit-5-4 commit-4-4 \
+               commit-6-3 commit-5-3 commit-4-3 \
+               commit-6-2 commit-5-2 commit-4-2 \
+               commit-6-1 commit-5-1 commit-4-1 \
+       >expect &&
+       run_three_modes git rev-list --topo-order commit-3-8..commit-6-6
+ '
+ test_expect_success 'rev-list: first-parent range topo-order' '
+       git rev-parse \
+               commit-6-6 \
+               commit-6-5 \
+               commit-6-4 \
+               commit-6-3 \
+               commit-6-2 \
+               commit-6-1 commit-5-1 commit-4-1 \
+       >expect &&
+       run_three_modes git rev-list --first-parent --topo-order commit-3-8..commit-6-6
+ '
+ test_expect_success 'rev-list: ancestry-path topo-order' '
+       git rev-parse \
+               commit-6-6 commit-5-6 commit-4-6 commit-3-6 \
+               commit-6-5 commit-5-5 commit-4-5 commit-3-5 \
+               commit-6-4 commit-5-4 commit-4-4 commit-3-4 \
+               commit-6-3 commit-5-3 commit-4-3 \
+       >expect &&
+       run_three_modes git rev-list --topo-order --ancestry-path commit-3-3..commit-6-6
+ '
+ test_expect_success 'rev-list: symmetric difference topo-order' '
+       git rev-parse \
+               commit-6-6 commit-5-6 commit-4-6 \
+               commit-6-5 commit-5-5 commit-4-5 \
+               commit-6-4 commit-5-4 commit-4-4 \
+               commit-6-3 commit-5-3 commit-4-3 \
+               commit-6-2 commit-5-2 commit-4-2 \
+               commit-6-1 commit-5-1 commit-4-1 \
+               commit-3-8 commit-2-8 commit-1-8 \
+               commit-3-7 commit-2-7 commit-1-7 \
+       >expect &&
+       run_three_modes git rev-list --topo-order commit-3-8...commit-6-6
+ '
 +test_expect_success 'get_reachable_subset:all' '
 +      cat >input <<-\EOF &&
 +      X:commit-9-1
 +      X:commit-8-3
 +      X:commit-7-5
 +      X:commit-6-6
 +      X:commit-1-7
 +      Y:commit-3-3
 +      Y:commit-1-7
 +      Y:commit-5-6
 +      EOF
 +      (
 +              echo "get_reachable_subset(X,Y)" &&
 +              git rev-parse commit-3-3 \
 +                            commit-1-7 \
 +                            commit-5-6 | sort
 +      ) >expect &&
 +      test_three_modes get_reachable_subset
 +'
 +
 +test_expect_success 'get_reachable_subset:some' '
 +      cat >input <<-\EOF &&
 +      X:commit-9-1
 +      X:commit-8-3
 +      X:commit-7-5
 +      X:commit-1-7
 +      Y:commit-3-3
 +      Y:commit-1-7
 +      Y:commit-5-6
 +      EOF
 +      (
 +              echo "get_reachable_subset(X,Y)" &&
 +              git rev-parse commit-3-3 \
 +                            commit-1-7 | sort
 +      ) >expect &&
 +      test_three_modes get_reachable_subset
 +'
 +
 +test_expect_success 'get_reachable_subset:none' '
 +      cat >input <<-\EOF &&
 +      X:commit-9-1
 +      X:commit-8-3
 +      X:commit-7-5
 +      X:commit-1-7
 +      Y:commit-9-3
 +      Y:commit-7-6
 +      Y:commit-2-8
 +      EOF
 +      echo "get_reachable_subset(X,Y)" >expect &&
 +      test_three_modes get_reachable_subset
 +'
 +
  test_done