commit 630fc61f66dc259068303613f6f3cfc39f1d267f from: Stefan Sperling via: Thomas Adam date: Sun Jan 29 12:22:48 2023 UTC fix histedit -m on a commit which only changes filemode bits The commit was being miscategorized as a no-op change and dropped. Now the commit is retained and its log message is updated as expected. ok op, jamsek commit - 5d0e507d72eb3e7e37b2117812bbc39c7852b22d commit + 630fc61f66dc259068303613f6f3cfc39f1d267f blob - 1ef766456823715df13ecbf2112d94be62cf64d2 blob + 27852f29078039acf297d1eb6f667ff004418624 --- TODO +++ TODO @@ -18,8 +18,6 @@ got: 'got fetch' is supposed to work. To make this easier, if the HEAD symref points to a non-existent reference it should be updated by 'got fetch' to match the HEAD symref sent by the server. -- got histedit -m on a commit which only changes filemode bits results - in the commit being miscategorized as a no-op change and be dropped. network protocol: - add http(s) transport with libtls, speaking the two Git HTTP protocols blob - edc2bdd502f40016665e45418d4988558866917e blob + 439c945312b57aeab0f27bfe4dc1332e5a98c79f --- lib/worktree.c +++ lib/worktree.c @@ -2895,7 +2895,7 @@ merge_file_cb(void *arg, struct got_blob_object *blob1 } err = merge_file(&local_changes_subsumed, a->worktree, f_orig, f_deriv, f_deriv2, ondisk_path, path2, - sb.st_mode, a->label_orig, NULL, label_deriv2, + mode2, a->label_orig, NULL, label_deriv2, GOT_DIFF_ALGORITHM_PATIENCE, repo, a->progress_cb, a->progress_arg); } blob - 020abd3a8da16edd2d75278716efc534d6c9325e blob + 303300dcce6118b66bad71c7d40d3202e1cc6297 --- regress/cmdline/histedit.sh +++ regress/cmdline/histedit.sh @@ -2220,7 +2220,103 @@ test_histedit_umask() { test_done "$testroot" 0 } + +test_histedit_mesg_filemode_change() { + local testroot=`test_init histedit_mode_change` + + local orig_commit=`git_show_head $testroot/repo` + local orig_author_time=`git_show_author_time $testroot/repo` + + chmod +x $testroot/repo/alpha + git_commit $testroot/repo -m "set x bit on alpha" + local old_commit1=`git_show_head $testroot/repo` + local old_author_time1=`git_show_author_time $testroot/repo` + + got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null + ret=$? + if [ $ret -ne 0 ]; then + test_done "$testroot" "$ret" + return 1 + fi + + if [ -x $testroot/wt/alpha ]; then + echo "file alpha has unexpected executable bit" >&2 + test_done "$testroot" "1" + return 1 + fi + + cat > $testroot/editor.sh < $testroot/stdout) + + local new_commit1=`git_show_head $testroot/repo` + local new_author_time1=`git_show_author_time $testroot/repo` + + local short_old_commit1=`trim_obj_id 28 $old_commit1` + local short_new_commit1=`trim_obj_id 28 $new_commit1` + + echo "G alpha" > $testroot/stdout.expected + echo "$short_old_commit1 -> $short_new_commit1: set executable bit on alpha" \ + >> $testroot/stdout.expected + echo "Switching work tree to refs/heads/master" \ + >> $testroot/stdout.expected + + cmp -s $testroot/stdout.expected $testroot/stdout + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + + echo "alpha" > $testroot/content.expected + cat $testroot/wt/alpha > $testroot/content + cmp -s $testroot/content.expected $testroot/content + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/content.expected $testroot/content + test_done "$testroot" "$ret" + return 1 + fi + + if [ ! -x $testroot/wt/alpha ]; then + echo "file alpha lost its executable bit" >&2 + test_done "$testroot" "1" + return 1 + fi + + (cd $testroot/wt && got status > $testroot/stdout) + + echo -n > $testroot/stdout.expected + cmp -s $testroot/stdout.expected $testroot/stdout + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + + (cd $testroot/wt && got log -l1 | grep ' set executable bit on alpha' \ + > $testroot/stdout) + + echo ' set executable bit on alpha' > $testroot/stdout.expected + cmp -s $testroot/stdout.expected $testroot/stdout + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + + test_done "$testroot" "$ret" +} + test_parseargs "$@" run_test test_histedit_no_op run_test test_histedit_swap @@ -2244,3 +2340,4 @@ run_test test_histedit_prepend_line run_test test_histedit_mesg_invalid run_test test_histedit_resets_committer run_test test_histedit_umask +run_test test_histedit_mesg_filemode_change