From 5a625b07bbff709037f26be1c393337b6d9e103f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Fri, 3 Oct 2008 21:34:49 +0200 Subject: [PATCH 1/9] bash: remove fetch, push, pull dashed form leftovers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't provide complation for git-commands in dashed form anymore, so there is no need to keep those cases. Signed-off-by: SZEDER Gábor Tested-by: Thomas Rast Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 36 +++++++------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 3bc45f6b47..751e273e1a 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -799,14 +799,9 @@ _git_fetch () { local cur="${COMP_WORDS[COMP_CWORD]}" - case "${COMP_WORDS[0]},$COMP_CWORD" in - git-fetch*,1) + if [ "$COMP_CWORD" = 2 ]; then __gitcomp "$(__git_remotes)" - ;; - git,2) - __gitcomp "$(__git_remotes)" - ;; - *) + else case "$cur" in *:*) local pfx="" @@ -825,8 +820,7 @@ _git_fetch () __gitcomp "$(__git_refs2 "$remote")" ;; esac - ;; - esac + fi } _git_format_patch () @@ -1063,36 +1057,25 @@ _git_pull () { local cur="${COMP_WORDS[COMP_CWORD]}" - case "${COMP_WORDS[0]},$COMP_CWORD" in - git-pull*,1) + if [ "$COMP_CWORD" = 2 ]; then __gitcomp "$(__git_remotes)" - ;; - git,2) - __gitcomp "$(__git_remotes)" - ;; - *) + else local remote case "${COMP_WORDS[0]}" in git-pull) remote="${COMP_WORDS[1]}" ;; git) remote="${COMP_WORDS[2]}" ;; esac __gitcomp "$(__git_refs "$remote")" - ;; - esac + fi } _git_push () { local cur="${COMP_WORDS[COMP_CWORD]}" - case "${COMP_WORDS[0]},$COMP_CWORD" in - git-push*,1) + if [ "$COMP_CWORD" = 2 ]; then __gitcomp "$(__git_remotes)" - ;; - git,2) - __gitcomp "$(__git_remotes)" - ;; - *) + else case "$cur" in *:*) local remote @@ -1116,8 +1099,7 @@ _git_push () __gitcomp "$(__git_refs)" ;; esac - ;; - esac + fi } _git_rebase () From 5209ac4de4192e4ffcd72861517daccf387391e5 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Fri, 3 Oct 2008 20:23:50 +0400 Subject: [PATCH 2/9] builtin-blame: Fix blame -C -C with submodules. When performing copy detection, git-blame tries to read gitlinks as blobs, which causes it to die. This patch adds a check to skip them. Signed-off-by: Alexander Gavrilov Signed-off-by: Shawn O. Pearce --- builtin-blame.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin-blame.c b/builtin-blame.c index 9bc901c292..101c4162da 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -1136,6 +1136,8 @@ static int find_copy_in_parent(struct scoreboard *sb, if (!DIFF_FILE_VALID(p->one)) continue; /* does not exist in parent */ + if (S_ISGITLINK(p->one->mode)) + continue; /* ignore git links */ if (porigin && !strcmp(p->one->path, porigin->path)) /* find_move already dealt with this path */ continue; From fe8aa148b2cba66fb2643e4df1670c132da5d706 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Sun, 5 Oct 2008 15:53:00 +0200 Subject: [PATCH 3/9] Fix fetch/clone --quiet when stdout is connected Fixes the `git clone --quiet` issue raised by Dave Jones in http://marc.info/?l=git&m=121529226023180&w=2 With this simple patch applied we no longer see the following remote messages as no-progress is correctly sent to the remote site: remote: Counting objects: 84102, done. remote: Compressing objects: 100% (24720/24720), done. remote: Total 84102 (delta 60949), reused 80810 (delta 57900) Signed-off-by: Tuncer Ayaz Acked-by: Daniel Barkalow Signed-off-by: Shawn O. Pearce --- transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transport.c b/transport.c index 71433d9997..35cac441f8 100644 --- a/transport.c +++ b/transport.c @@ -643,8 +643,8 @@ static int fetch_refs_via_pack(struct transport *transport, args.use_thin_pack = data->thin; args.include_tag = data->followtags; args.verbose = (transport->verbose > 0); - args.quiet = args.no_progress = (transport->verbose < 0); - args.no_progress = !isatty(1); + args.quiet = (transport->verbose < 0); + args.no_progress = args.quiet || !isatty(1); args.depth = data->depth; for (i = 0; i < nr_heads; i++) From 71b989e7dd1dcf891369319cfeda0ed8b6a152e1 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 5 Oct 2008 15:35:15 -0400 Subject: [PATCH 4/9] fix bogus "diff --git" header from "diff --no-index" When "git diff --no-index" is given an absolute pathname, it would generate a diff header with the absolute path prepended by the prefix, like: diff --git a/dev/null b/foo Not only is this nonsensical, and not only does it violate the description of diffs given in git-diff(1), but it would produce broken binary diffs. Unlike text diffs, the binary diffs don't contain the filenames anywhere else, and so "git apply" relies on this header to figure out the filename. This patch just refuses to use an invalid name for anything visible in the diff. Now, this fixes the "git diff --no-index --binary a /dev/null" kind of case (and we'll end up using "a" as the basename), but some other insane cases are impossible to handle. If you do git diff --no-index --binary a /bin/echo you'll still get a patch like diff --git a/a b/bin/echo old mode 100644 new mode 100755 index ... and "git apply" will refuse to apply it for a couple of reasons, and the diff is simply bogus. And that, btw, is no longer a bug, I think. It's impossible to know whethe the user meant for the patch to be a rename or not. And as such, refusing to apply it because you don't know what name you should use is probably _exactly_ the right thing to do! Original problem reported by Imre Deak. Test script and problem description by Jeff King. Signed-off-by: Jeff King Signed-off-by: Linus Torvalds Signed-off-by: Shawn O. Pearce --- diff.c | 4 ++++ t/t4012-diff-binary.sh | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/diff.c b/diff.c index 781fa15ac1..f91f256c56 100644 --- a/diff.c +++ b/diff.c @@ -1465,6 +1465,10 @@ static void builtin_diff(const char *name_a, const char *set = diff_get_color_opt(o, DIFF_METAINFO); const char *reset = diff_get_color_opt(o, DIFF_RESET); + /* Never use a non-valid filename anywhere if at all possible */ + name_a = DIFF_FILE_VALID(one) ? name_a : name_b; + name_b = DIFF_FILE_VALID(two) ? name_b : name_a; + a_one = quote_two(o->a_prefix, name_a + (*name_a == '/')); b_two = quote_two(o->b_prefix, name_b + (*name_b == '/')); lbl[0] = DIFF_FILE_VALID(one) ? a_one : "/dev/null"; diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh index 64c372a025..eac12712db 100755 --- a/t/t4012-diff-binary.sh +++ b/t/t4012-diff-binary.sh @@ -77,4 +77,25 @@ test_expect_success 'apply binary patch' \ tree1=`git write-tree` && test "$tree1" = "$tree0"' +q_to_nul() { + perl -pe 'y/Q/\000/' +} + +nul_to_q() { + perl -pe 'y/\000/Q/' +} + +test_expect_success 'diff --no-index with binary creation' ' + echo Q | q_to_nul >binary && + (:# hide error code from diff, which just indicates differences + git diff --binary --no-index /dev/null binary >current || + true + ) && + rm binary && + git apply --binary expected && + nul_to_q actual && + test_cmp expected actual +' + test_done From 62525ef78e8aec776f44da525030d76b52f14a57 Mon Sep 17 00:00:00 2001 From: Dmitry Potapov Date: Sun, 5 Oct 2008 04:40:36 +0400 Subject: [PATCH 5/9] make prefix_path() never return NULL There are 9 places where prefix_path is called, and only in one of them the returned pointer was checked to be non-zero and only to call exit(128) as it is usually done by die(). In other 8 places, the returned value was not checked and it caused SIGSEGV when a path outside of the working tree was used. For instance, running git update-index --add /some/path/outside caused SIGSEGV. This patch changes prefix_path() to die if the path is outside of the repository, so it never returns NULL. Signed-off-by: Dmitry Potapov Signed-off-by: Shawn O. Pearce --- setup.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/setup.c b/setup.c index 2e3248a0c4..78a8041ff0 100644 --- a/setup.c +++ b/setup.c @@ -110,9 +110,7 @@ const char *prefix_path(const char *prefix, int len, const char *path) if (strncmp(sanitized, work_tree, len) || (sanitized[len] != '\0' && sanitized[len] != '/')) { error_out: - error("'%s' is outside repository", orig); - free(sanitized); - return NULL; + die("'%s' is outside repository", orig); } if (sanitized[len] == '/') len++; @@ -216,10 +214,7 @@ const char **get_pathspec(const char *prefix, const char **pathspec) prefixlen = prefix ? strlen(prefix) : 0; while (*src) { const char *p = prefix_path(prefix, prefixlen, *src); - if (p) - *(dst++) = p; - else - exit(128); /* error message already given */ + *(dst++) = p; src++; } *dst = NULL; From d09e2cd5516473753cb067e723293fab180e0b1b Mon Sep 17 00:00:00 2001 From: Dmitry Potapov Date: Sun, 5 Oct 2008 06:14:40 +0400 Subject: [PATCH 6/9] do not segfault if make_cache_entry failed Signed-off-by: Dmitry Potapov Signed-off-by: Shawn O. Pearce --- builtin-apply.c | 2 ++ builtin-reset.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/builtin-apply.c b/builtin-apply.c index 70c9f93554..2c87cf57fd 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -2586,6 +2586,8 @@ static void build_fake_ancestor(struct patch *list, const char *filename) sha1_ptr = sha1; ce = make_cache_entry(patch->old_mode, sha1_ptr, name, 0, 0); + if (!ce) + die("make_cache_entry failed for path '%s'", name); if (add_index_entry(&result, ce, ADD_CACHE_OK_TO_ADD)) die ("Could not add %s to temporary index", name); } diff --git a/builtin-reset.c b/builtin-reset.c index c24c219091..16e6bb20f1 100644 --- a/builtin-reset.c +++ b/builtin-reset.c @@ -121,6 +121,9 @@ static void update_index_from_diff(struct diff_queue_struct *q, struct cache_entry *ce; ce = make_cache_entry(one->mode, one->sha1, one->path, 0, 0); + if (!ce) + die("make_cache_entry failed for path '%s'", + one->path); add_cache_entry(ce, ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE); } else From 00e5d48a9aef3228496d6f517a272fa095c562fe Mon Sep 17 00:00:00 2001 From: Nanako Shiraishi Date: Sun, 5 Oct 2008 22:26:54 +0900 Subject: [PATCH 7/9] docs: describe pre-rebase hook Documentation/git-rebase.txt talks about pre-rebase hook, but it appears that Documentation/git-hooks.txt does not have corresponding entry for it. Signed-off-by: Nanako Shiraishi Signed-off-by: Shawn O. Pearce --- Documentation/githooks.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt index 7fefdb1f45..5faaaa5fed 100644 --- a/Documentation/githooks.txt +++ b/Documentation/githooks.txt @@ -130,6 +130,13 @@ parameter, and is invoked after a commit is made. This hook is meant primarily for notification, and cannot affect the outcome of 'git-commit'. +pre-rebase +---------- + +This hook is called by 'git-rebase' and can be used to prevent a branch +from getting rebased. + + post-checkout ----------- From d70b4a8f4ba79fb83dc95e9483f9fb3feaf578b7 Mon Sep 17 00:00:00 2001 From: Nanako Shiraishi Date: Mon, 6 Oct 2008 14:14:24 +0900 Subject: [PATCH 8/9] Teach rebase -i to honor pre-rebase hook The original git-rebase honored pre-rebase hook so that public branches can be protected from getting rebased, but rebase --interactive ignored the hook entirely. This fixes it. Signed-off-by: Nanako Shiraishi Signed-off-by: Shawn O. Pearce --- git-rebase--interactive.sh | 11 ++++ git-rebase.sh | 18 +++--- t/t3409-rebase-hook.sh | 126 +++++++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+), 7 deletions(-) create mode 100755 t/t3409-rebase-hook.sh diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index edb6ec6ed0..3350f90cb1 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -65,6 +65,16 @@ output () { esac } +run_pre_rebase_hook () { + if test -x "$GIT_DIR/hooks/pre-rebase" + then + "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || { + echo >&2 "The pre-rebase hook refused to rebase." + exit 1 + } + fi +} + require_clean_work_tree () { # test if working tree is dirty git rev-parse --verify HEAD > /dev/null && @@ -507,6 +517,7 @@ first and then run 'git rebase --continue' again." ;; --) shift + run_pre_rebase_hook ${1+"$@"} test $# -eq 1 -o $# -eq 2 || usage test -d "$DOTEST" && die "Interactive rebase already started" diff --git a/git-rebase.sh b/git-rebase.sh index 528b604cd5..a30d40c005 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -144,6 +144,16 @@ is_interactive () { done && test -n "$1" } +run_pre_rebase_hook () { + if test -x "$GIT_DIR/hooks/pre-rebase" + then + "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || { + echo >&2 "The pre-rebase hook refused to rebase." + exit 1 + } + fi +} + test -f "$GIT_DIR"/rebase-apply/applying && die 'It looks like git-am is in progress. Cannot rebase.' @@ -320,13 +330,7 @@ onto_name=${newbase-"$upstream_name"} onto=$(git rev-parse --verify "${onto_name}^0") || exit # If a hook exists, give it a chance to interrupt -if test -x "$GIT_DIR/hooks/pre-rebase" -then - "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || { - echo >&2 "The pre-rebase hook refused to rebase." - exit 1 - } -fi +run_pre_rebase_hook ${1+"$@"} # If the branch to rebase is given, that is the branch we will rebase # $branch_name -- branch being rebased, or HEAD (already detached) diff --git a/t/t3409-rebase-hook.sh b/t/t3409-rebase-hook.sh new file mode 100755 index 0000000000..bc93dda8fd --- /dev/null +++ b/t/t3409-rebase-hook.sh @@ -0,0 +1,126 @@ +#!/bin/sh + +test_description='git rebase with its hook(s)' + +. ./test-lib.sh + +test_expect_success setup ' + echo hello >file && + git add file && + test_tick && + git commit -m initial && + echo goodbye >file && + git add file && + test_tick && + git commit -m second && + git checkout -b side HEAD^ && + echo world >git && + git add git && + test_tick && + git commit -m side && + git checkout master && + git log --pretty=oneline --abbrev-commit --graph --all && + git branch test side +' + +test_expect_success 'rebase' ' + git checkout test && + git reset --hard side && + git rebase master && + test "z$(cat git)" = zworld +' + +test_expect_success 'rebase -i' ' + git checkout test && + git reset --hard side && + EDITOR=true git rebase -i master && + test "z$(cat git)" = zworld +' + +test_expect_success 'setup pre-rebase hook' ' + mkdir -p .git/hooks && + cat >.git/hooks/pre-rebase <.git/PRE-REBASE-INPUT +EOF + chmod +x .git/hooks/pre-rebase +' + +test_expect_success 'pre-rebase hook gets correct input (1)' ' + git checkout test && + git reset --hard side && + git rebase master && + test "z$(cat git)" = zworld && + test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster, + +' + +test_expect_success 'pre-rebase hook gets correct input (2)' ' + git checkout test && + git reset --hard side && + git rebase master test && + test "z$(cat git)" = zworld && + test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test +' + +test_expect_success 'pre-rebase hook gets correct input (3)' ' + git checkout test && + git reset --hard side && + git checkout master && + git rebase master test && + test "z$(cat git)" = zworld && + test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test +' + +test_expect_success 'pre-rebase hook gets correct input (4)' ' + git checkout test && + git reset --hard side && + EDITOR=true git rebase -i master && + test "z$(cat git)" = zworld && + test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster, + +' + +test_expect_success 'pre-rebase hook gets correct input (5)' ' + git checkout test && + git reset --hard side && + EDITOR=true git rebase -i master test && + test "z$(cat git)" = zworld && + test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test +' + +test_expect_success 'pre-rebase hook gets correct input (6)' ' + git checkout test && + git reset --hard side && + git checkout master && + EDITOR=true git rebase -i master test && + test "z$(cat git)" = zworld && + test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test +' + +test_expect_success 'setup pre-rebase hook that fails' ' + mkdir -p .git/hooks && + cat >.git/hooks/pre-rebase < Date: Mon, 6 Oct 2008 08:22:19 -0700 Subject: [PATCH 9/9] Update release notes for 1.6.0.3 Signed-off-by: Shawn O. Pearce --- Documentation/RelNotes-1.6.0.3.txt | 52 +++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/Documentation/RelNotes-1.6.0.3.txt b/Documentation/RelNotes-1.6.0.3.txt index 46e13a450a..edd5e45c95 100644 --- a/Documentation/RelNotes-1.6.0.3.txt +++ b/Documentation/RelNotes-1.6.0.3.txt @@ -13,33 +13,83 @@ Fixes since v1.6.0.2 * Continuing "git rebase -i" was also very confused when the user left some staged changes in the index after "edit". +* "git rebase -i" now honors the pre-rebase hook, just like the + other rebase implementations "git rebase" and "git rebase -m". + * Behaviour of "git diff --quiet" was inconsistent with "diff --exit-code" with the output redirected to /dev/null. +* "git diff --no-index" on binary files no longer outputs a bogus + "diff --git" header line. + +* Hunk headers in "git diff" default to using extended regular + expressions, fixing some of the internal patterns on non-GNU + platforms. + +* New config "diff.*.xfuncname" exposes extended regular expressions + for user specified hunk header patterns. + * "git stash apply sash@{1}" was fixed to error out. Prior versions would have applied stash@{0} incorrectly. +* "git stash apply" now offers a better suggestion on how to continue + if the working tree is currently dirty. + * "git for-each-ref --format=%(subject)" fixed for commits with no no newline in the message body. * "git remote" fixed to protect printf from user input. +* "git remote show -v" now displays all URLs of a remote. + * "git checkout -q" once again suppresses the locally modified file list. +* "git clone -q", "git fetch -q" asks remote side to not send + progress messages, actually making their output quiet. + * Cross-directory renames are no longer used when creating packs. This allows more graceful behavior on filesystems like sshfs. * Stale temporary files under $GIT_DIR/objects/pack are now cleaned up automatically by "git prune". +* "git merge" once agrain removes directories after the last file has + been removed from it during the merge. + +* "git blame -C -C" no longer segfaults while trying to pass blame if + it encounters a submodule reference. + +* "git svn" fixed to display an error message when 'set-tree' failed, + instead of a Perl compile error. + +* "git submodule" fixed to handle checking out a different commit + than HEAD after initializing the submodule. + +* The "git commit" error message when there are still unmerged + files present was clarified to match "git write-tree". + +* Some segfaults due to uncaught NULL pointers were fixed multiple + tools such as apply, reset, update-index. + +* Solaris bulds now default to OLD_ICONV=1 to avoid compile warnings. + * "Git.pm" tests relied on unnecessarily more recent version of Perl. * "gitweb" triggered undef warning on commits without log messages. +* "gitweb" triggered undef warnings on missing trees. + +* "gitweb" now removes PATH_INFO from its URLs so users don't have + to manually set the url in the gitweb configuration. + +* Bash completion removed support for legacy "git-fetch", "git-push" + and "git-pull" as these are no longer installed. Dashless form + ("git fetch") is still however supported. + Many other documentation updates. -- exec >/var/tmp/1 -O=v1.6.0.2-41-g7fe4a72 +O=v1.6.0.2-76-gd70b4a8 echo O=$(git describe maint) git shortlog --no-merges $O..maint