Skip to content

Commit b450568

Browse files
crorvickgitster
authored andcommitted
push: allow already-exists advice to be disabled
Add 'advice.pushAlreadyExists' option to disable the advice shown when an update is rejected for a reference that is not allowed to update at all (verses those that are allowed to fast-forward.) Signed-off-by: Chris Rorvick <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1184564 commit b450568

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

Documentation/config.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ advice.*::
142142
--
143143
pushUpdateRejected::
144144
Set this variable to 'false' if you want to disable
145-
'pushNonFFCurrent', 'pushNonFFDefault', and
146-
'pushNonFFMatching' simultaneously.
145+
'pushNonFFCurrent', 'pushNonFFDefault',
146+
'pushNonFFMatching', and 'pushAlreadyExists'
147+
simultaneously.
147148
pushNonFFCurrent::
148149
Advice shown when linkgit:git-push[1] fails due to a
149150
non-fast-forward update to the current branch.
@@ -158,6 +159,9 @@ advice.*::
158159
'matching refs' explicitly (i.e. you used ':', or
159160
specified a refspec that isn't your current branch) and
160161
it resulted in a non-fast-forward error.
162+
pushAlreadyExists::
163+
Shown when linkgit:git-push[1] rejects an update that
164+
does not qualify for fast-forwarding (e.g., a tag.)
161165
statusHints::
162166
Show directions on how to proceed from the current
163167
state in the output of linkgit:git-status[1] and in

advice.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ int advice_push_update_rejected = 1;
44
int advice_push_non_ff_current = 1;
55
int advice_push_non_ff_default = 1;
66
int advice_push_non_ff_matching = 1;
7+
int advice_push_already_exists = 1;
78
int advice_status_hints = 1;
89
int advice_commit_before_merge = 1;
910
int advice_resolve_conflict = 1;
@@ -18,6 +19,7 @@ static struct {
1819
{ "pushnonffcurrent", &advice_push_non_ff_current },
1920
{ "pushnonffdefault", &advice_push_non_ff_default },
2021
{ "pushnonffmatching", &advice_push_non_ff_matching },
22+
{ "pushalreadyexists", &advice_push_already_exists },
2123
{ "statushints", &advice_status_hints },
2224
{ "commitbeforemerge", &advice_commit_before_merge },
2325
{ "resolveconflict", &advice_resolve_conflict },

advice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extern int advice_push_update_rejected;
77
extern int advice_push_non_ff_current;
88
extern int advice_push_non_ff_default;
99
extern int advice_push_non_ff_matching;
10+
extern int advice_push_already_exists;
1011
extern int advice_status_hints;
1112
extern int advice_commit_before_merge;
1213
extern int advice_resolve_conflict;

builtin/push.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ static void advise_checkout_pull_push(void)
247247

248248
static void advise_ref_already_exists(void)
249249
{
250+
if (!advice_push_already_exists || !advice_push_update_rejected)
251+
return;
250252
advise(_(message_advice_ref_already_exists));
251253
}
252254

0 commit comments

Comments
 (0)