Skip to content

Commit

Permalink
diff: accept -- when using --no-index
Browse files Browse the repository at this point in the history
Accept -- as an "end of options" marker even when using --no-index.
Previously, the -- triggered a "normal" index/tree diff and subsequently
failed because of the unrecognized (in that mode) --no-index.

Note that the second loop can treat '--' as a normal option, because
the preceding checks ensure it is the third-to-last argument.

While at it, fix the parsing of "-q" option in --no-index mode as well.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Thomas Rast authored and Junio C Hamano committed Jan 7, 2009
1 parent a567fdc commit e423ffd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions diff-no-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ void diff_no_index(struct rev_info *revs,

/* Were we asked to do --no-index explicitly? */
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--"))
return;
if (!strcmp(argv[i], "--")) {
i++;
break;
}
if (!strcmp(argv[i], "--no-index"))
no_index = 1;
if (argv[i][0] != '-')
Expand Down Expand Up @@ -212,8 +214,10 @@ void diff_no_index(struct rev_info *revs,
int j;
if (!strcmp(argv[i], "--no-index"))
i++;
else if (!strcmp(argv[1], "-q"))
else if (!strcmp(argv[i], "-q"))
options |= DIFF_SILENT_ON_REMOVED;
else if (!strcmp(argv[i], "--"))
i++;
else {
j = diff_opt_parse(&revs->diffopt, argv + i, argc - i);
if (!j)
Expand Down
1 change: 1 addition & 0 deletions t/t4013-diff-various.sh
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ diff --patch-with-stat -r initial..side
diff --patch-with-raw -r initial..side
diff --name-status dir2 dir
diff --no-index --name-status dir2 dir
diff --no-index --name-status -- dir2 dir
diff master master^ side
EOF

Expand Down
3 changes: 3 additions & 0 deletions t/t4013/diff.diff_--no-index_--name-status_--_dir2_dir
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ git diff --no-index --name-status -- dir2 dir
A dir/sub
$

0 comments on commit e423ffd

Please sign in to comment.