Skip to content

Commit 695985f

Browse files
Dongcan-Jianggitster
authored andcommitted
revision: forbid combining --graph and --no-walk
Because "--graph" is about connected history while --no-walk is about discrete points, it does not make sense to allow these two options at the same time. [1] This change makes a few calls to "show --graph" fail in t4052, but asking to show one commit with graph is a nonsensical thing to do. Thus, tests on "show --graph" in t4052 have been removed [2,3]. Same tests on "show" without --graph option have already been tested in 4052. 3 testcases have been added to test this patch. [1]: http://article.gmane.org/gmane.comp.version-control.git/216083 [2]: http://article.gmane.org/gmane.comp.version-control.git/264950 [3]: http://article.gmane.org/gmane.comp.version-control.git/265107 Helped-By: Eric Sunshine <[email protected]> Helped-By: René Scharfe <[email protected]> Helped-By: Junio C Hamano <[email protected]> Signed-off-by: Dongcan Jiang <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9874fca commit 695985f

File tree

6 files changed

+23
-7
lines changed

6 files changed

+23
-7
lines changed

Documentation/rev-list-options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ These options are mostly targeted for packing of Git repositories.
673673
given on the command line. Otherwise (if `sorted` or no argument
674674
was given), the commits are shown in reverse chronological order
675675
by commit time.
676+
Cannot be combined with `--graph`.
676677

677678
--do-walk::
678679
Overrides a previous `--no-walk`.
@@ -775,6 +776,7 @@ you would get an output like this:
775776
on the left hand side of the output. This may cause extra lines
776777
to be printed in between commits, in order for the graph history
777778
to be drawn properly.
779+
Cannot be combined with `--no-walk`.
778780
+
779781
This enables parent rewriting, see 'History Simplification' below.
780782
+

revision.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,6 +2337,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
23372337

23382338
if (revs->reflog_info && revs->graph)
23392339
die("cannot combine --walk-reflogs with --graph");
2340+
if (revs->no_walk && revs->graph)
2341+
die("cannot combine --no-walk with --graph");
23402342
if (!revs->reflog_info && revs->grep_filter.use_reflog_filter)
23412343
die("cannot use --grep-reflog without --walk-reflogs");
23422344

t/t4052-stat-output.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ do
9999
test_cmp "$expect" actual
100100
'
101101

102-
test "$cmd" != diff || continue
102+
case "$cmd" in diff|show) continue;; esac
103103

104104
test_expect_success "$cmd --graph $verb COLUMNS (big change)" '
105105
COLUMNS=200 git $cmd $args --graph >output
@@ -127,7 +127,7 @@ do
127127
test_cmp "$expect" actual
128128
'
129129

130-
test "$cmd" != diff || continue
130+
case "$cmd" in diff|show) continue;; esac
131131

132132
test_expect_success "$cmd --graph $verb not enough COLUMNS (big change)" '
133133
COLUMNS=40 git $cmd $args --graph >output
@@ -155,7 +155,7 @@ do
155155
test_cmp "$expect" actual
156156
'
157157

158-
test "$cmd" != diff || continue
158+
case "$cmd" in diff|show) continue;; esac
159159

160160
test_expect_success "$cmd --graph $verb statGraphWidth config" '
161161
git -c diff.statGraphWidth=26 $cmd $args --graph >output
@@ -196,7 +196,7 @@ do
196196
test_cmp expect actual
197197
'
198198

199-
test "$cmd" != diff || continue
199+
case "$cmd" in diff|show) continue;; esac
200200

201201
test_expect_success "$cmd --stat-width=width --graph with big change" '
202202
git $cmd $args --stat-width=40 --graph >output
@@ -236,7 +236,7 @@ do
236236
test_cmp expect actual
237237
'
238238

239-
test "$cmd" != diff || continue
239+
case "$cmd" in diff|show) continue;; esac
240240

241241
test_expect_success "$cmd --stat=width --graph with big change is balanced" '
242242
git $cmd $args --stat-width=60 --graph >output &&
@@ -270,7 +270,7 @@ do
270270
test_cmp "$expect" actual
271271
'
272272

273-
test "$cmd" != diff || continue
273+
case "$cmd" in diff|show) continue;; esac
274274

275275
test_expect_success "$cmd --graph $verb COLUMNS (long filename)" '
276276
COLUMNS=200 git $cmd $args --graph >output
@@ -299,7 +299,7 @@ do
299299
test_cmp "$expect" actual
300300
'
301301

302-
test "$cmd" != diff || continue
302+
case "$cmd" in diff|show) continue;; esac
303303

304304
test_expect_success COLUMNS_CAN_BE_1 \
305305
"$cmd --graph $verb prefix greater than COLUMNS (big change)" '

t/t4202-log.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,4 +872,8 @@ test_expect_success GPG 'log --graph --show-signature for merged tag' '
872872
grep "^| | gpg: Good signature" actual
873873
'
874874

875+
test_expect_success 'log --graph --no-walk is forbidden' '
876+
test_must_fail git log --graph --no-walk
877+
'
878+
875879
test_done

t/t6014-rev-list-all.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@ test_expect_success 'repack does not lose detached HEAD' '
3535
3636
'
3737

38+
test_expect_success 'rev-list --graph --no-walk is forbidden' '
39+
test_must_fail git rev-list --graph --no-walk HEAD
40+
'
41+
3842
test_done

t/t7007-show.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,8 @@ test_expect_success '--quiet suppresses diff' '
124124
test_cmp expect actual
125125
'
126126

127+
test_expect_success 'show --graph is forbidden' '
128+
test_must_fail git show --graph HEAD
129+
'
130+
127131
test_done

0 commit comments

Comments
 (0)