コード例 #1
0
ファイル: worktree.c プロジェクト: ayanmw/git
static void validate_no_submodules(const struct worktree *wt)
{
	struct index_state istate = { NULL };
	int i, found_submodules = 0;

	if (read_index_from(&istate, worktree_git_path(wt, "index"),
			    get_worktree_git_dir(wt)) > 0) {
		for (i = 0; i < istate.cache_nr; i++) {
			struct cache_entry *ce = istate.cache[i];

			if (S_ISGITLINK(ce->ce_mode)) {
				found_submodules = 1;
				break;
			}
		}
	}
	discard_index(&istate);

	if (found_submodules)
		die(_("working trees containing submodules cannot be moved or removed"));
}
コード例 #2
0
ファイル: worktree.c プロジェクト: PhilipOakley/git
const char *worktree_lock_reason(struct worktree *wt)
{
	assert(!is_main_worktree(wt));

	if (!wt->lock_reason_valid) {
		struct strbuf path = STRBUF_INIT;

		strbuf_addstr(&path, worktree_git_path(wt, "locked"));
		if (file_exists(path.buf)) {
			struct strbuf lock_reason = STRBUF_INIT;
			if (strbuf_read_file(&lock_reason, path.buf, 0) < 0)
				die_errno(_("failed to read '%s'"), path.buf);
			strbuf_trim(&lock_reason);
			wt->lock_reason = strbuf_detach(&lock_reason, NULL);
		} else
			wt->lock_reason = NULL;
		wt->lock_reason_valid = 1;
		strbuf_release(&path);
	}

	return wt->lock_reason;
}