diff options
author | Jonas Fonseca <jonas.fonseca@gmail.com> | 2014-03-16 23:25:45 -0400 |
---|---|---|
committer | Jonas Fonseca <jonas.fonseca@gmail.com> | 2014-03-16 23:29:45 -0400 |
commit | dd7db06f47c988d07037e0ce6917d21c61e8a288 (patch) | |
tree | c21e7078f6efc5b4b882fce0f71436cecd9ca267 | |
parent | 16af2ac7bf08fe6fbdddc896fdd596851324d1c1 (diff) |
status: fix staging of untracked directories
When status-update is used on an untracked directory the whole directory
is staged using git-add. This also fixes status listing to not list
empty directories when content of untracked directories is not
displayed.
Fixes #236
-rw-r--r-- | NEWS.adoc | 1 | ||||
-rw-r--r-- | src/status.c | 13 |
2 files changed, 12 insertions, 2 deletions
@@ -83,6 +83,7 @@ Bug fixes: - Fix rendering in non-UTF8 terminals. - Fix stage-update-line by rewriting the diff chunk containing the line instead of using `--unidiff-zero` and a diff context of zero. (GH #130) + - Fix status-update to work for untracked directories. (GH #236) tig-1.2.1 --------- diff --git a/src/status.c b/src/status.c index 9fc96378..4e345031 100644 --- a/src/status.c +++ b/src/status.c @@ -151,7 +151,7 @@ static const char *status_diff_index_argv[] = { GIT_DIFF_STAGED_FILES("-z") }; static const char *status_diff_files_argv[] = { GIT_DIFF_UNSTAGED_FILES("-z") }; static const char *status_list_other_argv[] = { - "git", "ls-files", "-z", "--others", "--exclude-standard", repo.prefix, NULL, NULL, + "git", "ls-files", "-z", "--others", "--exclude-standard", repo.prefix, NULL, NULL, NULL }; static const char *status_list_no_head_argv[] = { @@ -261,8 +261,10 @@ status_open(struct view *view, enum open_flags flags) io_run_bg(update_index_argv); - status_list_other_argv[ARRAY_SIZE(status_list_other_argv) - 2] = + status_list_other_argv[ARRAY_SIZE(status_list_other_argv) - 3] = opt_status_untracked_dirs ? NULL : "--directory"; + status_list_other_argv[ARRAY_SIZE(status_list_other_argv) - 2] = + opt_status_untracked_dirs ? NULL : "--no-empty-directory"; if (!status_run(view, staged_argv, staged_status, LINE_STAT_STAGED) || !status_run(view, status_diff_files_argv, 0, LINE_STAT_UNSTAGED) || @@ -446,9 +448,16 @@ status_update_write(struct io *io, struct status *status, enum line_type type) bool status_update_file(struct status *status, enum line_type type) { + const char *name = status->new.name; struct io io; bool result; + if (type == LINE_STAT_UNTRACKED && !suffixcmp(name, strlen(name), "/")) { + const char *add_argv[] = { "git", "add", "--", name, NULL }; + + return io_run_bg(add_argv); + } + if (!status_update_prepare(&io, type)) return FALSE; |