mirror of
https://github.com/git/git.git
synced 2026-03-16 11:40:07 +01:00
Merge branch 'master' into next
* master: Document that git-am can read standard input. Make gitk save and restore the user set window position. t4016: test quoting funny pathnames in diff output diff.c: More logical file name quoting for renames in diffstat. diff.c: Properly quote file names in diff --summary output. diff.c: Reuse the pprint_rename function for diff --summary output. Make it easier to override path to asciidoc command Avoid ugly linewrap in git help Fixed some typos in git-repack docs git-svn: correctly handle boolean options via git-config Allow aliases to expand to shell commands Print a sane error message if an alias expands to an invalid git command diff_flush_name(): take struct diff_options parameter.
This commit is contained in:
@@ -31,6 +31,7 @@ man1dir=$(mandir)/man1
|
||||
man7dir=$(mandir)/man7
|
||||
# DESTDIR=
|
||||
|
||||
ASCIIDOC=asciidoc
|
||||
INSTALL?=install
|
||||
DOC_REF = origin/man
|
||||
|
||||
@@ -91,16 +92,16 @@ clean:
|
||||
rm -f $(cmds_txt)
|
||||
|
||||
%.html : %.txt
|
||||
asciidoc -b xhtml11 -d manpage -f asciidoc.conf $<
|
||||
$(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf $<
|
||||
|
||||
%.1 %.7 : %.xml
|
||||
xmlto -m callouts.xsl man $<
|
||||
|
||||
%.xml : %.txt
|
||||
asciidoc -b docbook -d manpage -f asciidoc.conf $<
|
||||
$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf $<
|
||||
|
||||
user-manual.xml: user-manual.txt user-manual.conf
|
||||
asciidoc -b docbook -d book $<
|
||||
$(ASCIIDOC) -b docbook -d book $<
|
||||
|
||||
user-manual.html: user-manual.xml
|
||||
xmlto html-nochunks $<
|
||||
@@ -108,7 +109,7 @@ user-manual.html: user-manual.xml
|
||||
glossary.html : glossary.txt sort_glossary.pl
|
||||
cat $< | \
|
||||
perl sort_glossary.pl | \
|
||||
asciidoc -b xhtml11 - > glossary.html
|
||||
$(ASCIIDOC) -b xhtml11 - > glossary.html
|
||||
|
||||
howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
|
||||
rm -f $@+ $@
|
||||
@@ -116,13 +117,13 @@ howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
|
||||
mv $@+ $@
|
||||
|
||||
$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
|
||||
asciidoc -b xhtml11 $*.txt
|
||||
$(ASCIIDOC) -b xhtml11 $*.txt
|
||||
|
||||
WEBDOC_DEST = /pub/software/scm/git/docs
|
||||
|
||||
$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
|
||||
rm -f $@+ $@
|
||||
sed -e '1,/^$$/d' $< | asciidoc -b xhtml11 - >$@+
|
||||
sed -e '1,/^$$/d' $< | $(ASCIIDOC) -b xhtml11 - >$@+
|
||||
mv $@+ $@
|
||||
|
||||
install-webdoc : html
|
||||
|
||||
@@ -222,6 +222,12 @@ alias.*::
|
||||
spaces, the usual shell quoting and escaping is supported.
|
||||
quote pair and a backslash can be used to quote them.
|
||||
|
||||
If the alias expansion is prefixed with an exclamation point,
|
||||
it will be treated as a shell command. For example, defining
|
||||
"alias.new = !gitk --all --not ORIG_HEAD", the invocation
|
||||
"git new" is equivalent to running the shell command
|
||||
"gitk --all --not ORIG_HEAD".
|
||||
|
||||
apply.whitespace::
|
||||
Tells `git-apply` how to handle whitespaces, in the same way
|
||||
as the '--whitespace' option. See gitlink:git-apply[1].
|
||||
|
||||
@@ -21,6 +21,10 @@ current branch.
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
<mbox>...::
|
||||
The list of mailbox files to read patches from. If you do not
|
||||
supply this argument, reads from the standard input.
|
||||
|
||||
--signoff::
|
||||
Add `Signed-off-by:` line to the commit message, using
|
||||
the committer identity of yourself.
|
||||
|
||||
@@ -30,9 +30,9 @@ OPTIONS
|
||||
Instead of incrementally packing the unpacked objects,
|
||||
pack everything available into a single pack.
|
||||
Especially useful when packing a repository that is used
|
||||
for a private development and there no need to worry
|
||||
about people fetching via dumb protocols from it. Use
|
||||
with '-d'.
|
||||
for private development and there is no need to worry
|
||||
about people fetching via dumb file transfer protocols
|
||||
from it. Use with '-d'.
|
||||
|
||||
-d::
|
||||
After packing, if the newly created packs make some
|
||||
|
||||
90
diff.c
90
diff.c
@@ -559,6 +559,24 @@ static char *pprint_rename(const char *a, const char *b)
|
||||
int pfx_length, sfx_length;
|
||||
int len_a = strlen(a);
|
||||
int len_b = strlen(b);
|
||||
int qlen_a = quote_c_style(a, NULL, NULL, 0);
|
||||
int qlen_b = quote_c_style(b, NULL, NULL, 0);
|
||||
|
||||
if (qlen_a || qlen_b) {
|
||||
if (qlen_a) len_a = qlen_a;
|
||||
if (qlen_b) len_b = qlen_b;
|
||||
name = xmalloc( len_a + len_b + 5 );
|
||||
if (qlen_a)
|
||||
quote_c_style(a, name, NULL, 0);
|
||||
else
|
||||
memcpy(name, a, len_a);
|
||||
memcpy(name + len_a, " => ", 4);
|
||||
if (qlen_b)
|
||||
quote_c_style(b, name + len_a + 4, NULL, 0);
|
||||
else
|
||||
memcpy(name + len_a + 4, b, len_b + 1);
|
||||
return name;
|
||||
}
|
||||
|
||||
/* Find common prefix */
|
||||
pfx_length = 0;
|
||||
@@ -715,12 +733,14 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)
|
||||
struct diffstat_file *file = data->files[i];
|
||||
int change = file->added + file->deleted;
|
||||
|
||||
len = quote_c_style(file->name, NULL, NULL, 0);
|
||||
if (len) {
|
||||
char *qname = xmalloc(len + 1);
|
||||
quote_c_style(file->name, qname, NULL, 0);
|
||||
free(file->name);
|
||||
file->name = qname;
|
||||
if (!file->is_renamed) { /* renames are already quoted by pprint_rename */
|
||||
len = quote_c_style(file->name, NULL, NULL, 0);
|
||||
if (len) {
|
||||
char *qname = xmalloc(len + 1);
|
||||
quote_c_style(file->name, qname, NULL, 0);
|
||||
free(file->name);
|
||||
file->name = qname;
|
||||
}
|
||||
}
|
||||
|
||||
len = strlen(file->name);
|
||||
@@ -852,7 +872,7 @@ static void show_numstat(struct diffstat_t* data, struct diff_options *options)
|
||||
printf("-\t-\t");
|
||||
else
|
||||
printf("%d\t%d\t", file->added, file->deleted);
|
||||
if (options->line_termination &&
|
||||
if (options->line_termination && !file->is_renamed &&
|
||||
quote_c_style(file->name, NULL, NULL, 0))
|
||||
quote_c_style(file->name, NULL, stdout, 0);
|
||||
else
|
||||
@@ -2205,13 +2225,13 @@ static void diff_flush_raw(struct diff_filepair *p,
|
||||
free((void*)path_two);
|
||||
}
|
||||
|
||||
static void diff_flush_name(struct diff_filepair *p, int line_termination)
|
||||
static void diff_flush_name(struct diff_filepair *p, struct diff_options *opt)
|
||||
{
|
||||
char *path = p->two->path;
|
||||
|
||||
if (line_termination)
|
||||
if (opt->line_termination)
|
||||
path = quote_one(p->two->path);
|
||||
printf("%s%c", path, line_termination);
|
||||
printf("%s%c", path, opt->line_termination);
|
||||
if (p->two->path != path)
|
||||
free(path);
|
||||
}
|
||||
@@ -2418,24 +2438,29 @@ static void flush_one_pair(struct diff_filepair *p, struct diff_options *opt)
|
||||
else if (fmt & (DIFF_FORMAT_RAW | DIFF_FORMAT_NAME_STATUS))
|
||||
diff_flush_raw(p, opt);
|
||||
else if (fmt & DIFF_FORMAT_NAME)
|
||||
diff_flush_name(p, opt->line_termination);
|
||||
diff_flush_name(p, opt);
|
||||
}
|
||||
|
||||
static void show_file_mode_name(const char *newdelete, struct diff_filespec *fs)
|
||||
{
|
||||
char *name = quote_one(fs->path);
|
||||
if (fs->mode)
|
||||
printf(" %s mode %06o %s\n", newdelete, fs->mode, fs->path);
|
||||
printf(" %s mode %06o %s\n", newdelete, fs->mode, name);
|
||||
else
|
||||
printf(" %s %s\n", newdelete, fs->path);
|
||||
printf(" %s %s\n", newdelete, name);
|
||||
free(name);
|
||||
}
|
||||
|
||||
|
||||
static void show_mode_change(struct diff_filepair *p, int show_name)
|
||||
{
|
||||
if (p->one->mode && p->two->mode && p->one->mode != p->two->mode) {
|
||||
if (show_name)
|
||||
if (show_name) {
|
||||
char *name = quote_one(p->two->path);
|
||||
printf(" mode change %06o => %06o %s\n",
|
||||
p->one->mode, p->two->mode, p->two->path);
|
||||
p->one->mode, p->two->mode, name);
|
||||
free(name);
|
||||
}
|
||||
else
|
||||
printf(" mode change %06o => %06o\n",
|
||||
p->one->mode, p->two->mode);
|
||||
@@ -2444,34 +2469,11 @@ static void show_mode_change(struct diff_filepair *p, int show_name)
|
||||
|
||||
static void show_rename_copy(const char *renamecopy, struct diff_filepair *p)
|
||||
{
|
||||
const char *old, *new;
|
||||
char *names = pprint_rename(p->one->path, p->two->path);
|
||||
|
||||
/* Find common prefix */
|
||||
old = p->one->path;
|
||||
new = p->two->path;
|
||||
while (1) {
|
||||
const char *slash_old, *slash_new;
|
||||
slash_old = strchr(old, '/');
|
||||
slash_new = strchr(new, '/');
|
||||
if (!slash_old ||
|
||||
!slash_new ||
|
||||
slash_old - old != slash_new - new ||
|
||||
memcmp(old, new, slash_new - new))
|
||||
break;
|
||||
old = slash_old + 1;
|
||||
new = slash_new + 1;
|
||||
}
|
||||
/* p->one->path thru old is the common prefix, and old and new
|
||||
* through the end of names are renames
|
||||
*/
|
||||
if (old != p->one->path)
|
||||
printf(" %s %.*s{%s => %s} (%d%%)\n", renamecopy,
|
||||
(int)(old - p->one->path), p->one->path,
|
||||
old, new, (int)(0.5 + p->score * 100.0/MAX_SCORE));
|
||||
else
|
||||
printf(" %s %s => %s (%d%%)\n", renamecopy,
|
||||
p->one->path, p->two->path,
|
||||
(int)(0.5 + p->score * 100.0/MAX_SCORE));
|
||||
printf(" %s %s (%d%%)\n", renamecopy, names,
|
||||
(int)(0.5 + p->score * 100.0/MAX_SCORE));
|
||||
free(names);
|
||||
show_mode_change(p, 0);
|
||||
}
|
||||
|
||||
@@ -2492,8 +2494,10 @@ static void diff_summary(struct diff_filepair *p)
|
||||
break;
|
||||
default:
|
||||
if (p->score) {
|
||||
printf(" rewrite %s (%d%%)\n", p->two->path,
|
||||
char *name = quote_one(p->two->path);
|
||||
printf(" rewrite %s (%d%%)\n", name,
|
||||
(int)(0.5 + p->score * 100.0/MAX_SCORE));
|
||||
free(name);
|
||||
show_mode_change(p, 0);
|
||||
} else show_mode_change(p, 1);
|
||||
break;
|
||||
|
||||
@@ -1610,7 +1610,7 @@ sub read_repo_config {
|
||||
@$v = @tmp if @tmp;
|
||||
} else {
|
||||
chomp(my $tmp = `$arg --get svn.$key`);
|
||||
if ($tmp && !($arg =~ / --bool / && $tmp eq 'false')) {
|
||||
if ($tmp && !($arg =~ / --bool/ && $tmp eq 'false')) {
|
||||
$$v = $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
19
git.c
19
git.c
@@ -159,6 +159,16 @@ static int handle_alias(int *argcp, const char ***argv)
|
||||
alias_command = (*argv)[0];
|
||||
git_config(git_alias_config);
|
||||
if (alias_string) {
|
||||
if (alias_string[0] == '!') {
|
||||
trace_printf("trace: alias to shell cmd: %s => %s\n",
|
||||
alias_command, alias_string + 1);
|
||||
ret = system(alias_string + 1);
|
||||
if (ret >= 0 && WIFEXITED(ret) &&
|
||||
WEXITSTATUS(ret) != 127)
|
||||
exit(WEXITSTATUS(ret));
|
||||
die("Failed to run '%s' when expanding alias '%s'\n",
|
||||
alias_string + 1, alias_command);
|
||||
}
|
||||
count = split_cmdline(alias_string, &new_argv);
|
||||
option_count = handle_options(&new_argv, &count);
|
||||
memmove(new_argv - option_count, new_argv,
|
||||
@@ -388,8 +398,15 @@ int main(int argc, const char **argv, char **envp)
|
||||
done_alias = 1;
|
||||
}
|
||||
|
||||
if (errno == ENOENT)
|
||||
if (errno == ENOENT) {
|
||||
if (done_alias) {
|
||||
fprintf(stderr, "Expansion of alias '%s' failed; "
|
||||
"'%s' is not a git-command\n",
|
||||
cmd, argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
help_unknown_cmd(cmd);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Failed to run command '%s': %s\n",
|
||||
cmd, strerror(errno));
|
||||
|
||||
11
gitk
11
gitk
@@ -725,7 +725,7 @@ proc makewindow {} {
|
||||
bind . <Control-KP_Add> {incrfont 1}
|
||||
bind . <Control-minus> {incrfont -1}
|
||||
bind . <Control-KP_Subtract> {incrfont -1}
|
||||
bind . <Destroy> {savestuff %W}
|
||||
wm protocol . WM_DELETE_WINDOW doquit
|
||||
bind . <Button-1> "click %W"
|
||||
bind $fstring <Key-Return> dofind
|
||||
bind $sha1entry <Key-Return> gotocommit
|
||||
@@ -829,12 +829,12 @@ proc savestuff {w} {
|
||||
puts $f [list set colors $colors]
|
||||
puts $f [list set diffcolors $diffcolors]
|
||||
|
||||
puts $f "set geometry(main) [winfo geometry .]"
|
||||
puts $f "set geometry(main) [wm geometry .]"
|
||||
puts $f "set geometry(topwidth) [winfo width .tf]"
|
||||
puts $f "set geometry(topheight) [winfo height .tf]"
|
||||
puts $f "set geometry(canv) [expr {[winfo width $canv]-0}]"
|
||||
puts $f "set geometry(canv2) [expr {[winfo width $canv2]-0}]"
|
||||
puts $f "set geometry(canv3) [expr {[winfo width $canv3]-0}]"
|
||||
puts $f "set geometry(canv) [winfo width $canv]"
|
||||
puts $f "set geometry(canv2) [winfo width $canv2]"
|
||||
puts $f "set geometry(canv3) [winfo width $canv3]"
|
||||
puts $f "set geometry(botwidth) [winfo width .bleft]"
|
||||
puts $f "set geometry(botheight) [winfo height .bleft]"
|
||||
|
||||
@@ -5800,6 +5800,7 @@ proc showtag {tag isnew} {
|
||||
proc doquit {} {
|
||||
global stopped
|
||||
set stopped 100
|
||||
savestuff .
|
||||
destroy .
|
||||
}
|
||||
|
||||
|
||||
4
help.c
4
help.c
@@ -168,8 +168,8 @@ static void list_common_cmds_help(void)
|
||||
|
||||
puts("The most commonly used git commands are:");
|
||||
for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
|
||||
printf(" %s", common_cmds[i].name);
|
||||
mput_char(' ', longest - strlen(common_cmds[i].name) + 4);
|
||||
printf(" %s ", common_cmds[i].name);
|
||||
mput_char(' ', longest - strlen(common_cmds[i].name));
|
||||
puts(common_cmds[i].help);
|
||||
}
|
||||
puts("(use 'git help -a' to get a list of all installed git commands)");
|
||||
|
||||
66
t/t4016-diff-quote.sh
Executable file
66
t/t4016-diff-quote.sh
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2007 Junio C Hamano
|
||||
#
|
||||
|
||||
test_description='Quoting paths in diff output.
|
||||
'
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
P0='pathname'
|
||||
P1='pathname with HT'
|
||||
P2='pathname with SP'
|
||||
P3='pathname
|
||||
with LF'
|
||||
|
||||
test_expect_success setup '
|
||||
echo P0.0 >"$P0.0" &&
|
||||
echo P0.1 >"$P0.1" &&
|
||||
echo P0.2 >"$P0.2" &&
|
||||
echo P0.3 >"$P0.3" &&
|
||||
echo P1.0 >"$P1.0" &&
|
||||
echo P1.2 >"$P1.2" &&
|
||||
echo P1.3 >"$P1.3" &&
|
||||
git add . &&
|
||||
git commit -m initial &&
|
||||
git mv "$P0.0" "R$P0.0" &&
|
||||
git mv "$P0.1" "R$P1.0" &&
|
||||
git mv "$P0.2" "R$P2.0" &&
|
||||
git mv "$P0.3" "R$P3.0" &&
|
||||
git mv "$P1.0" "R$P0.1" &&
|
||||
git mv "$P1.2" "R$P2.1" &&
|
||||
git mv "$P1.3" "R$P3.1" &&
|
||||
:
|
||||
'
|
||||
|
||||
cat >expect <<\EOF
|
||||
rename pathname.1 => "Rpathname\twith HT.0" (100%)
|
||||
rename pathname.3 => "Rpathname\nwith LF.0" (100%)
|
||||
rename "pathname\twith HT.3" => "Rpathname\nwith LF.1" (100%)
|
||||
rename pathname.2 => Rpathname with SP.0 (100%)
|
||||
rename "pathname\twith HT.2" => Rpathname with SP.1 (100%)
|
||||
rename pathname.0 => Rpathname.0 (100%)
|
||||
rename "pathname\twith HT.0" => Rpathname.1 (100%)
|
||||
EOF
|
||||
test_expect_success 'git diff --summary -M HEAD' '
|
||||
git diff --summary -M HEAD >actual &&
|
||||
diff -u expect actual
|
||||
'
|
||||
|
||||
cat >expect <<\EOF
|
||||
pathname.1 => "Rpathname\twith HT.0" | 0
|
||||
pathname.3 => "Rpathname\nwith LF.0" | 0
|
||||
"pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0
|
||||
pathname.2 => Rpathname with SP.0 | 0
|
||||
"pathname\twith HT.2" => Rpathname with SP.1 | 0
|
||||
pathname.0 => Rpathname.0 | 0
|
||||
"pathname\twith HT.0" => Rpathname.1 | 0
|
||||
7 files changed, 0 insertions(+), 0 deletions(-)
|
||||
EOF
|
||||
test_expect_success 'git diff --stat -M HEAD' '
|
||||
git diff --stat -M HEAD >actual &&
|
||||
diff -u expect actual
|
||||
'
|
||||
|
||||
test_done
|
||||
Reference in New Issue
Block a user