commit - 3cd04235095aa7bdcf00df666cae3920964aec22
commit + 88d0e355ca772bd1e7e957adbfb68c2cc8d42cbb
blob - 5ce42cbb34750c1806b8be47db8426916ee452cd
blob + 982c3c862a12ef541b601f25a5596bcc055fa219
--- got/got.c
+++ got/got.c
};
static const struct got_error *
-print_diff(void *arg, unsigned char status, const char *path,
- struct got_object_id *blob_id, struct got_object_id *commit_id)
+print_diff(void *arg, unsigned char status, unsigned char staged_status,
+ const char *path, struct got_object_id *blob_id,
+ struct got_object_id *commit_id)
{
struct print_diff_arg *a = arg;
const struct got_error *err = NULL;
}
static const struct got_error *
-print_status(void *arg, unsigned char status, const char *path,
- struct got_object_id *blob_id, struct got_object_id *commit_id)
+print_status(void *arg, unsigned char status, unsigned char staged_status,
+ const char *path, struct got_object_id *blob_id,
+ struct got_object_id *commit_id)
{
- printf("%c %s\n", status, path);
+ printf("%c%c %s\n", status, staged_status, path);
return NULL;
}
blob - 2d55ba42e59fbbee2f17dfdd693234c397232b49
blob + 52674a343e3a62182995e05f88e313dadc8bc688
--- include/got_worktree.h
+++ include/got_worktree.h
/* A callback function which is invoked to report a path's status. */
typedef const struct got_error *(*got_worktree_status_cb)(void *,
- unsigned char, const char *, struct got_object_id *,
+ unsigned char, unsigned char, const char *, struct got_object_id *,
struct got_object_id *);
/*
blob - c45b9460c5134f96d0e145c25ee332de6de5208f
blob + 9ca3668846a3c3c88f8d3f2b88205f1bb55ccc91
--- lib/worktree.c
+++ lib/worktree.c
got_worktree_cancel_cb cancel_cb;
void *cancel_arg;
};
+
+static unsigned char
+get_staged_status(struct got_fileindex_entry *ie)
+{
+ switch (got_fileindex_entry_stage_get(ie)) {
+ case GOT_FILEIDX_STAGE_ADD:
+ return GOT_STATUS_ADD;
+ case GOT_FILEIDX_STAGE_DELETE:
+ return GOT_STATUS_DELETE;
+ case GOT_FILEIDX_STAGE_MODIFY:
+ return GOT_STATUS_MODIFY;
+ default:
+ return GOT_STATUS_NO_CHANGE;
+ }
+}
static const struct got_error *
report_file_status(struct got_fileindex_entry *ie, const char *abspath,
if (err == NULL && status != GOT_STATUS_NO_CHANGE) {
memcpy(blob_id.sha1, ie->blob_sha1, SHA1_DIGEST_LENGTH);
memcpy(commit_id.sha1, ie->commit_sha1, SHA1_DIGEST_LENGTH);
- err = (*status_cb)(status_arg, status, ie->path, &blob_id,
- &commit_id);
+ err = (*status_cb)(status_arg, status, get_staged_status(ie),
+ ie->path, &blob_id, &commit_id);
}
return err;
}
status = GOT_STATUS_MISSING;
else
status = GOT_STATUS_DELETE;
- return (*a->status_cb)(a->status_arg, status, ie->path, &blob_id,
- &commit_id);
+ return (*a->status_cb)(a->status_arg, status, get_staged_status(ie),
+ ie->path, &blob_id, &commit_id);
}
static const struct got_error *
if (got_path_is_child(path, a->status_path, a->status_path_len))
err = (*a->status_cb)(a->status_arg, GOT_STATUS_UNVERSIONED,
- path, NULL, NULL);
+ GOT_STATUS_NO_CHANGE, path, NULL, NULL);
if (parent_path[0])
free(path);
return err;
}
if (S_ISREG(sb.st_mode))
- return (*status_cb)(status_arg, GOT_STATUS_UNVERSIONED, path,
- NULL, NULL);
+ return (*status_cb)(status_arg, GOT_STATUS_UNVERSIONED,
+ GOT_STATUS_NO_CHANGE, path, NULL, NULL);
return NULL;
}
};
static const struct got_error *
-collect_commitables(void *arg, unsigned char status, const char *relpath,
+collect_commitables(void *arg, unsigned char status,
+ unsigned char staged_status, const char *relpath,
struct got_object_id *blob_id, struct got_object_id *commit_id)
{
struct collect_commitables_arg *a = arg;
const char *ct_path = ct->path;
while (ct_path[0] == '/')
ct_path++;
- return (*status_cb)(status_arg, ct->status, ct_path, ct->blob_id, NULL);
+ return (*status_cb)(status_arg, ct->status, GOT_STATUS_NO_CHANGE,
+ ct_path, ct->blob_id, NULL);
}
static const struct got_error *
}
static const struct got_error *
-rebase_status(void *arg, unsigned char status, const char *path,
- struct got_object_id *blob_id, struct got_object_id *commit_id)
+rebase_status(void *arg, unsigned char status, unsigned char staged_status,
+ const char *path, struct got_object_id *blob_id,
+ struct got_object_id *commit_id)
{
return NULL;
}
};
static const struct got_error *
-collect_revertible_paths(void *arg, unsigned char status, const char *relpath,
+collect_revertible_paths(void *arg, unsigned char status,
+ unsigned char staged_status, const char *relpath,
struct got_object_id *blob_id, struct got_object_id *commit_id)
{
struct collect_revertible_paths_arg *a = arg;
}
got_fileindex_entry_stage_set(ie, stage);
-
- /* XXX TODO pass 'staged' status separately */
- err = (*status_cb)(status_arg, status, relpath, blob_id, NULL);
+ err = (*status_cb)(status_arg, GOT_STATUS_NO_CHANGE,
+ get_staged_status(ie), relpath, blob_id, NULL);
done:
free(blob_id);
return err;
blob - 382ddd39fe2226a6fb139ae0ca401c60d3d8c8d4
blob + 0a71da3d883b97908fcb160560cf43325fa6676d
--- regress/cmdline/stage.sh
+++ regress/cmdline/stage.sh
echo "new file" > $testroot/wt/foo
(cd $testroot/wt && got add foo > /dev/null)
- echo 'M alpha' > $testroot/stdout.expected
- echo 'D beta' >> $testroot/stdout.expected
- echo 'A foo' >> $testroot/stdout.expected
+ echo ' M alpha' > $testroot/stdout.expected
+ echo ' D beta' >> $testroot/stdout.expected
+ echo ' A foo' >> $testroot/stdout.expected
(cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
cmp -s $testroot/stdout.expected $testroot/stdout