Skip to content

Commit

Permalink
Add ability to dump the raw commit objects for all encrypted files
Browse files Browse the repository at this point in the history
Using the wildcard with the --show-raw flag will now dump all of the
encrypted files' commit objects. This is useful for debugging issues
like a failed smudge filter, which usually happens due to user error
when a file is staged before setting the *crypt* Git attribute.

To expand on that, if you see errors like:

    error: external filter "$(git rev-parse --show-toplevel)"/.git/crypt/smudge failed 1

...you can run `transcrypt --show-raw '*'` and look for any file that
is being stored as plain text, and that's your culprit.
  • Loading branch information
elasticdog committed Apr 26, 2015
1 parent f86767b commit a0b7d4e
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions transcrypt
Expand Up @@ -395,18 +395,25 @@ list_files() {

# show the raw file as stored in the git commit object
show_raw_file() {
if [[ ! -f "$show_file" ]]; then
if [[ -f $show_file ]]; then
# ensure the file is currently being tracked
local escaped_file=${show_file//\//\\\/}
if $(git ls-files --others -- "$show_file" | awk "/$escaped_file/{ exit 1 }"); then
file_paths=$(git ls-tree --name-only --full-name HEAD "$show_file")
else
die 1 'the file "%s" is not currently being tracked by git' "$show_file"
fi
elif [[ $show_file == '*' ]]; then
file_paths=$(git ls-crypt)
else
die 1 'the file "%s" does not exist' "$show_file"
fi

# ensure the file is currently being tracked
local escaped_show_file=${show_file//\//\\\/}
if $(git ls-files --others -- "$show_file" | awk "/$escaped_show_file/{ exit 1 }"); then
local file_path=$(git ls-tree --name-only --full-name HEAD "$show_file")
git show HEAD:"$file_path" --no-textconv
else
die 1 'the file "%s" is not currently being tracked by git' "$show_file"
fi
for file in $file_paths; do
printf '==> %s <==\n' "$file" >&2
git --no-pager show HEAD:"$file" --no-textconv
printf '\n' >&2
done
}

# print this script's usage message to stderr
Expand Down

0 comments on commit a0b7d4e

Please sign in to comment.