Hey again.

I think I also managed to reproduce the first error:

$ git clone g...@github.com:calestyo/btrbk.git
$ cd btrbk
$ git checkout improve-ssh_filter_btrbk.sh


$ git rebase --interactive 53b3290e14ea9c8df6288bec981d8b28655c8fa7

This shows:
pick 9819fdc ssh_filter_btrbk.sh: convert to POSIX sh
pick 3d87f27 ssh_filter_btrbk.sh: use printf instead of echo
pick 2b53311 ssh_filter_btrbk.sh: set only needed directories in PATH
pick ec8e7a1 ssh_filter_btrbk.sh: use more common exit statuses
pick 0bd7374 ssh_filter_btrbk.sh: replace OpenSSH’s deprecated SSH_CLIENT
pick 7c77f0a ssh_filter_btrbk.sh: minor improvements
pick d3126c7 ssh_filter_btrbk.sh: further harden the shell execution environment
pick 7729be4 ssh_filter_btrbk.sh: properly normalise pathnames
pick 016e945 ssh_filter_btrbk.sh: forbid non-absolute pathnames to 
--restrict-path

Now delete all lines except for the first:
pick 9819fdc ssh_filter_btrbk.sh: convert to POSIX sh

in order to get rid of all those commits.


Then apply the attached patch (simulating the content that I had
changed) with some of the next upcoming commits:

$ patch < changes.patch


Then:
$ git crecord

and only select the "printf" lines, i.e.:
[~]    diff --git a/ssh_filter_btrbk.sh b/ssh_filter_btrbk.sh
       index 262cbbb..21074ae 100755
       3 hunks, 4 lines changed

   [ ]     @@ -3,7 +3,7 @@
            set -e
            set -u

      [ ]  -export PATH=/sbin:/bin:/usr/sbin:/usr/bin
      [ ]  +export PATH='/usr/bin:/bin'

            enable_log=
            restrict_path_list=

   [~]     @@ -41,8 +41,8 @@ reject_and_die()
            {
                local reason="$1"
                log_cmd 'auth.err' 'btrbk REJECT' "$reason"
      [ ]  -    echo "ERROR: ssh_filter_btrbk.sh: ssh command rejected: 
$reason: $SSH_ORIGINAL_COMMAND" 1>&2
      [ ]  -    exit 255
      [x]  +    printf 'ERROR: ssh_filter_btrbk.sh: ssh command rejected: %s: 
%s\n' "$reason" "$SSH_ORIGINAL_COMMAND" 1>&2
      [ ]  +    exit 1
            }

            run_cmd()

   [~]     @@ -171,7 +171,7 @@ while [ "$#" -ge 1 ]; do
                      ;;

                  *)
      [ ]  -          echo "ERROR: ssh_filter_btrbk.sh: failed to parse command 
line option: $key" 1>&2
      [x]  +          printf 'ERROR: ssh_filter_btrbk.sh: failed to parse 
command line option: %s\n' "$key" 1>&2
                      exit 255
                      ;;
                esac


Now "c", causes:
error: patch fragment without header at line 16: @@ -171,7 +171,8 @@
while [ "$#" -ge 1 ]; do
On branch improve-ssh_filter_btrbk.sh
Your branch is behind 'origin/improve-ssh_filter_btrbk.sh' by 8
commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        changes.patch

nothing added to commit but untracked files present (use "git add" to
track)
abort: commit failed: git exited with status 1


The same with --debug:
$ git crecord --debug
backup 'ssh_filter_btrbk.sh' as 
'/home/calestyo/foo/z/btrbk/.git/record-backups/ssh_filter_btrbk.sh.gu99sc7q'
applying patch
diff --git a/ssh_filter_btrbk.sh b/ssh_filter_btrbk.sh
index 262cbbb..21074ae 100755
--- a/ssh_filter_btrbk.sh
+++ b/ssh_filter_btrbk.sh
@@ -41,8 +41,9 @@ reject_and_die()
 {
     local reason="$1"
     log_cmd 'auth.err' 'btrbk REJECT' "$reason"
     echo "ERROR: ssh_filter_btrbk.sh: ssh command rejected: $reason: 
$SSH_ORIGINAL_COMMAND" 1>&2
     exit 255
+    printf 'ERROR: ssh_filter_btrbk.sh: ssh command rejected: %s: %s\n' 
"$reason" "$SSH_ORIGINAL_COMMAND" 1>&2
     exit 1
 }
 
 run_cmd()
@@ -171,7 +171,8 @@ while [ "$#" -ge 1 ]; do
           ;;
 
       *)
           echo "ERROR: ssh_filter_btrbk.sh: failed to parse command line 
option: $key" 1>&2
+          printf 'ERROR: ssh_filter_btrbk.sh: failed to parse command line 
option: %s\n' "$key" 1>&2
           exit 255
           ;;
     esac

error: patch fragment without header at line 16: @@ -171,7 +171,8 @@ while [ 
"$#" -ge 1 ]; do
On branch improve-ssh_filter_btrbk.sh
Your branch is behind 'origin/improve-ssh_filter_btrbk.sh' by 8 commits, and 
can be fast-forwarded.
  (use "git pull" to update your local branch)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        changes.patch

nothing added to commit but untracked files present (use "git add" to track)
restoring 
'/home/calestyo/foo/z/btrbk/.git/record-backups/ssh_filter_btrbk.sh.gu99sc7q' 
to 'ssh_filter_btrbk.sh'
abort: commit failed: git exited with status 1



Thanks,
Chris.

PS & offtopic:

Is "s" (for staging) supposed to work in the current Debian sid
version? And is bash completion supposed to work (i.e. $ git cre<tab>)?
diff --git a/ssh_filter_btrbk.sh b/ssh_filter_btrbk.sh
index 262cbbb..21074ae 100755
--- a/ssh_filter_btrbk.sh
+++ b/ssh_filter_btrbk.sh
@@ -3,7 +3,7 @@
 set -e
 set -u
 
-export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+export PATH='/usr/bin:/bin'
 
 enable_log=
 restrict_path_list=
@@ -41,8 +41,8 @@ reject_and_die()
 {
     local reason="$1"
     log_cmd 'auth.err' 'btrbk REJECT' "$reason"
-    echo "ERROR: ssh_filter_btrbk.sh: ssh command rejected: $reason: $SSH_ORIGINAL_COMMAND" 1>&2
-    exit 255
+    printf 'ERROR: ssh_filter_btrbk.sh: ssh command rejected: %s: %s\n' "$reason" "$SSH_ORIGINAL_COMMAND" 1>&2
+    exit 1
 }
 
 run_cmd()
@@ -171,7 +171,7 @@ while [ "$#" -ge 1 ]; do
           ;;
 
       *)
-          echo "ERROR: ssh_filter_btrbk.sh: failed to parse command line option: $key" 1>&2
+          printf 'ERROR: ssh_filter_btrbk.sh: failed to parse command line option: %s\n' "$key" 1>&2
           exit 255
           ;;
     esac

Reply via email to