commit - 13d9040b96f5ba9ac50c137a9909f824dd5bde20
commit + fc6346c42a66d7fc562608e08dbd41e775facfc4
blob - 3f0523ffaec3bb0f816ab6a98521fbe8d543e3f6
blob + 694339afe5680f6668ebb29a16409b9056d82593
--- lib/worktree.c
+++ lib/worktree.c
got_worktree_checkout_cb progress_cb, void *progress_arg,
got_worktree_cancel_cb cancel_cb, void *cancel_arg)
{
- const struct got_error *err;
+ const struct got_error *err = NULL;
unsigned char status;
struct stat sb;
char *ondisk_path;
err = get_file_status(&status, &sb, ie, ondisk_path, repo);
if (err)
return err;
-
- (*progress_cb)(progress_arg, GOT_STATUS_DELETE, ie->path);
- if (status == GOT_STATUS_NO_CHANGE) {
- err = remove_ondisk_file(worktree->root_path, ie->path);
+ if (status == GOT_STATUS_MODIFY || status == GOT_STATUS_CONFLICT ||
+ status == GOT_STATUS_ADD) {
+ (*progress_cb)(progress_arg, GOT_STATUS_MERGE, ie->path);
+ /*
+ * Preserve the working file and change the deleted blob's
+ * entry into a schedule-add entry.
+ */
+ err = got_fileindex_entry_update(ie, ondisk_path, NULL, NULL,
+ 0);
if (err)
return err;
+ } else {
+ (*progress_cb)(progress_arg, GOT_STATUS_DELETE, ie->path);
+ if (status == GOT_STATUS_NO_CHANGE) {
+ err = remove_ondisk_file(worktree->root_path, ie->path);
+ if (err)
+ return err;
+ }
+ got_fileindex_entry_remove(fileindex, ie);
}
- got_fileindex_entry_remove(fileindex, ie);
- return NULL;
+ return err;
}
struct diff_cb_arg {
blob - 5b27ea3fdd42c59f652befa84aa020bb8f3b7139
blob + f5e6128544c9c93da5fd836b3efe97bb428880fa
--- regress/cmdline/update.sh
+++ regress/cmdline/update.sh
(cd $testroot/wt && got update > $testroot/stdout)
- echo "D beta" > $testroot/stdout.expected
+ echo "G beta" > $testroot/stdout.expected
echo -n "Updated to commit " >> $testroot/stdout.expected
git_show_head $testroot/repo >> $testroot/stdout.expected
echo >> $testroot/stdout.expected
return 1
fi
- # beta is now an unversioned file... we don't flag tree conflicts yet
- echo '? beta' > $testroot/stdout.expected
+ # beta is now an added file... we don't flag tree conflicts yet
+ echo 'A beta' > $testroot/stdout.expected
(cd $testroot/wt && got status > $testroot/stdout)
cmp $testroot/stdout.expected $testroot/stdout
ret="$?"