When calling update-index on an unmerged file that is executable and core.filemode is false, or that is a symlink and core.symlink is false, the executable bit or the symlink property is lost. --- Stefan Haller <lists@xxxxxxxxxxxxxxxx> wrote: > There's a bug with the handling of the executable bit when core.filemode > is false: when you have an executable file that has unmerged changes, > and you stage it with "git update-index", the executable bit is lost. > If you stage it with "git add" instead, it works fine. It turns out that the same bug exists for symlinks when core.symlink is false. Here's a patch that adds two tests that demonstrate the problems. (I suspect both have a similar cause, and/or a similar solution.) This is the first time I write a git test, so please point out anything I might have done wrong. Also, I still don't have much of an idea how or where to fix the problem, so any guidance towards that is much appreciated. t/t2107-update-index-executable-bit-merged.sh | 44 +++++++++++++++++++++++++ t/t2108-update-index-symlink-merged.sh | 43 ++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 0 deletions(-) create mode 100755 t/t2107-update-index-executable-bit-merged.sh create mode 100755 t/t2108-update-index-symlink-merged.sh diff --git a/t/t2107-update-index-executable-bit-merged.sh b/t/t2107-update-index-executable-bit-merged.sh new file mode 100755 index 0000000..7a8f740 --- /dev/null +++ b/t/t2107-update-index-executable-bit-merged.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# +# Copyright (c) 2010 Stefan Haller +# + +test_description='git update-index on filesystem w/o symlinks test. + +This tests that git update-index keeps the executable bit when staging +an unmerged file after a merge if core.filemode is false.' + +. ./test-lib.sh + +test_expect_success \ +'preparation' ' +git config core.filemode false && +touch foo && +git add foo && +git update-index --chmod=+x foo && +git commit -m "Create"' + +test_expect_success \ +'modify the file on two branches and merge' ' +git branch br && +test_commit "Modify_on_master" foo && +git checkout br -- && +test_commit "Modify_on_branch" foo && +test_must_fail git merge master' + +test_expect_success \ +'double-check that file is indeed unmerged' ' +git ls-files --unmerged --error-unmatch -- foo' + +test_expect_success \ +'stage unmerged file with update-index' ' +git update-index -- foo' + +test_expect_failure \ +'check that filemode is still 100755' ' +case "`git ls-files --stage --cached -- foo`" in +"100755 "*foo) echo pass;; +*) echo fail; git ls-files --stage --cached -- foo; (exit 1);; +esac' + +test_done diff --git a/t/t2108-update-index-symlink-merged.sh b/t/t2108-update-index-symlink-merged.sh new file mode 100755 index 0000000..7e28e91 --- /dev/null +++ b/t/t2108-update-index-symlink-merged.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# +# Copyright (c) 2010 Stefan Haller +# + +test_description='git update-index on filesystem w/o symlinks test. + +This tests that git update-index keeps the executable bit when staging +an unmerged file after a merge if core.filemode is false.' + +. ./test-lib.sh + +test_expect_success \ +'preparation' ' +git config core.symlinks false && +l=$(printf file | git hash-object -t blob -w --stdin) && +echo "120000 $l symlink" | git update-index --index-info && +git commit -m "Create"' + +test_expect_success \ +'modify the symlink on two branches and merge' ' +git branch br && +test_commit "Modify_on_master" symlink && +git checkout br -- && +test_commit "Modify_on_branch" symlink && +test_must_fail git merge master' + +test_expect_success \ +'double-check that file is indeed unmerged' ' +git ls-files --unmerged --error-unmatch -- symlink' + +test_expect_success \ +'stage unmerged file with update-index' ' +git update-index -- symlink' + +test_expect_failure \ +'check that file is still a symlink' ' +case "`git ls-files --stage --cached -- symlink`" in +"120000 "*symlink) echo pass;; +*) echo fail; git ls-files --stage --cached -- symlink; (exit 1);; +esac' + +test_done -- 1.7.3.1.57.gb5d9d -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html