diff options
author | Ori Bernstein <ori@eigenstate.org> | 2022-08-16 23:50:28 +0000 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2022-08-16 23:50:28 +0000 |
commit | d86a7ed412555192e2000a9a34b3372f380ec3d0 (patch) | |
tree | 3a6440f1f5731ea8ccd5b11469145ccf21f22f9b /sys/src/cmd/git/import | |
parent | 3839ad4d3c9b26b8a5d564d1d8f09490799e4cd7 (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/import')
-rw-r--r--[-rwxr-xr-x] | sys/src/cmd/git/import | 12 |
1 files changed, 10 insertions, 2 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 '' |