From 364b8523529163ffeeb71521239a18ac1f550512 Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Wed, 4 Apr 2007 15:39:05 -0400 Subject: [PATCH 01/11] Fix t4200-rerere for white-space from "wc -l" On OS X, wc outputs 6 spaces before the number of lines, so the test expecting the string "10" failed. Do not quote $cmd to strip away the problematic whitespace as other tests do. Also fix the grammar of the test name while making changes to it. There's only one preimage, so it's "has", not "have". Signed-off-by: Junio C Hamano --- t/t4200-rerere.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index 8b611bbea2..bc878d750d 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -50,10 +50,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 = 10 ' From 2b93edbf32700d91c500806e4502077829d66d21 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 4 Apr 2007 14:12:03 -0700 Subject: [PATCH 02/11] rerere: make sorting really stable. The earlier code does not swap hunks when the beginning of the first side is identical to the whole of the second side. In such a case, the first one should sort later. Signed-off-by: Junio C Hamano --- builtin-rerere.c | 7 +++++-- t/t4200-rerere.sh | 11 ++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/builtin-rerere.c b/builtin-rerere.c index b463c07f04..8c2c8bdc18 100644 --- a/builtin-rerere.c +++ b/builtin-rerere.c @@ -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; diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index bc878d750d..6ba63d7173 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -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 @@ -53,7 +54,7 @@ test_expect_success 'no postimage or thisimage yet' \ 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; +-<<<<<<< +-======= +-* END * ->>>>>>> EOF git rerere diff > out From 5850cb645d3ca44c3bc014f92672dae6394c0315 Mon Sep 17 00:00:00 2001 From: Gerrit Pape Date: Wed, 4 Apr 2007 11:52:12 +0000 Subject: [PATCH 03/11] rename contrib/hooks/post-receieve-email to contrib/hooks/post-receive-email. $ git grep post-receieve-email $ git grep post-receive-email templates/hooks--post-receive:#. /usr/share/doc/git-core/contrib/hooks/post-receive-email $ Signed-off-by: Gerrit Pape Signed-off-by: Junio C Hamano --- contrib/hooks/{post-receieve-email => post-receive-email} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename contrib/hooks/{post-receieve-email => post-receive-email} (100%) diff --git a/contrib/hooks/post-receieve-email b/contrib/hooks/post-receive-email similarity index 100% rename from contrib/hooks/post-receieve-email rename to contrib/hooks/post-receive-email From 265d528032e55c48798266c538d3e6338cb1e2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Thu, 5 Apr 2007 22:55:43 +0200 Subject: [PATCH 04/11] Revert "builtin-archive: use RUN_SETUP" Commit 64edf4b2 cleaned up the initialization of git-archive, at the cost of 'git-archive --list' now requiring a git repo. This patch reverts the cleanup and documents the requirement for this particular dirtyness in a test. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- builtin-archive.c | 2 ++ git.c | 2 +- t/t5000-tar-tree.sh | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/builtin-archive.c b/builtin-archive.c index 2fae885f5c..8ea6cb1efc 100644 --- a/builtin-archive.c +++ b/builtin-archive.c @@ -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); diff --git a/git.c b/git.c index 5b1bc2a895..33dd4d39d9 100644 --- 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 }, diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index ac835fe431..b4359df795 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -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 From b24bace5ca9420033be83ef6c14fb092c9371fe1 Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Thu, 5 Apr 2007 10:53:07 -0400 Subject: [PATCH 05/11] Document --left-right option to rev-list. Explanation is paraphrased from "577ed5c... rev-list --left-right" Signed-off-by: Junio C Hamano --- Documentation/git-rev-list.txt | 31 +++++++++++++++++++++++++++++++ builtin-rev-list.c | 1 + 2 files changed, 32 insertions(+) diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index 4f145eaba4..11ce395c98 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -21,6 +21,7 @@ SYNOPSIS [ \--stdin ] [ \--topo-order ] [ \--parents ] + [ \--left-right ] [ \--encoding[=] ] [ \--(author|committer|grep)= ] [ [\--objects | \--objects-edge] [ \--unpacked ] ] @@ -100,6 +101,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 + Date: Thu, 5 Apr 2007 13:45:41 +0200 Subject: [PATCH 06/11] gitweb: Fix bug in "blobdiff" view for split (e.g. file to symlink) patches git_patchset_body needs patch generated with --full-index option to detect split patches, meaning two patches which corresponds to single difftree (raw diff) entry. An example of such situation is changing type (mode) of a file, e.g. from plain file to symbolic link. Add, in git_blobdiff, --full-index option to patch generating git diff invocation, for the 'html' format output ("blobdiff" view). "blobdiff_plain" still uses shortened sha1 in the extended git diff header "index ..[ ]" line. Noticed-by: Martin Koegler Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 3786955fca..45ac9d7121 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -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 { From 1e31fbe24fac983b0057af39824f73d65dba6502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Thu, 5 Apr 2007 21:09:31 +0300 Subject: [PATCH 07/11] DESTDIR support for git/contrib/emacs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make install DESTDIR=... support for git/contrib/emacs Signed-off-by: Ville Skyttä Signed-off-by: Junio C Hamano --- contrib/emacs/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/emacs/Makefile b/contrib/emacs/Makefile index 8554e3967c..98aa0aae9b 100644 --- a/contrib/emacs/Makefile +++ b/contrib/emacs/Makefile @@ -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 $< From 01ebb9dc8846af729c13d5d8c9d939a6d1159240 Mon Sep 17 00:00:00 2001 From: Geert Bosch Date: Thu, 5 Apr 2007 10:20:55 -0400 Subject: [PATCH 08/11] Fix renaming branch without config file Make git_config_rename_section return success if no config file exists. Otherwise, renaming a branch would abort, leaving the repository in an inconsistent state. [jc: test] Signed-off-by: Geert Bosch Signed-off-by: Junio C Hamano --- config.c | 5 +++-- t/t3200-branch.sh | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config.c b/config.c index 6479855723..70d1055679 100644 --- 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: diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 9558bdb631..ce2c5f41fd 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -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 \ From 766b084f59c97bc8b096a59cd5c8d06df5aa2bc5 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 5 Apr 2007 15:03:48 -0700 Subject: [PATCH 09/11] Fix dependency of common-cmds.h Say $(wildcard ...) when we mean it. Signed-off-by: Junio C Hamano --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b159ffd0ae..81dafe5ee3 100644 --- a/Makefile +++ b/Makefile @@ -684,7 +684,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 From 79ee194e52a140412da475e102145bad80d5d00a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 4 Apr 2007 11:19:14 -0400 Subject: [PATCH 10/11] Honor -p when applying git diffs If the user is trying to apply a Git generated diff file and they have specified a -p option, where is not 1, the user probably has a good reason for doing this. Such as they are me, trying to apply a patch generated in git.git for the git-gui subdirectory to the git-gui.git repository, where there is no git-gui subdirectory present. Users shouldn't supply -p2 unless they mean it. But if they are supplying it, they probably have thought about how to make this patch apply to their working directory, and want to risk whatever results may come from that. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- builtin-apply.c | 4 ++-- t/t4120-apply-popt.sh | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100755 t/t4120-apply-popt.sh diff --git a/builtin-apply.c b/builtin-apply.c index 27a182bfaa..a5d612655f 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -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); diff --git a/t/t4120-apply-popt.sh b/t/t4120-apply-popt.sh new file mode 100755 index 0000000000..2f672f30d4 --- /dev/null +++ b/t/t4120-apply-popt.sh @@ -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 From b5da24679ec73f458988523dce9dd17b4e9b0e02 Mon Sep 17 00:00:00 2001 From: Dana How Date: Thu, 5 Apr 2007 12:05:57 -0700 Subject: [PATCH 11/11] Fix lseek(2) calls with args 2 and 3 swapped Signed-off-by: Junio C Hamano --- http-fetch.c | 2 +- http-push.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/http-fetch.c b/http-fetch.c index 557b40322f..09baedc18a 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -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); } } diff --git a/http-push.c b/http-push.c index 724720c562..e3f767582b 100644 --- a/http-push.c +++ b/http-push.c @@ -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); } }