summaryrefslogtreecommitdiff
path: root/sys/src/cmd/git
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2022-08-16 23:50:28 +0000
committerOri Bernstein <ori@eigenstate.org>2022-08-16 23:50:28 +0000
commitd86a7ed412555192e2000a9a34b3372f380ec3d0 (patch)
tree3a6440f1f5731ea8ccd5b11469145ccf21f22f9b /sys/src/cmd/git
parent3839ad4d3c9b26b8a5d564d1d8f09490799e4cd7 (diff)
git/rebase: allow rebase without a clean tree
Here, patch grows a dry run option (-n), which allows git/import to bail out early if it would patch files that are dirty in tree. Once git/import refuses to patch dirty files, git/rebase can skip checking if the whole tree is clean, which is both convenient and much faster on large trees.
Diffstat (limited to 'sys/src/cmd/git')
-rw-r--r--[-rwxr-xr-x]sys/src/cmd/git/import12
-rw-r--r--[-rwxr-xr-x]sys/src/cmd/git/rebase2
2 files changed, 10 insertions, 4 deletions
diff --git a/sys/src/cmd/git/import b/sys/src/cmd/git/import
index 0cc450bf8..102a4fdcd 100755..100644
--- a/sys/src/cmd/git/import
+++ b/sys/src/cmd/git/import
@@ -76,8 +76,16 @@ fn apply @{
# force re-reading env
rc -c '
- echo applying $msg | sed 1q
date=`{seconds $date}
+ files=`$nl{patch -np1 < $diffpath}
+ if(! git/walk -q $files){
+ >[1=2] {
+ echo patch would clobber files:
+ git/walk $files
+ exit clobber
+ }
+ }
+ echo applying $msg | sed 1q
if(! files=`$nl{patch -p1 < $diffpath})
die ''patch failed''
for(f in $files){
@@ -111,6 +119,6 @@ for(p in $patches){
if(test -d $p && test -f $p/header && test -f $p/body)
{{cat $p/header; echo; cat $p/body} | apply} || die $status
if not
- apply < $p || die $status
+ apply < $p
}
exit ''
diff --git a/sys/src/cmd/git/rebase b/sys/src/cmd/git/rebase
index 395f3e693..a2aef6c2f 100755..100644
--- a/sys/src/cmd/git/rebase
+++ b/sys/src/cmd/git/rebase
@@ -7,8 +7,6 @@ flagfmt='a:abort, r:resume, i:interactive'; args='onto'
eval `''{aux/getflags $*} || exec aux/usage
tmp=_rebase.working
-if(! git/walk -q)
- die dirty working tree
if(~ $#abort 1){
if(! test -f .git/rebase.todo)
die no rebase to abort