summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrej Shadura <andrew@shadura.me>2019-02-17 15:44:10 +0100
committerAndrej Shadura <andrew@shadura.me>2019-02-17 15:45:11 +0100
commit95f6693614645a8b65fb9340ce866f241df5c6b2 (patch)
treea71019f20c287919a1054563449eb79fdaf72520
parent8614f4cd9650124f1981ead34c5aea9f0f5f1717 (diff)
Fix committing deletions
git-add cannot handle files not present in the working tree, so we need to filter them out when running git-add. The changes will be picked up by git-commit anyway. Staging won’t work properly anyway, but I will address that later.
-rw-r--r--git_crecord/main.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/git_crecord/main.py b/git_crecord/main.py
index f57d839..79c4c83 100644
--- a/git_crecord/main.py
+++ b/git_crecord/main.py
@@ -97,8 +97,10 @@ class Ui:
return t
def stage(self, *files, **opts):
- util.system(['git', 'add', '-f', '--'] + list(files),
- onerr=util.Abort, errprefix=_("add failed"))
+ to_add = [f for f in files if os.path.exists(f)]
+ if to_add:
+ util.system(['git', 'add', '-N', '--'] + to_add,
+ onerr=util.Abort, errprefix=_("add failed"))
def commit(self, *files, **opts):
(fd, name) = tempfile.mkstemp(prefix='git-crecord-',
@@ -130,8 +132,11 @@ class Ui:
else:
args.append('--%s=%s' % (k, v))
- util.system(['git', 'add', '-N', '--'] + list(files),
- onerr=util.Abort, errprefix=_("add failed"))
+ util.system(['git', 'status'])
+ to_add = [f for f in files if os.path.exists(f)]
+ if to_add:
+ util.system(['git', 'add', '-N', '--'] + to_add,
+ onerr=util.Abort, errprefix=_("add failed"))
if opts['message'] is None:
util.system(['git', 'commit'] + args + ['--'] + list(files),
onerr=util.Abort, errprefix=_("commit failed"))