summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 63d564b)
raw | patch | inline | side by side (parent: 63d564b)
author | Junio C Hamano <gitster@pobox.com> | |
Tue, 3 Nov 2009 14:59:18 +0000 (06:59 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 20 Nov 2009 23:10:29 +0000 (15:10 -0800) |
Move the logic to read revs from standard input that rev-list knows about
from it to revision machinery, so that all the users of setup_revisions()
can feed the list of revs from the standard input when "--stdin" is used
on the command line.
Allow some users of the revision machinery that want different semantics
from the "--stdin" option to disable it by setting an option in the
rev_info structure.
This also cleans up the kludge made to bundle.c via cut and paste.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
from it to revision machinery, so that all the users of setup_revisions()
can feed the list of revs from the standard input when "--stdin" is used
on the command line.
Allow some users of the revision machinery that want different semantics
from the "--stdin" option to disable it by setting an option in the
rev_info structure.
This also cleans up the kludge made to bundle.c via cut and paste.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
index bf66116d61af4f16cff59ed1563f38736a14ecce..88ad405111dcf53d12ab4a41306f03b3bd844b01 100644 (file)
Pretend as if all the refs in `$GIT_DIR/refs/remotes` are listed
on the command line as '<commit>'.
-ifdef::git-rev-list[]
--stdin::
In addition to the '<commit>' listed on the command
line, read them from the standard input.
+ifdef::git-rev-list[]
--quiet::
Don't print anything to standard output. This form
diff --git a/builtin-blame.c b/builtin-blame.c
index 7512773b401255e76aadd5be6e561432d7d60772..b0aa5305079715165508bd96e5c1b35de8ddd3e3 100644 (file)
--- a/builtin-blame.c
+++ b/builtin-blame.c
die_errno("cannot stat path '%s'", path);
}
+ revs.disable_stdin = 1;
setup_revisions(argc, argv, &revs, NULL);
memset(&sb, 0, sizeof(sb));
diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c
index 79cedb72c44dca3edf400d86e401a93531b54407..2380c21951fb5fb8050ab1acf0e7f01f36ea5520 100644 (file)
--- a/builtin-diff-tree.c
+++ b/builtin-diff-tree.c
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
opt->abbrev = 0;
opt->diff = 1;
+ opt->disable_stdin = 1;
argc = setup_revisions(argc, argv, opt, NULL);
while (--argc > 0) {
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 42cc8d8872afbc1302f14e089db430014330f7c3..f6a56f34e18809f9feeee3bbd77c4b11cc08a6c6 100644 (file)
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
struct rev_info revs;
struct rev_list_info info;
int i;
- int read_from_stdin = 0;
int bisect_list = 0;
int bisect_show_vars = 0;
int bisect_find_all = 0;
bisect_show_vars = 1;
continue;
}
- if (!strcmp(arg, "--stdin")) {
- if (read_from_stdin++)
- die("--stdin given twice?");
- read_revisions_from_stdin(&revs);
- continue;
- }
usage(rev_list_usage);
}
diff --git a/bundle.c b/bundle.c
index df95e151e2e82b48e4f15f2180838bf2d178f923..e04ab497111a15f96671d27e16fd901438d28e26 100644 (file)
--- a/bundle.c
+++ b/bundle.c
int i, ref_count = 0;
char buffer[1024];
struct rev_info revs;
- int read_from_stdin = 0;
struct child_process rls;
FILE *rls_fout;
/* write references */
argc = setup_revisions(argc, argv, &revs, NULL);
- for (i = 1; i < argc; i++) {
- if (!strcmp(argv[i], "--stdin")) {
- if (read_from_stdin++)
- die("--stdin given twice?");
- read_revisions_from_stdin(&revs);
- continue;
- }
- return error("unrecognized argument: %s'", argv[i]);
- }
+ if (argc > 1)
+ return error("unrecognized argument: %s'", argv[1]);
object_array_remove_duplicates(&revs.pending);
diff --git a/revision.c b/revision.c
index d56387fe65ea55d48c7eef1dda23f789e334397a..f5b735fc1416917f4bae0701344f96ba12d723f8 100644 (file)
--- a/revision.c
+++ b/revision.c
return 0;
}
-void read_revisions_from_stdin(struct rev_info *revs)
+static void read_revisions_from_stdin(struct rev_info *revs)
{
struct strbuf sb;
*/
int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def)
{
- int i, flags, left, seen_dashdash;
+ int i, flags, left, seen_dashdash, read_from_stdin;
/* First, search for "--" */
seen_dashdash = 0;
@@ -1247,6 +1247,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
/* Second, deal with arguments and options */
flags = 0;
+ read_from_stdin = 0;
for (left = i = 1; i < argc; i++) {
const char *arg = argv[i];
if (*arg == '-') {
@@ -1285,6 +1286,16 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
revs->no_walk = 0;
continue;
}
+ if (!strcmp(arg, "--stdin")) {
+ if (revs->disable_stdin) {
+ argv[left++] = arg;
+ continue;
+ }
+ if (read_from_stdin++)
+ die("--stdin given twice?");
+ read_revisions_from_stdin(revs);
+ continue;
+ }
opts = handle_revision_opt(revs, argc - i, argv + i, &left, argv);
if (opts > 0) {
diff --git a/revision.h b/revision.h
index b6421a64321168237443ecb7e56e6b0765256c8b..f64637bcbdc0cfd36585cf93902d33bfc6002894 100644 (file)
--- a/revision.h
+++ b/revision.h
use_terminator:1,
missing_newline:1,
date_mode_explicit:1;
+ unsigned int disable_stdin:1;
+
enum date_mode date_mode;
unsigned int abbrev;
#define REV_TREE_DIFFERENT 3 /* Mixed changes */
/* revision.c */
-void read_revisions_from_stdin(struct rev_info *revs);
-
typedef void (*show_early_output_fn_t)(struct rev_info *, struct commit_list *);
extern volatile show_early_output_fn_t show_early_output;