If a file is added to the index (stg add) but is removed from the shell,
git.tree_status doesn't detect it but other commands like push fail. The
patch adds a call to 'git diff-files' in git.tree_status.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
conflicts = []
cache_files += [('C', filename) for filename in conflicts
if not files or filename in files]
conflicts = []
cache_files += [('C', filename) for filename in conflicts
if not files or filename in files]
+ reported_files = set(conflicts)
args = diff_flags + [tree_id]
if files:
args += ['--'] + files
for line in GRun('diff-index', *args).output_lines():
fs = tuple(line.rstrip().split(' ',4)[-1].split('\t',1))
args = diff_flags + [tree_id]
if files:
args += ['--'] + files
for line in GRun('diff-index', *args).output_lines():
fs = tuple(line.rstrip().split(' ',4)[-1].split('\t',1))
- if fs[1] not in conflicts:
+ if fs[1] not in reported_files:
+ reported_files.add(fs[1])
+
+ # files in the index but changed on (or removed from) disk
+ args = list(diff_flags)
+ if files:
+ args += ['--'] + files
+ for line in GRun('diff-files', *args).output_lines():
+ fs = tuple(line.rstrip().split(' ',4)[-1].split('\t',1))
+ if fs[1] not in reported_files:
+ cache_files.append(fs)
+ reported_files.add(fs[1])
diff -u expected.txt output.txt
'
diff -u expected.txt output.txt
'
+cat > expected.txt <<EOF
+D foo/bar
+EOF
+test_expect_success 'Status of disappeared newborn' '
+ stg refresh &&
+ touch foo/bar &&
+ stg add foo/bar &&
+ rm foo/bar &&
+ stg status > output.txt &&
+ diff -u expected.txt output.txt
+'
+
+test_expect_success \
+ 'Undo with disappeared newborn' \
+ '
+ touch newfile &&
+ stg add newfile &&
+ rm newfile &&
+ stg push --undo
+ '
+