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 <sunshine@sunshineco.com> Helped-By: René Scharfe <l.s.r@web.de> Helped-By: Junio C Hamano <gitster@pobox.com> Signed-off-by: Dongcan Jiang <dongcan.jiang@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Dongcan Jiang committed Mar 11, 2015 at 10:13 UTC 695985f4837e7299dca10b5e45206dbd2c52c1e0
6 files changed +23 -7
Documentation/rev-list-options.txt
+2
@@ -673,6 +673,7 @@ These options are mostly targeted for packing of Git repositories.
673 given on the command line. Otherwise (if `sorted` or no argument
674 was given), the commits are shown in reverse chronological order
675 by commit time.
676 + Cannot be combined with `--graph`.
677
678 --do-walk::
679 Overrides a previous `--no-walk`.
@@ -775,6 +776,7 @@ you would get an output like this:
776 on the left hand side of the output. This may cause extra lines
777 to be printed in between commits, in order for the graph history
778 to be drawn properly.
779 + Cannot be combined with `--no-walk`.
780 +
781 This enables parent rewriting, see 'History Simplification' below.
782 +
revision.c
+2
@@ -2337,6 +2337,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2337
2338 if (revs->reflog_info && revs->graph)
2339 die("cannot combine --walk-reflogs with --graph");
2340 + if (revs->no_walk && revs->graph)
2341 + die("cannot combine --no-walk with --graph");
2342 if (!revs->reflog_info && revs->grep_filter.use_reflog_filter)
2343 die("cannot use --grep-reflog without --walk-reflogs");
2344
t/t4052-stat-output.sh
+7 -7
@@ -99,7 +99,7 @@ do
99 test_cmp "$expect" actual
100 '
101
102 - test "$cmd" != diff || continue
102 + case "$cmd" in diff|show) continue;; esac
103
104 test_expect_success "$cmd --graph $verb COLUMNS (big change)" '
105 COLUMNS=200 git $cmd $args --graph >output
@@ -127,7 +127,7 @@ do
127 test_cmp "$expect" actual
128 '
129
130 - test "$cmd" != diff || continue
130 + case "$cmd" in diff|show) continue;; esac
131
132 test_expect_success "$cmd --graph $verb not enough COLUMNS (big change)" '
133 COLUMNS=40 git $cmd $args --graph >output
@@ -155,7 +155,7 @@ do
155 test_cmp "$expect" actual
156 '
157
158 - test "$cmd" != diff || continue
158 + case "$cmd" in diff|show) continue;; esac
159
160 test_expect_success "$cmd --graph $verb statGraphWidth config" '
161 git -c diff.statGraphWidth=26 $cmd $args --graph >output
@@ -196,7 +196,7 @@ do
196 test_cmp expect actual
197 '
198
199 - test "$cmd" != diff || continue
199 + case "$cmd" in diff|show) continue;; esac
200
201 test_expect_success "$cmd --stat-width=width --graph with big change" '
202 git $cmd $args --stat-width=40 --graph >output
@@ -236,7 +236,7 @@ do
236 test_cmp expect actual
237 '
238
239 - test "$cmd" != diff || continue
239 + case "$cmd" in diff|show) continue;; esac
240
241 test_expect_success "$cmd --stat=width --graph with big change is balanced" '
242 git $cmd $args --stat-width=60 --graph >output &&
@@ -270,7 +270,7 @@ do
270 test_cmp "$expect" actual
271 '
272
273 - test "$cmd" != diff || continue
273 + case "$cmd" in diff|show) continue;; esac
274
275 test_expect_success "$cmd --graph $verb COLUMNS (long filename)" '
276 COLUMNS=200 git $cmd $args --graph >output
@@ -299,7 +299,7 @@ do
299 test_cmp "$expect" actual
300 '
301
302 - test "$cmd" != diff || continue
302 + case "$cmd" in diff|show) continue;; esac
303
304 test_expect_success COLUMNS_CAN_BE_1 \
305 "$cmd --graph $verb prefix greater than COLUMNS (big change)" '
t/t4202-log.sh
+4
@@ -872,4 +872,8 @@ test_expect_success GPG 'log --graph --show-signature for merged tag' '
872 grep "^| | gpg: Good signature" actual
873 '
874
875 +test_expect_success 'log --graph --no-walk is forbidden' '
876 + test_must_fail git log --graph --no-walk
877 +'
878 +
879 test_done
t/t6014-rev-list-all.sh
+4
@@ -35,4 +35,8 @@ test_expect_success 'repack does not lose detached HEAD' '
35
36 '
37
38 +test_expect_success 'rev-list --graph --no-walk is forbidden' '
39 + test_must_fail git rev-list --graph --no-walk HEAD
40 +'
41 +
42 test_done
t/t7007-show.sh
+4
@@ -124,4 +124,8 @@ test_expect_success '--quiet suppresses diff' '
124 test_cmp expect actual
125 '
126
127 +test_expect_success 'show --graph is forbidden' '
128 + test_must_fail git show --graph HEAD
129 +'
130 +
131 test_done