Skip to content

Commit

Permalink
add status.relativePaths config variable
Browse files Browse the repository at this point in the history
The output of git-status was recently changed to output relative
paths. Setting this variable to false restores the old behavior for
any old-timers that prefer it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Dec 8, 2007
1 parent c3ce326 commit 46f721c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,12 @@ showbranch.default::
The default set of branches for gitlink:git-show-branch[1].
See gitlink:git-show-branch[1].

status.relativePaths::
By default, gitlink:git-status[1] shows paths relative to the
current directory. Setting this variable to `false` shows paths
relative to the repository root (this was the default for git
prior to v1.5.4).

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
7 changes: 6 additions & 1 deletion Documentation/git-status.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ template comments, and all the output lines are prefixed with '#'.

The paths mentioned in the output, unlike many other git commands, are
made relative to the current directory, if you are working in a
subdirectory (this is on purpose, to help cutting and pasting).
subdirectory (this is on purpose, to help cutting and pasting). See
the status.relativePaths config option below.


CONFIGURATION
Expand All @@ -53,6 +54,10 @@ mean the same thing and the latter is kept for backward
compatibility) and `color.status.<slot>` configuration variables
to colorize its output.

If the config variable `status.relativePaths` is set to false, then all
paths shown are relative to the repository root, not to the current
directory.

See Also
--------
gitlink:gitignore[5]
Expand Down
3 changes: 2 additions & 1 deletion builtin-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix)
struct wt_status s;

wt_status_prepare(&s);
s.prefix = prefix;
if (wt_status_relative_paths)
s.prefix = prefix;

if (amend) {
s.amend = 1;
Expand Down
31 changes: 31 additions & 0 deletions t/t7502-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,35 @@ test_expect_success 'status with relative paths' '
'

cat > expect << \EOF
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: dir2/added
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
#
# modified: dir1/modified
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# dir1/untracked
# dir2/modified
# dir2/untracked
# expect
# output
# untracked
EOF

test_expect_success 'status without relative paths' '
git config status.relativePaths false
(cd dir1 && git status) > output &&
git diff expect output
'

test_done
6 changes: 6 additions & 0 deletions wt-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "revision.h"
#include "diffcore.h"

int wt_status_relative_paths = 1;
int wt_status_use_color = 0;
static char wt_status_colors[][COLOR_MAXLEN] = {
"", /* WT_STATUS_HEADER: normal */
Expand Down Expand Up @@ -400,6 +401,11 @@ int git_status_config(const char *k, const char *v)
if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
int slot = parse_status_slot(k, 13);
color_parse(v, k, wt_status_colors[slot]);
return 0;
}
if (!strcmp(k, "status.relativepaths")) {
wt_status_relative_paths = git_config_bool(k, v);
return 0;
}
return git_default_config(k, v);
}
1 change: 1 addition & 0 deletions wt-status.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct wt_status {

int git_status_config(const char *var, const char *value);
int wt_status_use_color;
int wt_status_relative_paths;
void wt_status_prepare(struct wt_status *s);
void wt_status_print(struct wt_status *s);

Expand Down

0 comments on commit 46f721c

Please sign in to comment.