]> asedeno.scripts.mit.edu Git - git.git/commitdiff
Merge branch 'maint'
authorJunio C Hamano <junkio@cox.net>
Thu, 5 Apr 2007 23:34:51 +0000 (16:34 -0700)
committerJunio C Hamano <junkio@cox.net>
Thu, 5 Apr 2007 23:34:51 +0000 (16:34 -0700)
* maint:
  Fix lseek(2) calls with args 2 and 3 swapped
  Honor -p<n> when applying git diffs
  Fix dependency of common-cmds.h
  Fix renaming branch without config file
  DESTDIR support for git/contrib/emacs
  gitweb: Fix bug in "blobdiff" view for split (e.g. file to symlink) patches
  Document --left-right option to rev-list.
  Revert "builtin-archive: use RUN_SETUP"
  rename contrib/hooks/post-receieve-email to contrib/hooks/post-receive-email.
  rerere: make sorting really stable.
  Fix t4200-rerere for white-space from "wc -l"

17 files changed:
Documentation/git-rev-list.txt
Makefile
builtin-apply.c
builtin-archive.c
builtin-rerere.c
builtin-rev-list.c
config.c
contrib/emacs/Makefile
contrib/hooks/post-receive-email [moved from contrib/hooks/post-receieve-email with 100% similarity]
git.c
gitweb/gitweb.perl
http-fetch.c
http-push.c
t/t3200-branch.sh
t/t4120-apply-popt.sh [new file with mode: 0755]
t/t4200-rerere.sh
t/t5000-tar-tree.sh

index 3fa45b81cc6de7b5104d343538c9ad040c208ce1..12b71ed0bbae2516cb67c98c96a56e6278a6f5c2 100644 (file)
@@ -21,6 +21,7 @@ SYNOPSIS
             [ \--stdin ]
             [ \--topo-order ]
             [ \--parents ]
+            [ \--left-right ]
             [ \--encoding[=<encoding>] ]
             [ \--(author|committer|grep)=<pattern> ]
             [ [\--objects | \--objects-edge] [ \--unpacked ] ]
@@ -101,6 +102,36 @@ include::pretty-formats.txt[]
 
        Print the parents of the commit.
 
+--left-right::
+
+       Mark which side of a symmetric diff a commit is reachable from.
+       Commits from the left side are prefixed with `<` and those from
+       the right with `>`.  If combined with `--boundary`, those
+       commits are prefixed with `-`.
++
+For example, if you have this topology:
++
+-----------------------------------------------------------------------
+             y---b---b  branch B
+            / \ /
+           /   .
+          /   / \
+         o---x---a---a  branch A
+-----------------------------------------------------------------------
++
+you would get an output line this:
++
+-----------------------------------------------------------------------
+       $ git rev-list --left-right --boundary --pretty=oneline A...B
+
+       >bbbbbbb... 3rd on b
+       >bbbbbbb... 2nd on b
+       <aaaaaaa... 3rd on a
+       <aaaaaaa... 2nd on a
+       -yyyyyyy... 1st on b
+       -xxxxxxx... 1st on a
+-----------------------------------------------------------------------
+
 Diff Formatting
 ~~~~~~~~~~~~~~~
 
index 507ad9103e73b275ed00f3e9099d9699affa868f..45dbcf6edff9d907836aa2208dd59c12c4b6ec03 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -727,7 +727,7 @@ help.o: common-cmds.h
 $(BUILT_INS): git$X
        $(QUIET_BUILT_IN)rm -f $@ && ln git$X $@
 
-common-cmds.h: Documentation/git-*.txt
+common-cmds.h: $(wildcard Documentation/git-*.txt)
        $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
 
 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
