commit - 22694bb8ff1cf412bbdfc251e2dce27baca160b6
commit + 022fae89eee20051d352d3dc2b8c64486bdafe93
blob - 044aadf30b3ae798d851660a58e8dddd57a6b746
blob + 6b4ec9a6c5c0f9240144d60d19c72d8af64f0b0e
--- TODO
+++ TODO
got:
- 'histedit -c' prompts for log message even if there are no changes to commit
-- recursive addition: got add -R
- recursive removal: got rm -R
tog:
blob - 57af02b4edfdbb7d0e6764d05c516a435f823c56
blob + 738c17c0ebe37a01def24d8380868ab37fa276bd
--- got/got.1
+++ got/got.1
command may be used to delete a tag's reference.
This should only be done if the tag has not already been copied to
another repository.
-.It Cm add Oo Fl R Oc Ar path ...
+.It Cm add Oo Fl R Oc Oo Fl I Oc Ar path ...
Schedule unversioned files in a work tree for addition to the
repository in the next commit.
.Pp
will refuse to run if a specified
.Ar path
is a directory.
+.It Fl I
+With -R, add files even if they match a
+.Cm got status
+ignore pattern.
.El
.It Cm remove Ar file-path ...
Remove versioned files from a work tree and schedule them for deletion
blob - 756eaa2ea3216dabe5aaf7080a2c652fdbfd0f74
blob + 1887fafe21f18bb64e456a7b9c9947b27b4572f2
--- got/got.c
+++ got/got.c
__dead static void
usage_add(void)
{
- fprintf(stderr, "usage: %s add file-path ...\n", getprogname());
+ fprintf(stderr, "usage: %s add [-R] [-I] file-path ...\n",
+ getprogname());
exit(1);
}
char *cwd = NULL;
struct got_pathlist_head paths;
struct got_pathlist_entry *pe;
- int ch, can_recurse = 0;
+ int ch, can_recurse = 0, no_ignores = 0;
TAILQ_INIT(&paths);
- while ((ch = getopt(argc, argv, "R")) != -1) {
+ while ((ch = getopt(argc, argv, "IR")) != -1) {
switch (ch) {
+ case 'I':
+ no_ignores = 1;
+ break;
case 'R':
can_recurse = 1;
break;
error = get_worktree_paths_from_argv(&paths, argc, argv, worktree);
if (error)
+ goto done;
+
+ if (!can_recurse && no_ignores) {
+ error = got_error_msg(GOT_ERR_BAD_PATH,
+ "disregarding ignores requires -R option");
goto done;
+ }
+
if (!can_recurse) {
char *ondisk_path;
struct stat sb;
}
}
}
+
error = got_worktree_schedule_add(worktree, &paths, add_progress,
- NULL, repo);
+ NULL, repo, no_ignores);
done:
if (repo)
got_repo_close(repo);
blob - a18fc5a59d6c2c165d6f449c5accb262eb450485
blob + 33c5e5f8529ba9bf1fcf626666817f9317db7d02
--- include/got_worktree.h
+++ include/got_worktree.h
/* Schedule files at on-disk paths for addition in the next commit. */
const struct got_error *got_worktree_schedule_add(struct got_worktree *,
struct got_pathlist_head *, got_worktree_checkout_cb, void *,
- struct got_repository *);
+ struct got_repository *, int);
/*
* Remove files from disk and schedule them to be deleted in the next commit.
blob - c56c307e7fad0d579e6eb3fa799150a8b8d31558
blob + a1011c791c8036dbbd7c2f29f5cd7ca8ecafb60c
--- lib/worktree.c
+++ lib/worktree.c
worktree_status(struct got_worktree *worktree, const char *path,
struct got_fileindex *fileindex, struct got_repository *repo,
got_worktree_status_cb status_cb, void *status_arg,
- got_cancel_cb cancel_cb, void *cancel_arg)
+ got_cancel_cb cancel_cb, void *cancel_arg, int no_ignores)
{
const struct got_error *err = NULL;
DIR *workdir = NULL;
arg.cancel_cb = cancel_cb;
arg.cancel_arg = cancel_arg;
TAILQ_INIT(&arg.ignores);
- err = add_ignores(&arg.ignores, worktree->root_path, path,
- ".cvsignore");
- if (err == NULL)
+ if (!no_ignores) {
err = add_ignores(&arg.ignores, worktree->root_path,
- path, ".gitignore");
+ path, ".cvsignore");
+ if (err == NULL)
+ err = add_ignores(&arg.ignores,
+ worktree->root_path, path, ".gitignore");
+ }
if (err == NULL)
err = got_fileindex_diff_dir(fileindex, workdir,
worktree->root_path, path, repo, &fdiff_cb, &arg);
TAILQ_FOREACH(pe, paths, entry) {
err = worktree_status(worktree, pe->path, fileindex, repo,
- status_cb, status_arg, cancel_cb, cancel_arg);
+ status_cb, status_arg, cancel_cb, cancel_arg, 0);
if (err)
break;
}
got_worktree_schedule_add(struct got_worktree *worktree,
struct got_pathlist_head *paths,
got_worktree_checkout_cb progress_cb, void *progress_arg,
- struct got_repository *repo)
+ struct got_repository *repo, int no_ignores)
{
struct got_fileindex *fileindex = NULL;
char *fileindex_path = NULL;
return got_error_from_errno("asprintf");
saa.ondisk_path = ondisk_path;
err = worktree_status(worktree, pe->path, fileindex, repo,
- schedule_addition, &saa, NULL, NULL);
+ schedule_addition, &saa, NULL, NULL, no_ignores);
free(ondisk_path);
if (err)
break;
rfa.repo = repo;
TAILQ_FOREACH(pe, paths, entry) {
err = worktree_status(worktree, pe->path, fileindex, repo,
- revert_file, &rfa, NULL, NULL);
+ revert_file, &rfa, NULL, NULL, 0);
if (err)
break;
}
cc_arg.have_staged_files = have_staged_files;
TAILQ_FOREACH(pe, paths, entry) {
err = worktree_status(worktree, pe->path, fileindex, repo,
- collect_commitables, &cc_arg, NULL, NULL);
+ collect_commitables, &cc_arg, NULL, NULL, 0);
if (err)
goto done;
}
}
TAILQ_FOREACH(pe, merged_paths, entry) {
err = worktree_status(worktree, pe->path, fileindex,
- repo, collect_commitables, &cc_arg, NULL, NULL);
+ repo, collect_commitables, &cc_arg, NULL, NULL, 0);
if (err)
goto done;
}
} else {
err = worktree_status(worktree, "", fileindex, repo,
- collect_commitables, &cc_arg, NULL, NULL);
+ collect_commitables, &cc_arg, NULL, NULL, 0);
if (err)
goto done;
}
rfa.patch_arg = NULL;
rfa.repo = repo;
err = worktree_status(worktree, "", fileindex, repo,
- revert_file, &rfa, NULL, NULL);
+ revert_file, &rfa, NULL, NULL, 0);
if (err)
goto sync;
rfa.patch_arg = NULL;
rfa.repo = repo;
err = worktree_status(worktree, "", fileindex, repo,
- revert_file, &rfa, NULL, NULL);
+ revert_file, &rfa, NULL, NULL, 0);
if (err)
goto sync;
oka.have_changes = 0;
TAILQ_FOREACH(pe, paths, entry) {
err = worktree_status(worktree, pe->path, fileindex, repo,
- check_stage_ok, &oka, NULL, NULL);
+ check_stage_ok, &oka, NULL, NULL, 0);
if (err)
goto done;
}
spa.staged_something = 0;
TAILQ_FOREACH(pe, paths, entry) {
err = worktree_status(worktree, pe->path, fileindex, repo,
- stage_path, &spa, NULL, NULL);
+ stage_path, &spa, NULL, NULL, 0);
if (err)
goto done;
}
upa.patch_arg = patch_arg;
TAILQ_FOREACH(pe, paths, entry) {
err = worktree_status(worktree, pe->path, fileindex, repo,
- unstage_path, &upa, NULL, NULL);
+ unstage_path, &upa, NULL, NULL, 0);
if (err)
goto done;
}
blob - 9260016060fa594ef14a31a90e815737bb487ca1
blob + 5964e3aa493d757508aee784e9fe5e11399472cf
--- regress/cmdline/add.sh
+++ regress/cmdline/add.sh
(cd $testroot/wt && got add . > $testroot/stdout 2> $testroot/stderr)
ret="$?"
- if [ "$ret" == "0" ]; then
- echo "got add command succeeded unexpectedly" >&2
- test_done "$testroot" "1"
+ echo "got: adding directories requires -R option" \
+ > $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
- echo "got: adding directories requires -R option" \
+
+ (cd $testroot/wt && got add -I . > $testroot/stdout 2> $testroot/stderr)
+ ret="$?"
+ echo "got: disregarding ignores requires -R option" \
> $testroot/stderr.expected
cmp -s $testroot/stderr.expected $testroot/stderr
ret="$?"
return 1
fi
- (touch $testroot/wt/epsilon/zeta1 && touch $testroot/wt/epsilon/zeta2)
+ mkdir -p $testroot/wt/tree1
+ mkdir -p $testroot/wt/tree2
+ echo "tree1/**" > $testroot/wt/.gitignore
+ echo "tree2/**" >> $testroot/wt/.gitignore
+ echo -n > $testroot/wt/tree1/foo
+ echo -n > $testroot/wt/tree2/foo
+ echo -n > $testroot/wt/epsilon/zeta1
+ echo -n > $testroot/wt/epsilon/zeta2
(cd $testroot/wt && got add -R . > $testroot/stdout)
- echo 'A epsilon/zeta1' > $testroot/stdout.expected
+ echo 'A .gitignore' > $testroot/stdout.expected
+ echo 'A epsilon/zeta1' >> $testroot/stdout.expected
echo 'A epsilon/zeta2' >> $testroot/stdout.expected
cmp -s $testroot/stdout.expected $testroot/stdout
return 1
fi
- echo "zeta" > $testroot/content.expected
- cat $testroot/wt/epsilon/zeta > $testroot/content
+ (cd $testroot/wt && got add -RI tree1 > $testroot/stdout)
- cmp -s $testroot/content.expected $testroot/content
+ echo 'A tree1/foo' > $testroot/stdout.expected
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
if [ "$ret" != "0" ]; then
- diff -u $testroot/content.expected $testroot/content
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
fi
+
+ (cd $testroot/wt && got add tree2/foo > $testroot/stdout)
+
+ echo 'A tree2/foo' > $testroot/stdout.expected
+
+ 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_done "$testroot" "$ret"
}