From 7c4188360ac157217046dd99f4d98a4bf17907a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Fri, 3 Oct 2008 02:08:21 +0200 Subject: [PATCH 1/6] rebase -i: proper prepare-commit-msg hook argument when squashing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One would expect that the prepare-commit-msg hook gets 'squash' as the second argument when squashing commits with 'rebase -i'. However, that was not the case, as it got 'merge' instead. This patch fixes the problem. Signed-off-by: SZEDER Gábor Signed-off-by: Shawn O. Pearce --- git-rebase--interactive.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index edb6ec6ed..ec4299ae3 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -304,23 +304,28 @@ do_next () { mark_action_done make_squash_message $sha1 > "$MSG" + failed=f + author_script=$(get_author_ident_from_commit HEAD) + output git reset --soft HEAD^ + pick_one -n $sha1 || failed=t case "$(peek_next_command)" in squash|s) EDIT_COMMIT= USE_OUTPUT=output + MSG_OPT=-F + MSG_FILE="$MSG" cp "$MSG" "$SQUASH_MSG" ;; *) EDIT_COMMIT=-e USE_OUTPUT= + MSG_OPT= + MSG_FILE= rm -f "$SQUASH_MSG" || exit + cp -v "$MSG" "$GIT_DIR"/SQUASH_MSG + rm -f "$GIT_DIR"/MERGE_MSG || exit ;; esac - - failed=f - author_script=$(get_author_ident_from_commit HEAD) - output git reset --soft HEAD^ - pick_one -n $sha1 || failed=t echo "$author_script" > "$DOTEST"/author-script if test $failed = f then @@ -329,7 +334,7 @@ do_next () { GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \ GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \ GIT_AUTHOR_DATE="$GIT_AUTHOR_DATE" \ - $USE_OUTPUT git commit --no-verify -F "$MSG" $EDIT_COMMIT || failed=t + $USE_OUTPUT git commit --no-verify $MSG_OPT "$MSG_FILE" $EDIT_COMMIT || failed=t fi if test $failed = t then From 943cea901483c95ee7c83b70191bf7cc8f4f7c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Fri, 3 Oct 2008 11:33:20 +0200 Subject: [PATCH 2/6] rebase -i: remove leftover debugging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SZEDER Gábor Signed-off-by: Shawn O. Pearce --- git-rebase--interactive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index ec4299ae3..77e113259 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -322,7 +322,7 @@ do_next () { MSG_OPT= MSG_FILE= rm -f "$SQUASH_MSG" || exit - cp -v "$MSG" "$GIT_DIR"/SQUASH_MSG + cp "$MSG" "$GIT_DIR"/SQUASH_MSG rm -f "$GIT_DIR"/MERGE_MSG || exit ;; esac From 0e214af9c34623979b19bb183bd8e518d749fd63 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 3 Oct 2008 02:39:36 -0400 Subject: [PATCH 3/6] Makefile: do not set NEEDS_LIBICONV for Solaris 8 This breaks my build on Solaris 8, as there is no separate libiconv. The history of this line is somewhat convoluted. In 2fd955c (in November 2005), NEEDS_LIBICONV was turned on for all Solaris builds, claiming to "fix an error in Solaris 10 by setting NEEDS_LIBICONV". Later, e15f545 (in February of 2006) claimed that "Solaris 9+ don't need iconv", and moved NEEDS_LIBICONV into a section for Solaris 8. Furthermore, Brandon Casey claims in <5A1KxlhmUIHe8iXPxnXYuNXsq0Yjlbwkz2eBin3z7ELuL9nK-4tSpw@cipher.nrlssc.navy.mil> that he does not set NEEDS_LIBICONV for Solaris 7. So either one of those commits is totally wrong, or there is some other magic going on where some Solaris installs need it and others don't. Given Brandon's statement and my problems on Solaris 8 with NEEDS_LIBICONV, I am inclined to think the first commit was bogus, and that NEEDS_LIBICONV shouldn't be set for Solaris at all by default. If somebody wants to use iconv and has installed it manually, they can set it in their config.mak. Signed-off-by: Jeff King Signed-off-by: Shawn O. Pearce --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 7fad9f7ff..0d40f0ecc 100644 --- a/Makefile +++ b/Makefile @@ -639,7 +639,6 @@ ifeq ($(uname_S),SunOS) NO_MKDTEMP = YesPlease OLD_ICONV = UnfortunatelyYes ifeq ($(uname_R),5.8) - NEEDS_LIBICONV = YesPlease NO_UNSETENV = YesPlease NO_SETENV = YesPlease NO_C99_FORMAT = YesPlease From 36e40535dcafe230a7f5ef43fea5cf67c1c58f6f Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Wed, 8 Oct 2008 19:07:54 -0500 Subject: [PATCH 4/6] builtin-merge.c: allocate correct amount of memory Fix two memory allocation errors which allocate space for a pointer rather than enough space for the structure itself. This: struct commit_list *parent = xmalloc(sizeof(struct commit_list *)); should have been this: struct commit_list *parent = xmalloc(sizeof(struct commit_list)); But while we're at it, change the allocation to reference the variable it is allocating memory for to try to prevent a similar mistake, for example if the type is changed, in the future. Signed-off-by: Brandon Casey Acked-by: Miklos Vajna Signed-off-by: Shawn O. Pearce --- builtin-merge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin-merge.c b/builtin-merge.c index dcaf3681d..d0bf1fc1e 100644 --- a/builtin-merge.c +++ b/builtin-merge.c @@ -651,12 +651,12 @@ static void add_strategies(const char *string, unsigned attr) static int merge_trivial(void) { unsigned char result_tree[20], result_commit[20]; - struct commit_list *parent = xmalloc(sizeof(struct commit_list *)); + struct commit_list *parent = xmalloc(sizeof(*parent)); write_tree_trivial(result_tree); printf("Wonderful.\n"); parent->item = lookup_commit(head); - parent->next = xmalloc(sizeof(struct commit_list *)); + parent->next = xmalloc(sizeof(*parent->next)); parent->next->item = remoteheads->item; parent->next->next = NULL; commit_tree(merge_msg.buf, result_tree, parent, result_commit); From 875471c510b29f920693834b43a992c99694af58 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Thu, 2 Oct 2008 18:52:11 -0500 Subject: [PATCH 5/6] git-stash.sh: fix flawed fix of invalid ref handling (commit da65e7c1) The referenced commit tried to fix a flaw in stash's handling of a user supplied invalid ref. i.e. 'git stash apply fake_ref@{0}' should fail instead of applying stash@{0}. But, it did so in a naive way by avoiding the use of the --default option of rev-parse, and instead manually supplied the default revision if the user supplied an empty command line. This prevented a common usage scenario of supplying flags on the stash command line (i.e. non-empty command line) which would be parsed by lower level git commands, without supplying a specific revision. This should fall back to the default revision, but now it causes an error. e.g. 'git stash show -p' The correct fix is to use the --verify option of rev-parse, which fails properly if an invalid ref is supplied, and still allows falling back to a default ref when one is not supplied. Convert stash-drop to use --verify while we're at it, since specifying multiple revisions for any of these commands is also an error and --verify makes it so. Signed-off-by: Brandon Casey Signed-off-by: Shawn O. Pearce --- git-stash.sh | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/git-stash.sh b/git-stash.sh index 42f626f9d..b9ace9970 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -145,16 +145,8 @@ show_stash () { flags=--stat fi - if test $# = 0 - then - set x "$ref_stash@{0}" - shift - fi - - s=$(git rev-parse --revs-only --no-flags "$@") - - w_commit=$(git rev-parse --verify "$s") && - b_commit=$(git rev-parse --verify "$s^") && + w_commit=$(git rev-parse --verify --default $ref_stash "$@") && + b_commit=$(git rev-parse --verify "$w_commit^") && git diff $flags $b_commit $w_commit } @@ -170,19 +162,13 @@ apply_stash () { shift esac - if test $# = 0 - then - set x "$ref_stash@{0}" - shift - fi - # current index state c_tree=$(git write-tree) || die 'Cannot apply a stash in the middle of a merge' # stash records the work tree, and is a merge between the # base commit (first parent) and the index tree (second parent). - s=$(git rev-parse --revs-only --no-flags "$@") && + s=$(git rev-parse --verify --default $ref_stash "$@") && w_tree=$(git rev-parse --verify "$s:") && b_tree=$(git rev-parse --verify "$s^1:") && i_tree=$(git rev-parse --verify "$s^2:") || @@ -242,7 +228,7 @@ drop_stash () { shift fi # Verify supplied argument looks like a stash entry - s=$(git rev-parse --revs-only --no-flags "$@") && + s=$(git rev-parse --verify "$@") && git rev-parse --verify "$s:" > /dev/null 2>&1 && git rev-parse --verify "$s^1:" > /dev/null 2>&1 && git rev-parse --verify "$s^2:" > /dev/null 2>&1 || From b8ebe08b9a643f432866eb7150c3b20d59b755f2 Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Thu, 9 Oct 2008 00:24:16 +0300 Subject: [PATCH 6/6] builtin-apply: fix typo leading to stack corruption This typo led to stack corruption for lines with whitespace fixes and length > 1024. Signed-off-by: Imre Deak Looks-good-by: Junio C Hamano Signed-off-by: Shawn O. Pearce --- builtin-apply.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin-apply.c b/builtin-apply.c index 2c87cf57f..74f7e7924 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -1697,7 +1697,7 @@ static int match_fragment(struct image *img, fixlen = ws_fix_copy(buf, orig, oldlen, ws_rule, NULL); /* Try fixing the line in the target */ - if (sizeof(tgtfixbuf) < tgtlen) + if (sizeof(tgtfixbuf) > tgtlen) tgtfix = tgtfixbuf; else tgtfix = xmalloc(tgtlen);