Merge branch 'master' of git://repo.or.cz/git/fastimport
authorJunio C Hamano <junkio@cox.net>
Mon, 12 Feb 2007 04:34:57 +0000 (20:34 -0800)
committerJunio C Hamano <junkio@cox.net>
Mon, 12 Feb 2007 04:34:57 +0000 (20:34 -0800)
* 'master' of git://repo.or.cz/git/fastimport:
bash: Hide git-fast-import.
fast-import: Add tip about importing renames.
fast-import: Hide the pack boundary commits by default.

Documentation/Makefile
Documentation/config.txt
Documentation/git-am.txt
Documentation/git-repack.txt
diff.c
git-svn.perl
git.c
gitk
help.c
t/t4016-diff-quote.sh [new file with mode: 0755]
index 266af47176a7f09000ed90f43b5ed83af74db8ea..aaf95918c3cb0e89b9c608e1df4eb548f38203d7 100644 (file)
@@ -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
index 4e650af01af9e0c528805b472e6970e5e24322e4..0129b1fd69ff4b8a82c09b5fc10fb7a999da919f 100644 (file)
@@ -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].
index f7d551e2c71ebee44762ea11b161632c4dab4e65..77ef103b21ed7c8864cf05c08efe3ae562357f55 100644 (file)
@@ -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.
index 4a57ce86017b42519a63532cb59284f28a36dfee..d39abc126dec70108625af13d11541b771c8e85d 100644 (file)
@@ -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
diff --git a/diff.c b/diff.c
index ad476f7c689262ce54c761615eac1d82355b33f9..aaab3095a5f44d5d835bda4bc60112481bf94ed9 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -545,6 +545,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;
@@ -701,12 +719,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);
@@ -838,7 +858,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
@@ -2191,13 +2211,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);
 }
@@ -2404,24 +2424,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);
@@ -2430,34 +2455,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);
 }
 
@@ -2478,8 +2480,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;
index 8ebaae9ff8865ab638f7a2db8c64f2d22f227470..d792a62d7ca400145d57189b5ca8af97978fef4d 100755 (executable)
@@ -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;
                        }
                }
diff --git a/git.c b/git.c
index 82a8357272bee1ad6d452a19bf9270f94d94a6cc..45265f14d0cc225dedcae84b7e2ef5700b966f20 100644 (file)
--- a/git.c
+++ b/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,
@@ -387,8 +397,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));
diff --git a/gitk b/gitk
index 1c36235bff8c127faa60eca051f15f35fb14f484..df1ce8cbbd3625d10e4660eb14c02ea9496c513b 100755 (executable)
--- a/gitk
+++ b/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 .
 }
 
diff --git a/help.c b/help.c
index 341b9e370eec4fa90014249a63afac17b083b275..b6674635a2e08197cc13aaa6acbe6290a303d6b3 100644 (file)
--- a/help.c
+++ b/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)");
diff --git a/t/t4016-diff-quote.sh b/t/t4016-diff-quote.sh
new file mode 100755 (executable)
index 0000000..edde8f5
--- /dev/null
@@ -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