commit - 537ac44b6c471f75e8dd4abf6e16d0a775d9dded
commit + 244725f25f8754428aebce708d49d3ea834faf90
blob - dae6672247158b8fbc4f7a5261aa087743531d3a
blob + 0cde8390b3004214f2bdd29ec02d112479acc054
--- got/got.c
+++ got/got.c
const char *path, struct got_object_id *blob_id,
struct got_object_id *staged_blob_id, struct got_object_id *commit_id)
{
- if (status == staged_status &&
- (status == GOT_STATUS_ADD || status == GOT_STATUS_DELETE))
+ if (status == staged_status && (status == GOT_STATUS_DELETE))
status = GOT_STATUS_NO_CHANGE;
printf("%c%c %s\n", status, staged_status, path);
return NULL;
blob - 4b2e43983065a80504a44a2a3afdcc6d5c13462d
blob + d40289335e722c9620094d0cfbfebe7527a68ab1
--- lib/worktree.c
+++ lib/worktree.c
if (!got_fileindex_entry_has_file_on_disk(ie)) {
*status = GOT_STATUS_DELETE;
return NULL;
- } else if (!got_fileindex_entry_has_blob(ie)) {
+ } else if (!got_fileindex_entry_has_blob(ie) &&
+ staged_status != GOT_STATUS_ADD) {
*status = GOT_STATUS_ADD;
return NULL;
}
blob - 5aa544477117e7400db4bd3392d28c422359ba50
blob + 5bce7df072be4dc184600315ef84e4729d5b5d1e
--- regress/cmdline/stage.sh
+++ regress/cmdline/stage.sh
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
fi
+
+ echo "modified file again" >> $testroot/wt/alpha
+ echo "modified added file again" >> $testroot/wt/foo
+
+ echo 'MM alpha' > $testroot/stdout.expected
+ echo ' D beta' >> $testroot/stdout.expected
+ echo 'A epsilon/new' >> $testroot/stdout.expected
+ echo 'M epsilon/zeta' >> $testroot/stdout.expected
+ echo 'MA foo' >> $testroot/stdout.expected
+ echo 'D gamma/delta' >> $testroot/stdout.expected
+
+ (cd $testroot/wt && got status > $testroot/stdout)
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ # test no-op change of added file with new stat(2) timestamp
+ echo "new file" > $testroot/wt/foo
+ echo ' A foo' > $testroot/stdout.expected
+ (cd $testroot/wt && got status foo > $testroot/stdout)
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ # test staged deleted file which is restored on disk
+ echo "new file" > $testroot/wt/beta
+ echo ' D beta' > $testroot/stdout.expected
+ (cd $testroot/wt && got status beta > $testroot/stdout)
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
test_done "$testroot" "$ret"
+
}
run_test test_stage_basic