File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,23 +22,41 @@ graph_git_two_modes() {
2222# NOTE: it is a bug to call this function with <directory> containing
2323# any characters in $IFS.
2424graph_git_behavior () {
25+ BARE=
26+ if test " $1 " = " --bare"
27+ then
28+ BARE=t
29+ shift
30+ fi
2531 MSG=$1
2632 DIR=$2
2733 BRANCH=$3
2834 COMPARE=$4
2935 test_expect_success " check normal git operations: $MSG " '
30- graph_git_two_modes "${DIR:+-C $DIR} log --oneline $BRANCH" &&
31- graph_git_two_modes "${DIR:+-C $DIR} log --topo-order $BRANCH" &&
32- graph_git_two_modes "${DIR:+-C $DIR} log --graph $COMPARE..$BRANCH" &&
33- graph_git_two_modes "${DIR:+-C $DIR} branch -vv" &&
34- graph_git_two_modes "${DIR:+-C $DIR} merge-base -a $BRANCH $COMPARE"
36+ if test -n "$BARE"
37+ then
38+ DIR_ARGS="${DIR:+--git-dir=$DIR}"
39+ else
40+ DIR_ARGS="${DIR:+-C $DIR}"
41+ fi &&
42+ graph_git_two_modes "$DIR_ARGS log --oneline $BRANCH" &&
43+ graph_git_two_modes "$DIR_ARGS log --topo-order $BRANCH" &&
44+ graph_git_two_modes "$DIR_ARGS log --graph $COMPARE..$BRANCH" &&
45+ graph_git_two_modes "$DIR_ARGS branch -vv" &&
46+ graph_git_two_modes "$DIR_ARGS merge-base -a $BRANCH $COMPARE"
3547 '
3648}
3749
3850graph_read_expect () {
3951 OPTIONAL=" "
4052 NUM_CHUNKS=3
4153 DIR=" ."
54+ BARE=
55+ if test " $1 " = " --bare"
56+ then
57+ BARE=t
58+ shift
59+ fi
4260 if test " $1 " = -C
4361 then
4462 shift
@@ -68,6 +86,10 @@ graph_read_expect() {
6886 EOF
6987 (
7088 cd " $DIR " &&
89+ if test -n " $BARE "
90+ then
91+ GIT_DIR=. && export GIT_DIR
92+ fi &&
7193 test-tool read-graph > output &&
7294 test_cmp expect output
7395 )
Original file line number Diff line number Diff line change @@ -274,17 +274,17 @@ test_expect_success 'setup bare repo' '
274274 git clone --bare --no-local full bare
275275'
276276
277- graph_git_behavior ' bare repo, commit 8 vs merge 1' bare commits/8 merge/1
278- graph_git_behavior ' bare repo, commit 8 vs merge 2' bare commits/8 merge/2
277+ graph_git_behavior --bare ' bare repo, commit 8 vs merge 1' bare commits/8 merge/1
278+ graph_git_behavior --bare ' bare repo, commit 8 vs merge 2' bare commits/8 merge/2
279279
280280test_expect_success ' write graph in bare repo' '
281281 git -C bare commit-graph write &&
282282 test_path_is_file bare/objects/info/commit-graph &&
283- graph_read_expect -C bare 11 "generation_data extra_edges"
283+ graph_read_expect --bare - C bare 11 "generation_data extra_edges"
284284'
285285
286- graph_git_behavior ' bare repo with graph, commit 8 vs merge 1' bare commits/8 merge/1
287- graph_git_behavior ' bare repo with graph, commit 8 vs merge 2' bare commits/8 merge/2
286+ graph_git_behavior --bare ' bare repo with graph, commit 8 vs merge 1' bare commits/8 merge/1
287+ graph_git_behavior --bare ' bare repo with graph, commit 8 vs merge 2' bare commits/8 merge/2
288288
289289test_expect_success ' perform fast-forward merge in full repo' '
290290 git -C full checkout -b merge-5-to-8 commits/5 &&
You can’t perform that action at this time.
0 commit comments