Commit cd676a5
committed
diff --relative: output paths as relative to the current subdirectory
This adds --relative option to the diff family. When you start
from a subdirectory:
$ git diff --relative
shows only the diff that is inside your current subdirectory,
and without $prefix part. People who usually live in
subdirectories may like it.
There are a few things I should also mention about the change:
- This works not just with diff but also works with the log
family of commands, but the history pruning is not affected.
In other words, if you go to a subdirectory, you can say:
$ git log --relative -p
but it will show the log message even for commits that do not
touch the current directory. You can limit it by giving
pathspec yourself:
$ git log --relative -p .
This originally was not a conscious design choice, but we
have a way to affect diff pathspec and pruning pathspec
independently. IOW "git log --full-diff -p ." tells it to
prune history to commits that affect the current subdirectory
but show the changes with full context. I think it makes
more sense to leave pruning independent from --relative than
the obvious alternative of always pruning with the current
subdirectory, which would break the symmetry.
- Because this works also with the log family, you could
format-patch a single change, limiting the effect to your
subdirectory, like so:
$ cd gitk-git
$ git format-patch -1 --relative 911f1eb
But because that is a special purpose usage, this option will
never become the default, with or without repository or user
preference configuration. The risk of producing a partial
patch and sending it out by mistake is too great if we did
so.
- This is inherently incompatible with --no-index, which is a
bolted-on hack that does not have much to do with git
itself. I didn't bother checking and erroring out on the
combined use of the options, but probably I should.
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 7a2078b commit cd676a5
File tree
5 files changed
+105
-18
lines changed- Documentation
5 files changed
+105
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
173 | 178 | | |
174 | 179 | | |
175 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
46 | 52 | | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
51 | | - | |
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
| |||
241 | 246 | | |
242 | 247 | | |
243 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
244 | 253 | | |
245 | 254 | | |
246 | 255 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1397 | 1397 | | |
1398 | 1398 | | |
1399 | 1399 | | |
| 1400 | + | |
1400 | 1401 | | |
1401 | 1402 | | |
1402 | 1403 | | |
| |||
1411 | 1412 | | |
1412 | 1413 | | |
1413 | 1414 | | |
1414 | | - | |
| 1415 | + | |
1415 | 1416 | | |
1416 | 1417 | | |
1417 | 1418 | | |
| |||
1831 | 1832 | | |
1832 | 1833 | | |
1833 | 1834 | | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
1834 | 1838 | | |
1835 | 1839 | | |
1836 | 1840 | | |
| |||
1850 | 1854 | | |
1851 | 1855 | | |
1852 | 1856 | | |
| 1857 | + | |
1853 | 1858 | | |
1854 | 1859 | | |
1855 | 1860 | | |
| |||
1859 | 1864 | | |
1860 | 1865 | | |
1861 | 1866 | | |
1862 | | - | |
| 1867 | + | |
1863 | 1868 | | |
1864 | 1869 | | |
1865 | 1870 | | |
| |||
1900 | 1905 | | |
1901 | 1906 | | |
1902 | 1907 | | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
1903 | 1917 | | |
1904 | 1918 | | |
1905 | 1919 | | |
| |||
1909 | 1923 | | |
1910 | 1924 | | |
1911 | 1925 | | |
| 1926 | + | |
1912 | 1927 | | |
1913 | 1928 | | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
1914 | 1934 | | |
1915 | 1935 | | |
1916 | | - | |
| 1936 | + | |
| 1937 | + | |
1917 | 1938 | | |
1918 | 1939 | | |
1919 | 1940 | | |
1920 | | - | |
1921 | | - | |
1922 | 1941 | | |
1923 | 1942 | | |
1924 | 1943 | | |
| |||
1981 | 2000 | | |
1982 | 2001 | | |
1983 | 2002 | | |
1984 | | - | |
| 2003 | + | |
| 2004 | + | |
1985 | 2005 | | |
1986 | 2006 | | |
1987 | | - | |
| 2007 | + | |
| 2008 | + | |
1988 | 2009 | | |
1989 | 2010 | | |
1990 | 2011 | | |
1991 | | - | |
1992 | | - | |
| 2012 | + | |
| 2013 | + | |
1993 | 2014 | | |
1994 | 2015 | | |
1995 | 2016 | | |
| |||
2010 | 2031 | | |
2011 | 2032 | | |
2012 | 2033 | | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
2013 | 2037 | | |
2014 | 2038 | | |
2015 | 2039 | | |
| |||
2022 | 2046 | | |
2023 | 2047 | | |
2024 | 2048 | | |
| 2049 | + | |
2025 | 2050 | | |
2026 | 2051 | | |
2027 | 2052 | | |
| |||
2030 | 2055 | | |
2031 | 2056 | | |
2032 | 2057 | | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
2033 | 2062 | | |
2034 | 2063 | | |
2035 | 2064 | | |
2036 | 2065 | | |
2037 | | - | |
| 2066 | + | |
2038 | 2067 | | |
2039 | 2068 | | |
2040 | 2069 | | |
| |||
2076 | 2105 | | |
2077 | 2106 | | |
2078 | 2107 | | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
2079 | 2115 | | |
2080 | 2116 | | |
2081 | 2117 | | |
| |||
2264 | 2300 | | |
2265 | 2301 | | |
2266 | 2302 | | |
| 2303 | + | |
| 2304 | + | |
2267 | 2305 | | |
2268 | 2306 | | |
2269 | 2307 | | |
| |||
2475 | 2513 | | |
2476 | 2514 | | |
2477 | 2515 | | |
2478 | | - | |
2479 | | - | |
2480 | | - | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
2481 | 2524 | | |
2482 | | - | |
2483 | | - | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
| 2529 | + | |
2484 | 2530 | | |
2485 | 2531 | | |
2486 | 2532 | | |
| |||
2677 | 2723 | | |
2678 | 2724 | | |
2679 | 2725 | | |
2680 | | - | |
2681 | | - | |
| 2726 | + | |
| 2727 | + | |
| 2728 | + | |
| 2729 | + | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
2682 | 2733 | | |
2683 | 2734 | | |
2684 | 2735 | | |
| |||
3164 | 3215 | | |
3165 | 3216 | | |
3166 | 3217 | | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
| 3221 | + | |
| 3222 | + | |
3167 | 3223 | | |
3168 | 3224 | | |
3169 | 3225 | | |
| |||
3193 | 3249 | | |
3194 | 3250 | | |
3195 | 3251 | | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
3196 | 3257 | | |
3197 | 3258 | | |
3198 | 3259 | | |
| |||
3207 | 3268 | | |
3208 | 3269 | | |
3209 | 3270 | | |
| 3271 | + | |
| 3272 | + | |
| 3273 | + | |
| 3274 | + | |
| 3275 | + | |
3210 | 3276 | | |
3211 | 3277 | | |
3212 | 3278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| |||
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| 86 | + | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
723 | 727 | | |
724 | 728 | | |
725 | 729 | | |
| |||
0 commit comments