mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Reland: add a --no-squash argument to git rebase-update
See crbug.com/40264739 for many more details. But a prior attempt to land this patch resulted in [1] which simply removed all squashing behavior from `git rebase-update`. That broke several people's workflows. So this patch attempts, again, to simply add an opt-in to *not* squashing, for the folks (like me) who do not want that behavior. [1] https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6104282 Fixed: 40264739 Change-Id: I4a6aa8e53e854a7e601a0fb83f4f9fcb638d36ed Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6254099 Reviewed-by: Mason Freed <masonf@chromium.org> Commit-Queue: Mason Freed <masonf@chromium.org> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org>
This commit is contained in:
@@ -140,7 +140,7 @@ def remove_empty_branches(branch_tree):
|
|||||||
print(git.run('branch', '-d', branch))
|
print(git.run('branch', '-d', branch))
|
||||||
|
|
||||||
|
|
||||||
def rebase_branch(branch, parent, start_hash):
|
def rebase_branch(branch, parent, start_hash, no_squash):
|
||||||
logging.debug('considering %s(%s) -> %s(%s) : %s', branch,
|
logging.debug('considering %s(%s) -> %s(%s) : %s', branch,
|
||||||
git.hash_one(branch), parent, git.hash_one(parent),
|
git.hash_one(branch), parent, git.hash_one(parent),
|
||||||
start_hash)
|
start_hash)
|
||||||
@@ -161,7 +161,8 @@ def rebase_branch(branch, parent, start_hash):
|
|||||||
if git.hash_one(parent) != start_hash:
|
if git.hash_one(parent) != start_hash:
|
||||||
# Try a plain rebase first
|
# Try a plain rebase first
|
||||||
print('Rebasing:', branch)
|
print('Rebasing:', branch)
|
||||||
consider_squashing = git.get_num_commits(branch) != 1
|
consider_squashing = git.get_num_commits(branch) != 1 and not (
|
||||||
|
no_squash)
|
||||||
rebase_ret = git.rebase(parent,
|
rebase_ret = git.rebase(parent,
|
||||||
start_hash,
|
start_hash,
|
||||||
branch,
|
branch,
|
||||||
@@ -275,6 +276,11 @@ def main(args=None):
|
|||||||
'-e',
|
'-e',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Do not automatically delete empty branches.')
|
help='Do not automatically delete empty branches.')
|
||||||
|
parser.add_argument(
|
||||||
|
'--no-squash',
|
||||||
|
action='store_true',
|
||||||
|
help='Will not try to squash branches if rebasing fails.')
|
||||||
|
|
||||||
opts = parser.parse_args(args)
|
opts = parser.parse_args(args)
|
||||||
|
|
||||||
if opts.verbose: # pragma: no cover
|
if opts.verbose: # pragma: no cover
|
||||||
@@ -341,7 +347,8 @@ def main(args=None):
|
|||||||
if git.is_dormant(branch):
|
if git.is_dormant(branch):
|
||||||
print('Skipping dormant branch', branch)
|
print('Skipping dormant branch', branch)
|
||||||
else:
|
else:
|
||||||
ret = rebase_branch(branch, parent, merge_base[branch])
|
ret = rebase_branch(branch, parent, merge_base[branch],
|
||||||
|
opts.no_squash)
|
||||||
if not ret:
|
if not ret:
|
||||||
retcode = 1
|
retcode = 1
|
||||||
|
|
||||||
|
|||||||
@@ -756,7 +756,7 @@ git-rebase-update(1) Manual Page
|
|||||||
<h2 id="_synopsis">SYNOPSIS</h2>
|
<h2 id="_synopsis">SYNOPSIS</h2>
|
||||||
<div class="sectionbody">
|
<div class="sectionbody">
|
||||||
<div class="verseblock">
|
<div class="verseblock">
|
||||||
<pre class="content"><em>git rebase-update</em> [-v | --verbose] [-n | --no-fetch] [-k | --keep-going]</pre>
|
<pre class="content"><em>git rebase-update</em> [-v | --verbose] [-n | --no-fetch] [-k | --keep-going] [--no-squash]</pre>
|
||||||
<div class="attribution">
|
<div class="attribution">
|
||||||
</div></div>
|
</div></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -869,6 +869,14 @@ Restoration
|
|||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="hdlist1">
|
<dt class="hdlist1">
|
||||||
|
--no-squash
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
Skip the squash phase of rebase-update if there are merge conflicts.
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt class="hdlist1">
|
||||||
-v
|
-v
|
||||||
</dt>
|
</dt>
|
||||||
<dt class="hdlist1">
|
<dt class="hdlist1">
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ git-rebase-update \- Updates all branches to have the latest changes from their
|
|||||||
.SH "SYNOPSIS"
|
.SH "SYNOPSIS"
|
||||||
.sp
|
.sp
|
||||||
.nf
|
.nf
|
||||||
\fIgit rebase\-update\fR [\-v | \-\-verbose] [\-n | \-\-no\-fetch] [\-k | \-\-keep\-going]
|
\fIgit rebase\-update\fR [\-v | \-\-verbose] [\-n | \-\-no\-fetch] [\-k | \-\-keep\-going] | [\-\-no\-squash]
|
||||||
.fi
|
.fi
|
||||||
.sp
|
.sp
|
||||||
.SH "DESCRIPTION"
|
.SH "DESCRIPTION"
|
||||||
@@ -125,6 +125,11 @@ Skip the
|
|||||||
phase of rebase\-update\&.
|
phase of rebase\-update\&.
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
|
\-\-no\-squash
|
||||||
|
.RS 4
|
||||||
|
Skip the squashing phase of rebase\-update\&.
|
||||||
|
.RE
|
||||||
|
.PP
|
||||||
\-v, \-\-verbose
|
\-v, \-\-verbose
|
||||||
.RS 4
|
.RS 4
|
||||||
More text than your terminal can handle\&.
|
More text than your terminal can handle\&.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ include::_git-rebase-update_desc.helper.txt[]
|
|||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
[verse]
|
[verse]
|
||||||
'git rebase-update' [-v | --verbose] [-n | --no-fetch] [-k | --keep-going]
|
'git rebase-update' [-v | --verbose] [-n | --no-fetch] [-k | --keep-going] [--no-squash]
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
@@ -78,6 +78,9 @@ OPTIONS
|
|||||||
--no-fetch::
|
--no-fetch::
|
||||||
Skip the `git fetch` phase of rebase-update.
|
Skip the `git fetch` phase of rebase-update.
|
||||||
|
|
||||||
|
--no-squash::
|
||||||
|
Skip the squash phase of rebase-update if there are merge conflicts.
|
||||||
|
|
||||||
-v::
|
-v::
|
||||||
--verbose::
|
--verbose::
|
||||||
More text than your terminal can handle.
|
More text than your terminal can handle.
|
||||||
|
|||||||
Reference in New Issue
Block a user