From e8c88c70d9f738be1f0f83199ebea8d6e0fa96be Mon Sep 17 00:00:00 2001 From: David Turner Date: Mon, 14 Nov 2016 18:13:56 -0500 Subject: [PATCH] Fix mode setting in the case of moved executable files --- git-remote-hg | 12 +----------- test/main-push.t | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 5c36ca0..bec1609 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -778,17 +778,7 @@ def get_file_metadata(repo, p1, files): if 'rename' in f and 'mode' not in f: old = f['rename'] ctx = repo[p1][old] - m = '' - # .isexec(), .islink() only around in newer versions - if hasattr(ctx, 'isexec'): - m = ctx.isexec() - else: - m = ('x' in ctx.flags()) - if hasattr(ctx, 'islink'): - m = ctx.islink() - else: - m = ('l' in ctx.flags()) - f['mode'] = m + f['mode'] = ctx.flags() f['data'] = ctx.data() def get_merge_files(repo, p1, p2, files): diff --git a/test/main-push.t b/test/main-push.t index 4c70c31..e73365d 100755 --- a/test/main-push.t +++ b/test/main-push.t @@ -251,6 +251,32 @@ test_expect_success 'shared-marks unset to set' ' ) ' +test_expect_success 'push with renamed executable preserves executable bit' ' + test_when_finished "rm -rf hgrepo gitrepo*" && + + hg init hgrepo && + + ( + git init gitrepo && + cd gitrepo && + git remote add origin "hg::../hgrepo" && + echo one > content && + chmod a+x content && + git add content && + git commit -a -m one && + git mv content content2 && + git commit -a -m two && + git push origin master + ) && + + ( + cd hgrepo && + hg update && + stat content2 >expected && + grep -- -rwxr-xr-x expected + ) +' + # cleanup setting git config --global --unset remote-hg.shared-marks