Teach "git diff" to handle filenames starting with '-'
It adds "--" to the git-diff.sh scripts, to keep any filenames that start with a "-" from being confused with an option. But in order to do that, it needs to teach git-diff-files to honor "--". Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Linus Torvalds committed
Oct 18, 2005 at 00:16 UTC
ea51d416c02bb26e9d7600f87b27deb42752e6b5
2 files changed
+9
-4
diff-files.c
+5
@@ -41,6 +41,11 @@ int main(int argc, const char **argv)
41
git_config(git_default_config);
42
diff_setup(&diff_options);
43
while (1 < argc && argv[1][0] == '-') {
44
+ if (!strcmp(argv[1], "--")) {
45
+ argv++;
46
+ argc--;
47
+ break;
48
+ }
49
if (!strcmp(argv[1], "-q"))
50
silent = 1;
51
else if (!strcmp(argv[1], "-r"))
git-diff.sh
+4
-4
@@ -28,16 +28,16 @@ case "$rev" in
28
?*' '^?*)
29
begin=$(expr "$rev" : '.*^.\([0-9a-f]*\).*') &&
30
end=$(expr "$rev" : '.\([0-9a-f]*\). .*') || exit
31
- cmd="git-diff-tree $flags $begin $end $files"
31
+ cmd="git-diff-tree $flags $begin $end -- $files"
32
;;
33
?*' '?*)
34
- cmd="git-diff-tree $flags $rev $files"
34
+ cmd="git-diff-tree $flags $rev -- $files"
35
;;
36
?*' ')
37
- cmd="git-diff-index $flags $rev $files"
37
+ cmd="git-diff-index $flags $rev -- $files"
38
;;
39
'')
40
- cmd="git-diff-files $flags $files"
40
+ cmd="git-diff-files $flags -- $files"
41
;;
42
*)
43
die "I don't understand $*"