commit - f851031c033085ae17b056bef665a879706f07eb
commit + 7b5dc508da734468a2a01112b45b7999b55123ce
blob - 3c6178de57a898b1c3c7be0e3585e0a5c40bb6bb
blob + 78201506bd3635cf27a885f9e35fc7c49027ff38
--- lib/worktree.c
+++ lib/worktree.c
struct got_object_id *base_commit_idp = NULL;
char *in_repo_path = NULL, *p;
- if (status == GOT_STATUS_UNVERSIONED)
+ if (status == GOT_STATUS_UNVERSIONED ||
+ status == GOT_STATUS_NO_CHANGE)
return NULL;
if (status == GOT_STATUS_NONEXISTENT)
return got_error_set_errno(ENOENT, relpath);
base_commit_idp = &base_commit_id;
}
- if (status == GOT_STATUS_NO_CHANGE) {
- err = got_error_path(ie->path, GOT_ERR_STAGE_NO_CHANGE);
- goto done;
- } else if (status == GOT_STATUS_CONFLICT) {
+ if (status == GOT_STATUS_CONFLICT) {
err = got_error_path(ie->path, GOT_ERR_STAGE_CONFLICT);
goto done;
} else if (status != GOT_STATUS_ADD &&
void *status_arg;
got_worktree_patch_cb patch_cb;
void *patch_arg;
+ int staged_something;
};
static const struct got_error *
else
stage = GOT_FILEIDX_STAGE_MODIFY;
got_fileindex_entry_stage_set(ie, stage);
+ a->staged_something = 1;
if (a->status_cb == NULL)
break;
err = (*a->status_cb)(a->status_arg, GOT_STATUS_NO_CHANGE,
}
stage = GOT_FILEIDX_STAGE_DELETE;
got_fileindex_entry_stage_set(ie, stage);
+ a->staged_something = 1;
if (a->status_cb == NULL)
break;
err = (*a->status_cb)(a->status_arg, GOT_STATUS_NO_CHANGE,
get_staged_status(ie), relpath, NULL, NULL, NULL);
break;
case GOT_STATUS_NO_CHANGE:
- err = got_error_path(relpath, GOT_ERR_STAGE_NO_CHANGE);
break;
case GOT_STATUS_CONFLICT:
err = got_error_path(relpath, GOT_ERR_STAGE_CONFLICT);
spa.patch_arg = patch_arg;
spa.status_cb = status_cb;
spa.status_arg = status_arg;
+ spa.staged_something = 0;
TAILQ_FOREACH(pe, paths, entry) {
err = worktree_status(worktree, pe->path, fileindex, repo,
stage_path, &spa, NULL, NULL);
if (err)
goto done;
+ }
+ if (!spa.staged_something) {
+ err = got_error(GOT_ERR_STAGE_NO_CHANGE);
+ goto done;
}
sync_err = sync_fileindex(fileindex, fileindex_path);
blob - ba1b5eaaf04bac104befb9a8defef1522ad1de37
blob + 27f30ad84a157384de00cdd4bf0f3cabdc222bcb
--- regress/cmdline/stage.sh
+++ regress/cmdline/stage.sh
(cd $testroot/wt && got add foo > /dev/null)
(cd $testroot/wt && got stage alpha beta foo > /dev/null)
- echo "got: alpha: no changes to stage" > $testroot/stderr.expected
+ echo "got: no changes to stage" > $testroot/stderr.expected
(cd $testroot/wt && got stage alpha 2> $testroot/stderr)
cmp -s $testroot/stderr.expected $testroot/stderr
ret="$?"
return 1
fi
- (cd $testroot/wt && got stage beta > $testroot/stdout)
+ (cd $testroot/wt && got stage beta \
+ > $testroot/stdout 2> $testroot/stderr)
ret="$?"
+ if [ "$ret" == "0" ]; then
+ echo "got stage command succeeded unexpectedly" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+ echo -n > $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
if [ "$ret" != "0" ]; then
- echo "got stage command failed unexpectedly" >&2
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ echo "got: no changes to stage" > $testroot/stderr.expected
+ (cd $testroot/wt && got stage foo 2> $testroot/stderr)
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ printf "q\n" > $testroot/patchscript
+ (cd $testroot/wt && got stage -F $testroot/patchscript -p \
+ > $testroot/stdout 2> $testroot/stderr)
+ ret="$?"
+ if [ "$ret" == "0" ]; then
+ echo "got stage command succeeded unexpectedly" >&2
test_done "$testroot" "1"
return 1
fi
return 1
fi
- echo "got: foo: no changes to stage" > $testroot/stderr.expected
+ echo "got: no changes to stage" > $testroot/stderr.expected
(cd $testroot/wt && got stage foo 2> $testroot/stderr)
cmp -s $testroot/stderr.expected $testroot/stderr
ret="$?"
# don't stage any hunks
printf "n\nn\nn\n" > $testroot/patchscript
(cd $testroot/wt && got stage -F $testroot/patchscript -p \
- numbers > $testroot/stdout)
+ numbers > $testroot/stdout 2> $testroot/stderr)
ret="$?"
- if [ "$ret" != "0" ]; then
- echo "got stage command failed unexpectedly" >&2
+ if [ "$ret" == "0" ]; then
+ echo "got stage command succeeded unexpectedly" >&2
test_done "$testroot" "1"
return 1
fi
return 1
fi
+ echo "got: no changes to stage" > $testroot/stderr.expected
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+
(cd $testroot/wt && got status > $testroot/stdout)
echo "M numbers" > $testroot/stdout.expected
cmp -s $testroot/stdout.expected $testroot/stdout
return 1
fi
- echo "got: epsilon/new: no changes to stage" > $testroot/stderr.expected
+ echo "got: no changes to stage" > $testroot/stderr.expected
cmp -s $testroot/stderr.expected $testroot/stderr
ret="$?"
if [ "$ret" != "0" ]; then
(cd $testroot/wt && got stage -F $testroot/patchscript -p beta \
> $testroot/stdout 2> $testroot/stderr)
ret="$?"
- if [ "$ret" != "0" ]; then
- echo "got stage command failed unexpectedly" >&2
+ if [ "$ret" == "0" ]; then
+ echo "got stage command succeeded unexpectedly" >&2
test_done "$testroot" "$ret"
return 1
fi
- echo -n > $testroot/stderr.expected
+ echo "got: no changes to stage" > $testroot/stderr.expected
cmp -s $testroot/stderr.expected $testroot/stderr
ret="$?"
if [ "$ret" != "0" ]; then