Skip to content

Commit b4c8eb0

Browse files
prertikgitster
authored andcommitted
builtin rebase: support --quiet
This commit introduces a rebase option `--quiet`. While `--quiet` is commonly perceived as opposite to `--verbose`, this is not the case for the rebase command: both `--quiet` and `--verbose` default to `false` if neither `--quiet` nor `--verbose` is present. Despite the default being `false` for both verbose and quiet mode, passing the `--quiet` option will turn off verbose mode, and `--verbose` will turn off quiet mode. This patch introduces the `flags` bit field, with `REBASE_NO_QUIET` as first user (with many more to come). We do *not* use `REBASE_QUIET` here for an important reason: To keep the implementation simple, this commit introduces `--no-quiet` instead of `--quiet`, so that a single `OPT_NEGBIT()` can turn on quiet mode and turn off verbose and diffstat mode at the same time. Likewise, the companion commit which will introduce support for `--verbose` will have a single `OPT_BIT()` that turns off quiet mode and turns on verbose and diffstat mode at the same time. Signed-off-by: Pratik Karki <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 06e4775 commit b4c8eb0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

builtin/rebase.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ struct rebase_options {
7979
int root;
8080
struct commit *restrict_revision;
8181
int dont_finish_rebase;
82+
enum {
83+
REBASE_NO_QUIET = 1<<0,
84+
} flags;
85+
struct strbuf git_am_opt;
8286
};
8387

8488
/* Returns the filename prefixed by the state_dir */
@@ -159,6 +163,9 @@ static int run_specific_rebase(struct rebase_options *opts)
159163
add_var(&script_snippet, "revisions", opts->revisions);
160164
add_var(&script_snippet, "restrict_revision", opts->restrict_revision ?
161165
oid_to_hex(&opts->restrict_revision->object.oid) : NULL);
166+
add_var(&script_snippet, "GIT_QUIET",
167+
opts->flags & REBASE_NO_QUIET ? "" : "t");
168+
add_var(&script_snippet, "git_am_opt", opts->git_am_opt.buf);
162169

163170
switch (opts->type) {
164171
case REBASE_AM:
@@ -308,6 +315,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
308315
{
309316
struct rebase_options options = {
310317
.type = REBASE_UNSPECIFIED,
318+
.flags = REBASE_NO_QUIET,
319+
.git_am_opt = STRBUF_INIT,
311320
};
312321
const char *branch_name;
313322
int ret, flags;
@@ -321,6 +330,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
321330
N_("rebase onto given branch instead of upstream")),
322331
OPT_BOOL(0, "no-verify", &ok_to_skip_pre_rebase,
323332
N_("allow pre-rebase hook to run")),
333+
OPT_NEGBIT('q', "quiet", &options.flags,
334+
N_("be quiet. implies --no-stat"),
335+
REBASE_NO_QUIET),
324336
OPT_END(),
325337
};
326338

@@ -357,6 +369,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
357369
usage_with_options(builtin_rebase_usage,
358370
builtin_rebase_options);
359371

372+
if (!(options.flags & REBASE_NO_QUIET))
373+
strbuf_addstr(&options.git_am_opt, " -q");
374+
360375
switch (options.type) {
361376
case REBASE_MERGE:
362377
case REBASE_INTERACTIVE:

0 commit comments

Comments
 (0)