add status.relativePaths config variable
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>
Jeff King committed
Dec 7, 2007 at 16:26 UTC
46f721c8fee9f1c027f96e2bf987ce6e7d05ab94
6 files changed
+52
-2
Documentation/config.txt
+6
@@ -762,6 +762,12 @@ showbranch.default::
762
The default set of branches for gitlink:git-show-branch[1].
763
See gitlink:git-show-branch[1].
764
765
+status.relativePaths::
766
+ By default, gitlink:git-status[1] shows paths relative to the
767
+ current directory. Setting this variable to `false` shows paths
768
+ relative to the repository root (this was the default for git
769
+ prior to v1.5.4).
770
+
771
tar.umask::
772
This variable can be used to restrict the permission bits of
773
tar archive entries. The default is 0002, which turns off the
Documentation/git-status.txt
+6
-1
@@ -42,7 +42,8 @@ template comments, and all the output lines are prefixed with '#'.
42
43
The paths mentioned in the output, unlike many other git commands, are
44
made relative to the current directory, if you are working in a
45
-subdirectory (this is on purpose, to help cutting and pasting).
45
+subdirectory (this is on purpose, to help cutting and pasting). See
46
+the status.relativePaths config option below.
47
48
49
CONFIGURATION
@@ -53,6 +54,10 @@ mean the same thing and the latter is kept for backward
54
compatibility) and `color.status.<slot>` configuration variables
55
to colorize its output.
56
57
+If the config variable `status.relativePaths` is set to false, then all
58
+paths shown are relative to the repository root, not to the current
59
+directory.
60
+
61
See Also
62
--------
63
gitlink:gitignore[5]
builtin-commit.c
+2
-1
@@ -285,7 +285,8 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix)
285
struct wt_status s;
286
287
wt_status_prepare(&s);
288
- s.prefix = prefix;
288
+ if (wt_status_relative_paths)
289
+ s.prefix = prefix;
290
291
if (amend) {
292
s.amend = 1;
t/t7502-status.sh
+31
@@ -88,4 +88,35 @@ test_expect_success 'status with relative paths' '
88
89
'
90
91
+cat > expect << \EOF
92
+# On branch master
93
+# Changes to be committed:
94
+# (use "git reset HEAD <file>..." to unstage)
95
+#
96
+# new file: dir2/added
97
+#
98
+# Changed but not updated:
99
+# (use "git add <file>..." to update what will be committed)
100
+#
101
+# modified: dir1/modified
102
+#
103
+# Untracked files:
104
+# (use "git add <file>..." to include in what will be committed)
105
+#
106
+# dir1/untracked
107
+# dir2/modified
108
+# dir2/untracked
109
+# expect
110
+# output
111
+# untracked
112
+EOF
113
+
114
+test_expect_success 'status without relative paths' '
115
+
116
+ git config status.relativePaths false
117
+ (cd dir1 && git status) > output &&
118
+ git diff expect output
119
+
120
+'
121
+
122
test_done
wt-status.c
+6
@@ -8,6 +8,7 @@
8
#include "revision.h"
9
#include "diffcore.h"
10
11
+int wt_status_relative_paths = 1;
12
int wt_status_use_color = 0;
13
static char wt_status_colors[][COLOR_MAXLEN] = {
14
"", /* WT_STATUS_HEADER: normal */
@@ -400,6 +401,11 @@ int git_status_config(const char *k, const char *v)
401
if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
402
int slot = parse_status_slot(k, 13);
403
color_parse(v, k, wt_status_colors[slot]);
404
+ return 0;
405
+ }
406
+ if (!strcmp(k, "status.relativepaths")) {
407
+ wt_status_relative_paths = git_config_bool(k, v);
408
+ return 0;
409
}
410
return git_default_config(k, v);
411
}
wt-status.h
+1
@@ -28,6 +28,7 @@ struct wt_status {
28
29
int git_status_config(const char *var, const char *value);
30
int wt_status_use_color;
31
+int wt_status_relative_paths;
32
void wt_status_prepare(struct wt_status *s);
33
void wt_status_print(struct wt_status *s);
34