Skip to content

Commit

Permalink
Add configuration option for default untracked files mode
Browse files Browse the repository at this point in the history
By default, the untracked files mode for commit/status is 'normal'

Signed-off-by: Marius Storm-Olsen <marius@trolltech.com>
  • Loading branch information
Marius Storm-Olsen authored and Junio C Hamano committed Jun 9, 2008
1 parent 6c2ce04 commit d6293d1
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,25 @@ status.relativePaths::
relative to the repository root (this was the default for git
prior to v1.5.4).

status.showUntrackedFiles::
By default, linkgit:git-status[1] and linkgit:git-commit[1] show
files which are not currently tracked by Git. Directories which
contain only untracked files, are shown with the directory name
only. Showing untracked files means that Git needs to lstat() all
all the files in the whole repository, which might be slow on some
systems. So, this variable controls how the commands displays
the untracked files. Possible values are:
+
--
- 'no' - Show no untracked files
- 'normal' - Shows untracked files and directories
- 'all' - Shows also individual files in untracked directories.
--
+
If this variable is not specified, it defaults to 'normal'.
This variable can be overridden with the -u|--untracked-files option
of linkgit:git-status[1] and linkgit:git-commit[1].

tar.umask::
This variable can be used to restrict the permission bits of
tar archive entries. The default is 0002, which turns off the
Expand Down
4 changes: 4 additions & 0 deletions Documentation/git-commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ the handling of untracked files. The possible options are:
- 'normal' - Shows untracked files and directories
- 'all' - Also shows individual files in untracked directories.
--
+
See linkgit:git-config[1] for configuration variable
used to change the default for when the option is not
specified.

-v|--verbose::
Show unified diff between the HEAD commit and what
Expand Down
18 changes: 18 additions & 0 deletions t/t7502-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ test_expect_success 'status -uno' '
test_cmp expect output
'

test_expect_success 'status (status.showUntrackedFiles no)' '
git config status.showuntrackedfiles no
git status >output &&
test_cmp expect output
'

cat >expect <<EOF
# On branch master
# Changes to be committed:
Expand Down Expand Up @@ -117,6 +123,12 @@ test_expect_success 'status -unormal' '
test_cmp expect output
'

test_expect_success 'status (status.showUntrackedFiles normal)' '
git config status.showuntrackedfiles normal
git status >output &&
test_cmp expect output
'

cat >expect <<EOF
# On branch master
# Changes to be committed:
Expand All @@ -143,7 +155,13 @@ cat >expect <<EOF
EOF
test_expect_success 'status -uall' '
git status -uall >output &&
test_cmp expect output
'
test_expect_success 'status (status.showUntrackedFiles all)' '
git config status.showuntrackedfiles all
git status >output &&
rm -rf dir3 &&
git config --unset status.showuntrackedfiles &&
test_cmp expect output
'

Expand Down
13 changes: 13 additions & 0 deletions wt-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,18 @@ int git_status_config(const char *k, const char *v, void *cb)
wt_status_relative_paths = git_config_bool(k, v);
return 0;
}
if (!strcmp(k, "status.showuntrackedfiles")) {
if (!v)
return config_error_nonbool(v);
else if (!strcmp(v, "no"))
show_untracked_files = SHOW_NO_UNTRACKED_FILES;
else if (!strcmp(v, "normal"))
show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
else if (!strcmp(v, "all"))
show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
else
return error("Invalid untracked files mode '%s'", v);
return 0;
}
return git_color_default_config(k, v, cb);
}

0 comments on commit d6293d1

Please sign in to comment.