Skip to content

Commit

Permalink
git-apply: if no input files specified, apply stdin
Browse files Browse the repository at this point in the history
This makes it act more like a traditional UNIX thing (eg "cat").
  • Loading branch information
Linus Torvalds committed May 23, 2005
1 parent 9ab55bd commit 4dfdbe1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ static int apply_patch(int fd)
int main(int argc, char **argv)
{
int i;
int read_stdin = 1;

if (read_cache() < 0)
die("unable to read index file");
Expand All @@ -519,6 +520,7 @@ int main(int argc, char **argv)

if (!strcmp(arg, "-")) {
apply_patch(0);
read_stdin = 0;
continue;
}
if (!strcmp(arg, "--no-merge")) {
Expand All @@ -528,8 +530,11 @@ int main(int argc, char **argv)
fd = open(arg, O_RDONLY);
if (fd < 0)
usage(apply_usage);
read_stdin = 0;
apply_patch(fd);
close(fd);
}
if (read_stdin)
apply_patch(0);
return 0;
}

0 comments on commit 4dfdbe1

Please sign in to comment.