Skip to content

Commit 36e0e74

Browse files
authored
Merge pull request #83 from mharacewiat/preserve-file-permissions
Preserve file permissions
2 parents fd72641 + bc1bb28 commit 36e0e74

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

run-tests.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,37 @@ twigSplitTest() {
155155
cd ../
156156
}
157157

158+
filemodeTest() {
159+
rm -rf filemode
160+
mkdir filemode
161+
cd filemode
162+
git init > /dev/null
163+
164+
switchAsSammy "Sat, 24 Nov 1973 19:01:02 +0200" "Sat, 24 Nov 1973 19:11:22 +0200"
165+
echo "a" > a
166+
git add a
167+
git commit -m"added a" > /dev/null
168+
169+
switchAsFred "Sat, 24 Nov 1973 20:01:02 +0200" "Sat, 24 Nov 1973 20:11:22 +0200"
170+
mkdir b/
171+
echo "b" > b/b
172+
chmod +x b/b
173+
git add b
174+
git commit -m"added b" > /dev/null
175+
176+
$LITE_PATH --prefix=b/::not-important:also-not-important --target refs/heads/split 2>/dev/null
177+
FILEMODE=`git ls-tree -r --format='%(objectmode)' split b`
178+
179+
if test "$FILEMODE" = "100755"; then
180+
echo "Test #6 - OK"
181+
else
182+
echo "Test #6 - NOT OK"
183+
exit 1
184+
fi
185+
186+
cd ../
187+
}
188+
158189
LITE_PATH=`pwd`/splitsh-lite
159190
if [ ! -e $LITE_PATH ]; then
160191
echo "You first need to compile the splitsh-lite binary"
@@ -169,3 +200,4 @@ cd splitter-lite-tests
169200
simpleTest
170201
mergeTest
171202
twigSplitTest
203+
filemodeTest

splitter/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ func (s *state) pruneTree(tree *git.Tree, excludes []string) (*git.Tree, error)
383383
err = tree.Walk(func(path string, entry *git.TreeEntry) error {
384384
// always add files at the root directory
385385
if entry.Type == git.ObjectBlob {
386-
if err := treeBuilder.Insert(entry.Name, entry.Id, git.FilemodeBlob); err != nil {
386+
if err := treeBuilder.Insert(entry.Name, entry.Id, entry.Filemode); err != nil {
387387
return err
388388
}
389389
return nil

0 commit comments

Comments
 (0)