index 6a8292e2a5448389fbe76d9d899cb1d066e2a996..4b8311b4de3f5c5d93352dac62856d67acfb143f 100644 (file)
@@ -417,7 +417,7 @@ static int gitdiff_hdrend(const char *line, struct patch *patch)
 static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name, const char *oldnew)
 {
        if (!orig_name && !isnull)
-               return find_name(line, NULL, 1, TERM_TAB);
+               return find_name(line, NULL, p_value, TERM_TAB);
 
        if (orig_name) {
                int len;
@@ -427,7 +427,7 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,
                len = strlen(name);
                if (isnull)
                        die("git-apply: bad git-diff - expected /dev/null, got %s on line %d", name, linenr);
-               another = find_name(line, NULL, 1, TERM_TAB);
+               another = find_name(line, NULL, p_value, TERM_TAB);
                if (!another || memcmp(another, name, len))
                        die("git-apply: bad git-diff - inconsistent %s filename on line %d", oldnew, linenr);
                free(another);
index 2fae885f5c27f73820824b612d41fd37ab91239d..8ea6cb1efc4f988fb09051852f9e51fc88b5efd7 100644 (file)
@@ -252,6 +252,8 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
 
        memset(&ar, 0, sizeof(ar));
        tree_idx = parse_archive_args(argc, argv, &ar);
+       if (prefix == NULL)
+               prefix = setup_git_directory();
 
        argv += tree_idx;
        parse_treeish_arg(argv, &ar.args, prefix);
index b463c07f04b127ee3d1e17962813367fb4a5a588..8c2c8bdc18a69e4dff7386548e5f7ea78a133f7b 100644 (file)
@@ -117,10 +117,13 @@ static int handle_file(const char *path,
                else if (!prefixcmp(buf, "======="))
                        hunk = 2;
                else if (!prefixcmp(buf, ">>>>>>> ")) {
+                       int one_is_longer = (one->nr > two->nr);
+                       int common_len = one_is_longer ? two->nr : one->nr;
+                       int cmp = memcmp(one->ptr, two->ptr, common_len);
+
                        hunk_no++;
                        hunk = 0;
-                       if (memcmp(one->ptr, two->ptr, one->nr < two->nr ?
-                                               one->nr : two->nr) > 0) {
+                       if ((cmp > 0) || ((cmp == 0) && one_is_longer)) {
                                struct buffer *swap = one;
                                one = two;
                                two = swap;
index f91685a4067630b49e6d9235f29ab8f8060faf66..09774f9559b81050d89bd6663b8b672438da4342 100644 (file)
@@ -35,6 +35,7 @@ static const char rev_list_usage[] =
 "    --header | --pretty\n"
 "    --abbrev=nr | --no-abbrev\n"
 "    --abbrev-commit\n"
+"    --left-right\n"
 "  special purpose:\n"
 "    --bisect\n"
 "    --bisect-vars"
index 6479855723d6dc94fa7c440868724a794bb59901..70d105567921fe75518d8d5fe3d3df4aad0659cd 100644 (file)
--- a/config.c
+++ b/config.c
@@ -916,8 +916,8 @@ int git_config_rename_section(const char *old_name, const char *new_name)
        }
 
        if (!(config_file = fopen(config_filename, "rb"))) {
-               ret = error("Could not open config file!");
-               goto out;
+               /* no config file means nothing to rename, no error */
+               goto unlock_and_out;
        }
 
        while (fgets(buf, sizeof(buf), config_file)) {
@@ -951,6 +951,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
                }
        }
        fclose(config_file);
+ unlock_and_out:
        if (close(out_fd) || commit_lock_file(lock) < 0)
                        ret = error("Cannot commit config file!");
  out:
index 8554e3967cc692c6916e5aee35952074d07e8bf0..98aa0aae9b2e9e4a758fa58e7dd1e1adc3214883 100644 (file)
@@ -11,8 +11,8 @@ emacsdir = $(prefix)/share/emacs/site-lisp
 all: $(ELC)
 
 install: all
-       $(INSTALL) -d $(emacsdir)
-       $(INSTALL_ELC) $(ELC) $(emacsdir)
+       $(INSTALL) -d $(DESTDIR)$(emacsdir)
+       $(INSTALL_ELC) $(ELC) $(DESTDIR)$(emacsdir)
 
 %.elc: %.el
        $(EMACS) -batch -f batch-byte-compile $<
diff --git a/git.c b/git.c
index 5b1bc2a895306157649e399d5bad9bb827935318..33dd4d39d907a229679a41f9712ee99007a34f3b 100644 (file)
--- a/git.c
+++ b/git.c
@@ -226,7 +226,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
                { "add", cmd_add, RUN_SETUP | NOT_BARE },
                { "annotate", cmd_annotate, USE_PAGER },
                { "apply", cmd_apply },
-               { "archive", cmd_archive, RUN_SETUP },
+               { "archive", cmd_archive },
                { "blame", cmd_blame, RUN_SETUP },
                { "branch", cmd_branch, RUN_SETUP },
                { "bundle", cmd_bundle },
index ea491562c80fbb8147746bd0dd711529555780ee..e49eb91d69c2344163ab9477883777476c789bc7 100755 (executable)
@@ -3934,7 +3934,8 @@ sub git_blobdiff {
 
                # open patch output
                open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
-                       '-p', $hash_parent_base, $hash_base,
+                       '-p', ($format eq 'html' ? "--full-index" : ()),
+                       $hash_parent_base, $hash_base,
                        "--", (defined $file_parent ? $file_parent : ()), $file_name
                        or die_error(undef, "Open git-diff-tree failed");
        }
@@ -3969,7 +3970,8 @@ sub git_blobdiff {
                }
 
                # open patch output
-               open $fd, "-|", git_cmd(), "diff", '-p', @diff_opts,
+               open $fd, "-|", git_cmd(), "diff", @diff_opts,
+                       '-p', ($format eq 'html' ? "--full-index" : ()),
                        $hash_parent, $hash, "--"
                        or die_error(undef, "Open git-diff failed");
        } else  {
index 557b40322f22b77a81140ff8f29b2b2be0505581..09baedc18ae320a2f09fa61d9065bedb69c02a41 100644 (file)
@@ -198,7 +198,7 @@ static void start_object_request(struct object_request *obj_req)
                SHA1_Init(&obj_req->c);
                if (prev_posn>0) {
                        prev_posn = 0;
-                       lseek(obj_req->local, SEEK_SET, 0);
+                       lseek(obj_req->local, 0, SEEK_SET);
                        ftruncate(obj_req->local, 0);
                }
        }
index 724720c562ab6da2b02e91b69f5365bc7bfee4f4..e3f767582bfc71fc3d1b90be8fa76ab3ad7e1664 100644 (file)
@@ -312,7 +312,7 @@ static void start_fetch_loose(struct transfer_request *request)
                SHA1_Init(&request->c);
                if (prev_posn>0) {
                        prev_posn = 0;
-                       lseek(request->local_fileno, SEEK_SET, 0);
+                       lseek(request->local_fileno, 0, SEEK_SET);
                        ftruncate(request->local_fileno, 0);
                }
        }
index 9558bdb6318cc2956c43153084e1f1cc8386973f..ce2c5f41fd55e15bec4e42d9dbba0d310a6e6c87 100755 (executable)
@@ -83,6 +83,15 @@ test_expect_failure \
          git-branch r &&
          git-branch -m q r/q'
 
+mv .git/config .git/config-saved
+
+test_expect_success 'git branch -m q Q without config should succeed' '
+       git-branch -m q Q &&
+       git-branch -m Q q
+'
+
+mv .git/config-saved .git/config
+
 git-config branch.s/s.dummy Hello
 
 test_expect_success \
diff --git a/t/t4120-apply-popt.sh b/t/t4120-apply-popt.sh
new file mode 100755 (executable)
index 0000000..2f672f3
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Shawn O. Pearce
+#
+
+test_description='git-apply -p handling.'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+       mkdir sub &&
+       echo A >sub/file1 &&
+       cp sub/file1 file1 &&
+       git add sub/file1 &&
+       echo B >sub/file1 &&
+       git diff >patch.file &&
+       rm sub/file1 &&
+       rmdir sub
+'
+
+test_expect_success 'apply git diff with -p2' '
+       git apply -p2 patch.file
+'
+
+test_done
index 8b611bbea210551d86016b53718ba1af313f1353..6ba63d7173ba5d333d80c017c4ef5a8c77b90a11 100755 (executable)
@@ -35,7 +35,8 @@ git commit -q -a -m first
 
 git checkout -b second master
 git show first:a1 |
-sed -e 's/To die, t/To die! T/' -e 's/life;$/life./' > a1
+sed -e 's/To die, t/To die! T/' > a1
+echo "* END *" >>a1
 git commit -q -a -m second
 
 # activate rerere
@@ -50,10 +51,10 @@ test_expect_success 'recorded preimage' "grep ======= $rr/preimage"
 test_expect_success 'no postimage or thisimage yet' \
        "test ! -f $rr/postimage -a ! -f $rr/thisimage"
 
-test_expect_success 'preimage have right number of lines' '
+test_expect_success 'preimage has right number of lines' '
 
        cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) &&
-       test "$cnt" = 10
+       test $cnt = 9
 
 '
 
@@ -75,10 +76,10 @@ cat > expect << EOF
  For in that sleep of death what dreams may come
  When we have shuffled off this mortal coil,
  Must give us pause: there's the respect
+ That makes calamity of so long life;
 -<<<<<<<
--That makes calamity of so long life.
 -=======
- That makes calamity of so long life;
+-* END *
 ->>>>>>>
 EOF
 git rerere diff > out
index ac835fe4317b7a37d77205487066d8f10bd71422..b4359df795483691e61452366add69a212347723 100755 (executable)
@@ -130,4 +130,8 @@ test_expect_success \
     'validate file contents with prefix' \
     'diff -r a e/prefix/a'
 
+test_expect_success \
+    'git-archive --list outside of a git repo' \
+    'GIT_DIR=some/non-existing/directory git-archive --list'
+
 test_done