Skip to content

Commit 899b49c

Browse files
newrengitster
authored andcommitted
git-rebase, sequencer: extend --quiet option for the interactive machinery
While 'quiet' and 'interactive' may sound like antonyms, the interactive machinery actually has logic that implements several interactive_rebase=implied cases (--exec, --keep-empty, --rebase-merges) which won't pop up an editor. The rewrite of interactive rebase in C added a quiet option, though it only turns stats off. Since we want to make the interactive machinery also take over for git-rebase--merge, it should fully implement the --quiet option. git-rebase--interactive was already somewhat quieter than git-rebase--merge and git-rebase--am, possibly because cherry-pick has just traditionally been quieter. As such, we only drop a few informational messages -- "Rebasing (n/m)" and "Successfully rebased..." Also, for simplicity, remove the differences in how quiet and verbose options were recorded. Having one be signalled by the presence of a "verbose" file in the state_dir, while the other was signalled by the contents of a "quiet" file was just weirdly inconsistent. (This inconsistency pre-dated the rewrite into C.) Make them consistent by having them both key off the presence of the file. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 45339f7 commit 899b49c

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

builtin/rebase.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,7 @@ static int read_basic_state(struct rebase_options *opts)
185185
if (get_oid(buf.buf, &opts->orig_head))
186186
return error(_("invalid orig-head: '%s'"), buf.buf);
187187

188-
strbuf_reset(&buf);
189-
if (read_one(state_dir_path("quiet", opts), &buf))
190-
return -1;
191-
if (buf.len)
188+
if (file_exists(state_dir_path("quiet", opts)))
192189
opts->flags &= ~REBASE_NO_QUIET;
193190
else
194191
opts->flags |= REBASE_NO_QUIET;

git-legacy-rebase.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ read_basic_state () {
113113
else
114114
orig_head=$(cat "$state_dir"/head)
115115
fi &&
116-
GIT_QUIET=$(cat "$state_dir"/quiet) &&
116+
test -f "$state_dir"/quiet && GIT_QUIET=t
117117
test -f "$state_dir"/verbose && verbose=t
118118
test -f "$state_dir"/strategy && strategy="$(cat "$state_dir"/strategy)"
119119
test -f "$state_dir"/strategy_opts &&

git-rebase--common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ write_basic_state () {
1010
echo "$head_name" > "$state_dir"/head-name &&
1111
echo "$onto" > "$state_dir"/onto &&
1212
echo "$orig_head" > "$state_dir"/orig-head &&
13-
echo "$GIT_QUIET" > "$state_dir"/quiet &&
13+
test t = "$GIT_QUIET" && : > "$state_dir"/quiet
1414
test t = "$verbose" && : > "$state_dir"/verbose
1515
test -n "$strategy" && echo "$strategy" > "$state_dir"/strategy
1616
test -n "$strategy_opts" && echo "$strategy_opts" > \

sequencer.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ static GIT_PATH_FUNC(rebase_path_refs_to_delete, "rebase-merge/refs-to-delete")
150150
static GIT_PATH_FUNC(rebase_path_gpg_sign_opt, "rebase-merge/gpg_sign_opt")
151151
static GIT_PATH_FUNC(rebase_path_orig_head, "rebase-merge/orig-head")
152152
static GIT_PATH_FUNC(rebase_path_verbose, "rebase-merge/verbose")
153+
static GIT_PATH_FUNC(rebase_path_quiet, "rebase-merge/quiet")
153154
static GIT_PATH_FUNC(rebase_path_signoff, "rebase-merge/signoff")
154155
static GIT_PATH_FUNC(rebase_path_head_name, "rebase-merge/head-name")
155156
static GIT_PATH_FUNC(rebase_path_onto, "rebase-merge/onto")
156157
static GIT_PATH_FUNC(rebase_path_autostash, "rebase-merge/autostash")
157158
static GIT_PATH_FUNC(rebase_path_strategy, "rebase-merge/strategy")
158159
static GIT_PATH_FUNC(rebase_path_strategy_opts, "rebase-merge/strategy_opts")
159160
static GIT_PATH_FUNC(rebase_path_allow_rerere_autoupdate, "rebase-merge/allow_rerere_autoupdate")
160-
static GIT_PATH_FUNC(rebase_path_quiet, "rebase-merge/quiet")
161161

162162
static int git_sequencer_config(const char *k, const char *v, void *cb)
163163
{
@@ -2357,6 +2357,9 @@ static int read_populate_opts(struct replay_opts *opts)
23572357
if (file_exists(rebase_path_verbose()))
23582358
opts->verbose = 1;
23592359

2360+
if (file_exists(rebase_path_quiet()))
2361+
opts->quiet = 1;
2362+
23602363
if (file_exists(rebase_path_signoff())) {
23612364
opts->allow_ff = 0;
23622365
opts->signoff = 1;
@@ -2424,9 +2427,6 @@ int write_basic_state(struct replay_opts *opts, const char *head_name,
24242427

24252428
if (quiet)
24262429
write_file(rebase_path_quiet(), "%s\n", quiet);
2427-
else
2428-
write_file(rebase_path_quiet(), "\n");
2429-
24302430
if (opts->verbose)
24312431
write_file(rebase_path_verbose(), "%s", "");
24322432
if (opts->strategy)
@@ -3503,10 +3503,11 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
35033503
fprintf(f, "%d\n", todo_list->done_nr);
35043504
fclose(f);
35053505
}
3506-
fprintf(stderr, "Rebasing (%d/%d)%s",
3507-
todo_list->done_nr,
3508-
todo_list->total_nr,
3509-
opts->verbose ? "\n" : "\r");
3506+
if (!opts->quiet)
3507+
fprintf(stderr, "Rebasing (%d/%d)%s",
3508+
todo_list->done_nr,
3509+
todo_list->total_nr,
3510+
opts->verbose ? "\n" : "\r");
35103511
}
35113512
unlink(rebase_path_message());
35123513
unlink(rebase_path_author_script());
@@ -3738,8 +3739,10 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
37383739
}
37393740
apply_autostash(opts);
37403741

3741-
fprintf(stderr, "Successfully rebased and updated %s.\n",
3742-
head_ref.buf);
3742+
if (!opts->quiet)
3743+
fprintf(stderr,
3744+
"Successfully rebased and updated %s.\n",
3745+
head_ref.buf);
37433746

37443747
strbuf_release(&buf);
37453748
strbuf_release(&head_ref);

sequencer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct replay_opts {
3939
int allow_empty_message;
4040
int keep_redundant_commits;
4141
int verbose;
42+
int quiet;
4243

4344
int mainline;
4445

0 commit comments

Comments
 (0)